mirror of
https://gitlab.unicamp.br/infimecc_drupal11_modules/structural_pages.git
synced 2026-03-08 17:47:42 -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:
@@ -67,6 +67,17 @@ function structural_pages_entity_presave(EntityInterface $entity): void {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the configured site section vocabulary machine name.
|
||||
*
|
||||
* @return string
|
||||
* The vocabulary ID (e.g., 'site_sections').
|
||||
*/
|
||||
function _structural_pages_get_vocabulary(): string {
|
||||
return \Drupal::config('structural_pages.settings')
|
||||
->get('site_section_vocabulary') ?? 'site_sections';
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the site section ID from a parent entity.
|
||||
*
|
||||
@@ -82,9 +93,9 @@ function _structural_pages_get_section_from_parent(string $parent_entity_type, i
|
||||
$entity_type_manager = \Drupal::entityTypeManager();
|
||||
|
||||
if ($parent_entity_type === 'taxonomy_term') {
|
||||
// If parent is a taxonomy term, verify it's from site_sections vocabulary.
|
||||
// If parent is a taxonomy term, verify it's from the configured vocabulary.
|
||||
$term = $entity_type_manager->getStorage('taxonomy_term')->load($parent_id);
|
||||
if ($term instanceof TermInterface && $term->bundle() === 'site_sections') {
|
||||
if ($term instanceof TermInterface && $term->bundle() === _structural_pages_get_vocabulary()) {
|
||||
return $term->id();
|
||||
}
|
||||
return NULL;
|
||||
@@ -224,7 +235,7 @@ function structural_pages_token_info(): array {
|
||||
|
||||
$info['tokens']['node']['site-section-path'] = [
|
||||
'name' => t('Site Section Path'),
|
||||
'description' => t('The hierarchical path of the site_sections taxonomy (e.g., undergraduate/courses).'),
|
||||
'description' => t('The hierarchical path of the site section taxonomy (e.g., undergraduate/courses).'),
|
||||
];
|
||||
|
||||
$info['tokens']['term']['hierarchy-path'] = [
|
||||
|
||||
Reference in New Issue
Block a user