class FieldCollectionItemHostRevisionsOperationCheck in Field collection 8
Same name and namespace in other branches
- 8.3 src/Access/FieldCollectionItemHostRevisionsOperationCheck.php \Drupal\field_collection\Access\FieldCollectionItemHostRevisionsOperationCheck
Determines access to revision operations on the field collection item's host.
Hierarchy
- class \Drupal\field_collection\Access\FieldCollectionItemHostRevisionsOperationCheck implements AccessInterface
Expanded class hierarchy of FieldCollectionItemHostRevisionsOperationCheck
1 string reference to 'FieldCollectionItemHostRevisionsOperationCheck'
1 service uses FieldCollectionItemHostRevisionsOperationCheck
File
- src/
Access/ FieldCollectionItemHostRevisionsOperationCheck.php, line 15
Namespace
Drupal\field_collection\AccessView source
class FieldCollectionItemHostRevisionsOperationCheck implements AccessInterface {
/**
* The permission handler.
*
* @var \Drupal\user\PermissionHandlerInterface
*/
protected $permissionHandler;
/**
* The field collection item storage.
*
* @var \Drupal\Core\Entity\Sql\SqlContentEntityStorage
*/
protected $fieldCollectionItemStorage;
/**
* Constructs a new FieldCollectionItemHostRevisionsOperationCheck.
*
* @param \Drupal\user\PermissionHandlerInterface $permission_handler
* The permission handler.
*/
public function __construct(PermissionHandlerInterface $permission_handler) {
$this->permissionHandler = $permission_handler;
}
/**
* Checks operation access on the field collection item's host's revisions.
*
* @param \Drupal\Core\Session\AccountInterface $account
* The currently logged in account.
*
* TODO: Document params
*
* @return string
* A \Drupal\Core\Access\AccessInterface constant value.
*/
public function access(Route $route, AccountInterface $account, $field_collection_item_revision = NULL, FieldCollectionItem $field_collection_item = NULL) {
if ($field_collection_item_revision) {
$field_collection_item = \Drupal::entityTypeManager()
->getStorage('field_collection_item')
->loadRevision($field_collection_item_revision);
}
$operation = $route
->getRequirement('_access_field_collection_item_host_revisions');
$host = $field_collection_item
->getHost();
if ($host
->getEntityType()
->id() == 'node') {
return AccessResult::allowedIf($account
->hasPermission($operation . ' ' . $host
->getType() . ' revisions'));
}
else {
if ($host
->getEntityType()
->id() == 'field_collection_item') {
return $this
->access($route, $account, $host->revision_id, $host);
}
else {
return AccessResult::allowedIf($field_collection_item && $field_collection_item
->getHost()
->access($operation, $account))
->cachePerPermissions();
}
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
FieldCollectionItemHostRevisionsOperationCheck:: |
protected | property | The field collection item storage. | |
FieldCollectionItemHostRevisionsOperationCheck:: |
protected | property | The permission handler. | |
FieldCollectionItemHostRevisionsOperationCheck:: |
public | function | Checks operation access on the field collection item's host's revisions. | |
FieldCollectionItemHostRevisionsOperationCheck:: |
public | function | Constructs a new FieldCollectionItemHostRevisionsOperationCheck. |