You are here

class FieldCollectionItemHostAddOperationCheck in Field collection 8.3

Same name and namespace in other branches
  1. 8 src/Access/FieldCollectionItemHostAddOperationCheck.php \Drupal\field_collection\Access\FieldCollectionItemHostAddOperationCheck

Determines access to operations on the field collection item's host.

Hierarchy

Expanded class hierarchy of FieldCollectionItemHostAddOperationCheck

1 string reference to 'FieldCollectionItemHostAddOperationCheck'
field_collection.services.yml in ./field_collection.services.yml
field_collection.services.yml
1 service uses FieldCollectionItemHostAddOperationCheck
access_check.field_collection_item.host_add_operation_add in ./field_collection.services.yml
Drupal\field_collection\Access\FieldCollectionItemHostAddOperationCheck

File

src/Access/FieldCollectionItemHostAddOperationCheck.php, line 12

Namespace

Drupal\field_collection\Access
View 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

Namesort descending Modifiers Type Description Overrides
FieldCollectionItemHostAddOperationCheck::$entityTypeManager protected property The entity type manager.
FieldCollectionItemHostAddOperationCheck::access public function Checks access to add a field collection item to its future host.
FieldCollectionItemHostAddOperationCheck::__construct public function Constructs a FieldCollectionItemHostAddOperationCheck object.