public function QueryAccessSubscriber::onEventOnlyQueryAccess in Entity API 8
Modifies the access conditions based on the node type.
This is just a convenient example for testing whether the event-only query access subscriber is added to entity types that do not specify a query access handler; in this case: node.
Parameters
\Drupal\entity\QueryAccess\QueryAccessEvent $event: The event.
File
- tests/
modules/ entity_module_test/ src/ EventSubscriber/ QueryAccessSubscriber.php, line 96
Class
Namespace
Drupal\entity_module_test\EventSubscriberCode
public function onEventOnlyQueryAccess(QueryAccessEvent $event) {
if (\Drupal::state()
->get('test_event_only_query_access')) {
$conditions = $event
->getConditions();
$conditions
->addCondition('type', 'foo');
$cacheability = \Drupal::state()
->get('event_only_query_acccess_cacheability');
if ($cacheability instanceof CacheableDependencyInterface) {
$conditions
->addCacheableDependency($cacheability);
}
}
}