mirror of
https://gitlab.unicamp.br/infimecc_drupal11_modules/structural_pages.git
synced 2026-03-09 10:07:40 -03:00
Make site section vocabulary configurable and simplify settings form
Add a vocabulary selector to the settings form so the site section vocabulary is no longer hardcoded. Remove node bundle checkboxes (section_page/content_page are always included), keep user and group as configurable parent targets. All hardcoded 'site_sections' references in PHP replaced with dynamic config reads via helper. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -20,7 +20,7 @@ use Drupal\taxonomy\TermInterface;
|
||||
entity_type_id: 'taxonomy_term',
|
||||
clears_site_section: FALSE,
|
||||
sort_field: 'name',
|
||||
bundle_restrictions: ['site_sections'],
|
||||
bundle_restrictions: [],
|
||||
weight: 0,
|
||||
)]
|
||||
class TaxonomyTermHandler extends ParentEntityHandlerBase {
|
||||
@@ -61,6 +61,19 @@ class TaxonomyTermHandler extends ParentEntityHandlerBase {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function handlesEntity(EntityInterface $entity): bool {
|
||||
if ($entity->getEntityTypeId() !== 'taxonomy_term') {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
$vocabulary = \Drupal::config('structural_pages.settings')
|
||||
->get('site_section_vocabulary') ?? 'site_sections';
|
||||
return $entity->bundle() === $vocabulary;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
@@ -69,8 +82,7 @@ class TaxonomyTermHandler extends ParentEntityHandlerBase {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// Only site_sections terms can be site sections.
|
||||
if ($entity->bundle() !== 'site_sections') {
|
||||
if (!$this->handlesEntity($entity)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user