public function Email::checkFieldAccess in Search API Saved Searches 8
Checks access to an operation on a given entity field.
This method will only be called for fields defined by this plugin and can be used to implement custom access restrictions for those fields.
Parameters
string $operation: The operation access should be checked for. Usually one of "view" or "edit".
\Drupal\Core\Field\FieldDefinitionInterface $field_definition: The field definition.
\Drupal\Core\Session\AccountInterface $account: The user session for which to check access.
\Drupal\Core\Field\FieldItemListInterface $items: (optional) The field values for which to check access, or NULL if access is checked for the field definition, without any specific value available.
Return value
\Drupal\Core\Access\AccessResultInterface The access result.
Overrides NotificationPluginBase::checkFieldAccess
See also
\Drupal\search_api_saved_searches\Entity\SavedSearchAccessControlHandler::checkFieldAccess()
File
- src/
Plugin/ search_api_saved_searches/ notification/ Email.php, line 375
Class
- Provides e-mails as a notification mechanism.
Namespace
Drupal\search_api_saved_searches\Plugin\search_api_saved_searches\notificationCode
public function checkFieldAccess($operation, FieldDefinitionInterface $field_definition, AccountInterface $account, FieldItemListInterface $items = NULL) {
// Make sure this is really our e-mail field.
if ($field_definition
->getName() !== 'mail') {
return parent::checkFieldAccess($operation, $field_definition, $account, $items);
}
if (!$this->configuration['registered_choose_mail']) {
$permission = SavedSearchAccessControlHandler::ADMIN_PERMISSION;
return AccessResult::allowedIf($account
->isAnonymous())
->addCacheableDependency($account)
->orIf(AccessResult::allowedIfHasPermission($account, $permission));
}
return parent::checkFieldAccess($operation, $field_definition, $account, $items);
}