class SearchPageAccessControlHandler
Same name and namespace in other branches
- 11.x core/modules/search/src/SearchPageAccessControlHandler.php \Drupal\search\SearchPageAccessControlHandler
Defines the access control handler for the search page entity type.
Hierarchy
- class \Drupal\Core\Entity\EntityHandlerBase uses \Drupal\Core\StringTranslation\StringTranslationTrait, \Drupal\Core\DependencyInjection\DependencySerializationTrait
- class \Drupal\Core\Entity\EntityAccessControlHandler extends \Drupal\Core\Entity\EntityAccessControlHandlerInterface implements \Drupal\Core\Entity\EntityHandlerBase
- class \Drupal\search\SearchPageAccessControlHandler implements \Drupal\Core\Entity\EntityAccessControlHandler
- class \Drupal\Core\Entity\EntityAccessControlHandler extends \Drupal\Core\Entity\EntityAccessControlHandlerInterface implements \Drupal\Core\Entity\EntityHandlerBase
Expanded class hierarchy of SearchPageAccessControlHandler
See also
\Drupal\search\Entity\SearchPage
File
-
core/
modules/ search/ src/ SearchPageAccessControlHandler.php, line 16
Namespace
Drupal\searchView source
class SearchPageAccessControlHandler extends EntityAccessControlHandler {
/**
* {@inheritdoc}
*/
protected function checkAccess(EntityInterface $entity, $operation, AccountInterface $account) {
/** @var \Drupal\search\SearchPageInterface $entity */
if (in_array($operation, [
'delete',
'disable',
])) {
if ($entity->isDefaultSearch()) {
return AccessResult::forbidden()->addCacheableDependency($entity);
}
else {
return parent::checkAccess($entity, $operation, $account)->addCacheableDependency($entity);
}
}
if ($operation == 'view') {
if (!$entity->status()) {
return AccessResult::forbidden()->addCacheableDependency($entity);
}
$plugin = $entity->getPlugin();
if ($plugin instanceof AccessibleInterface) {
return $plugin->access($operation, $account, TRUE)
->addCacheableDependency($entity);
}
return AccessResult::allowed()->addCacheableDependency($entity);
}
return parent::checkAccess($entity, $operation, $account);
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.