mirror of
https://gitlab.unicamp.br/infimecc_drupal11_modules/structural_pages.git
synced 2026-05-04 13:10:41 -03:00
Fallback para nós sem field_parent_page em findAncestor()
Tipos de nó que não participam da hierarquia estrutural (ex.: blog_post) agora delegam para getAncestorFromRoute(), que usa os plugins ParentEntityHandler registrados para determinar o ancestral. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -102,6 +102,7 @@ class StructuralPagesMenuBlock extends BlockBase implements ContainerFactoryPlug
|
||||
public function defaultConfiguration(): array
|
||||
{
|
||||
return [
|
||||
'label_display' => '0',
|
||||
'max_depth' => 50,
|
||||
'show_ancestor_title' => TRUE,
|
||||
'expand_active_trail' => TRUE,
|
||||
@@ -188,6 +189,9 @@ class StructuralPagesMenuBlock extends BlockBase implements ContainerFactoryPlug
|
||||
'#tree' => $tree,
|
||||
'#active_trail' => $active_trail,
|
||||
'#show_ancestor_title' => $this->configuration['show_ancestor_title'],
|
||||
'#attached' => [
|
||||
'library' => ['structural_pages/menu'],
|
||||
],
|
||||
'#cache' => [
|
||||
'tags' => $this->cacheTags,
|
||||
'contexts' => ['route', 'url.path'],
|
||||
@@ -237,7 +241,9 @@ class StructuralPagesMenuBlock extends BlockBase implements ContainerFactoryPlug
|
||||
}
|
||||
|
||||
if (!$node->hasField('field_parent_page')) {
|
||||
return NULL;
|
||||
// Tipo de nó não participa da hierarquia estrutural: tenta resolver o
|
||||
// ancestral pela rota (ex.: blog_post → autor via BlogUserHandler).
|
||||
return $this->getAncestorFromRoute();
|
||||
}
|
||||
|
||||
$visited = [];
|
||||
|
||||
Reference in New Issue
Block a user