class EntityAnalyzerSubscriber in Entity Pager 8
Same name and namespace in other branches
- 2.0.x src/EventSubscriber/EntityAnalyzerSubscriber.php \Drupal\entity_pager\EventSubscriber\EntityAnalyzerSubscriber
Provides feedback about the current entity used by the entity pager.
Hierarchy
- class \Drupal\entity_pager\EventSubscriber\EntityAnalyzerSubscriber implements \Symfony\Component\EventDispatcher\EventSubscriberInterface
Expanded class hierarchy of EntityAnalyzerSubscriber
1 file declares its use of EntityAnalyzerSubscriber
- EntityAnalyzerSubscriberTest.php in tests/
src/ Unit/ EntityAnalyzerSubscriberTest.php
File
- src/
EventSubscriber/ EntityAnalyzerSubscriber.php, line 12
Namespace
Drupal\entity_pager\EventSubscriberView source
class EntityAnalyzerSubscriber implements EventSubscriberInterface {
/**
* {@inheritdoc}
*/
public static function getSubscribedEvents() {
$events = [];
$events[EntityPagerEvents::ENTITY_PAGER_ANALYZE][] = [
'onEntityPagerAnalyze',
];
return $events;
}
/**
* Checks if there is a valid entity for the pager.
*
* @param \Drupal\entity_pager\Event\EntityPagerAnalyzeEvent $event
* The analyze event.
*/
public function onEntityPagerAnalyze(EntityPagerAnalyzeEvent $event) {
$entity = $event
->getEntityPager()
->getEntity();
if (!$entity) {
$event
->log('No Entity on page.');
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
EntityAnalyzerSubscriber:: |
public static | function | Returns an array of event names this subscriber wants to listen to. | |
EntityAnalyzerSubscriber:: |
public | function | Checks if there is a valid entity for the pager. |