Add structural_pages_event submodule for Event entity support

Bridge submodule that registers Event entities (from event_management
module) as valid parent types for content_page nodes. Events act as
context containers (clears_site_section: TRUE), similar to users and
groups.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-02-06 07:32:59 -03:00
parent c1274bf3ce
commit eff3c0122f
4 changed files with 98 additions and 0 deletions

View File

@@ -0,0 +1,51 @@
<?php
declare(strict_types=1);
namespace Drupal\structural_pages_event\Plugin\ParentEntityHandler;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\Core\StringTranslation\TranslatableMarkup;
use Drupal\event_management\Entity\EventInterface;
use Drupal\structural_pages\Attribute\ParentEntityHandler;
use Drupal\structural_pages\ParentEntityHandler\ParentEntityHandlerBase;
/**
* Handler for event entities.
*
* This handler is provided by the structural_pages_event submodule and is only
* available when the Event Management module is installed.
*/
#[ParentEntityHandler(
id: 'event',
label: new TranslatableMarkup('Events (event)'),
entity_type_id: 'event',
provider_module: 'event_management',
clears_site_section: TRUE,
sort_field: 'title',
weight: 20,
)]
class EventHandler extends ParentEntityHandlerBase {
/**
* {@inheritdoc}
*/
public function getEntityFromRoute(RouteMatchInterface $route_match): ?EntityInterface {
$event = $route_match->getParameter('event');
if (!$event instanceof EventInterface) {
return NULL;
}
return $event;
}
/**
* {@inheritdoc}
*/
public function handlesEntity(EntityInterface $entity): bool {
return $entity instanceof EventInterface;
}
}