class ContentHubPageDisplayVariantSubscriber in Acquia Content Hub 8
Selects the simple page display variant.
Hierarchy
- class \Drupal\acquia_contenthub\EventSubscriber\ContentHubPageDisplayVariantSubscriber implements \Symfony\Component\EventDispatcher\EventSubscriberInterface
Expanded class hierarchy of ContentHubPageDisplayVariantSubscriber
See also
\Drupal\Core\Render\Plugin\DisplayVariant\SimplePageVariant
1 string reference to 'ContentHubPageDisplayVariantSubscriber'
1 service uses ContentHubPageDisplayVariantSubscriber
File
- src/
EventSubscriber/ ContentHubPageDisplayVariantSubscriber.php, line 15
Namespace
Drupal\acquia_contenthub\EventSubscriberView source
class ContentHubPageDisplayVariantSubscriber implements EventSubscriberInterface {
/**
* The current route match.
*
* @var \Drupal\Core\Routing\RouteMatchInterface
*/
protected $routeMatch;
/**
* ContentHubViewSubscriber constructor.
*
* @param \Drupal\Core\Routing\RouteMatchInterface $route_match
* The current route match.
*/
public function __construct(RouteMatchInterface $route_match) {
$this->routeMatch = $route_match;
}
/**
* Selects the block page display variant.
*
* @param \Drupal\Core\Render\PageDisplayVariantSelectionEvent $event
* The event to process.
*/
public function onSelectPageDisplayVariant(PageDisplayVariantSelectionEvent $event) {
if ($this->routeMatch
->getRouteName() === 'acquia_contenthub.content_entity_display.entity') {
$event
->setPluginId('contenthub_page');
}
}
/**
* {@inheritdoc}
*/
public static function getSubscribedEvents() {
$events[RenderEvents::SELECT_PAGE_DISPLAY_VARIANT][] = [
'onSelectPageDisplayVariant',
-1,
];
return $events;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ContentHubPageDisplayVariantSubscriber:: |
protected | property | The current route match. | |
ContentHubPageDisplayVariantSubscriber:: |
public static | function | Returns an array of event names this subscriber wants to listen to. | |
ContentHubPageDisplayVariantSubscriber:: |
public | function | Selects the block page display variant. | |
ContentHubPageDisplayVariantSubscriber:: |
public | function | ContentHubViewSubscriber constructor. |