mirror of
https://gitlab.unicamp.br/infimecc_drupal11_modules/structural_pages.git
synced 2026-03-10 02:17:42 -03:00
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:
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user