class FieldCollectionItemHostAddOperationCheck in Field collection 8
Same name and namespace in other branches
- 8.3 src/Access/FieldCollectionItemHostAddOperationCheck.php \Drupal\field_collection\Access\FieldCollectionItemHostAddOperationCheck
Determines access to operations on the field collection item's host.
Hierarchy
- class \Drupal\field_collection\Access\FieldCollectionItemHostAddOperationCheck implements AccessInterface
Expanded class hierarchy of FieldCollectionItemHostAddOperationCheck
1 string reference to 'FieldCollectionItemHostAddOperationCheck'
1 service uses FieldCollectionItemHostAddOperationCheck
File
- src/
Access/ FieldCollectionItemHostAddOperationCheck.php, line 12
Namespace
Drupal\field_collection\AccessView source
class FieldCollectionItemHostAddOperationCheck implements AccessInterface {
/**
* The entity type manager.
*
* @var \Drupal\Core\Entity\EntityTypeManagerInterface
*/
protected $entityTypeManager;
/**
* Constructs a FieldCollectionItemHostAddOperationCheck object.
*
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
* The entity type manager.
*/
public function __construct(EntityTypeManagerInterface $entity_type_manager) {
$this->entityTypeManager = $entity_type_manager;
}
/**
* Checks access to add a field collection item to its future host.
*
* @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(AccountInterface $account, $host_type, $host_id) {
$access_control_handler = $this->entityTypeManager
->getAccessControlHandler($host_type);
$host = $this->entityTypeManager
->getStorage($host_type)
->load($host_id);
return $access_control_handler
->access($host, 'update', $account, TRUE);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
FieldCollectionItemHostAddOperationCheck:: |
protected | property | The entity type manager. | |
FieldCollectionItemHostAddOperationCheck:: |
public | function | Checks access to add a field collection item to its future host. | |
FieldCollectionItemHostAddOperationCheck:: |
public | function | Constructs a FieldCollectionItemHostAddOperationCheck object. |