class HomeboxAddAccessCheck in Homebox 8
Determines access to for reference add pages.
Hierarchy
- class \Drupal\homebox\Access\HomeboxAddAccessCheck implements AccessInterface
Expanded class hierarchy of HomeboxAddAccessCheck
1 string reference to 'HomeboxAddAccessCheck'
1 service uses HomeboxAddAccessCheck
File
- src/
Access/ HomeboxAddAccessCheck.php, line 16
Namespace
Drupal\homebox\AccessView source
class HomeboxAddAccessCheck implements AccessInterface {
/**
* The entity manager.
*
* @var \Drupal\Core\Entity\EntityTypeManagerInterface
*/
protected $entityManager;
/**
* Constructs a EntityCreateAccessCheck object.
*
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_manager
* The entity manager.
*/
public function __construct(EntityTypeManagerInterface $entity_manager) {
$this->entityManager = $entity_manager;
}
/**
* Checks access to the reference add page for the reference type.
*
* @param \Drupal\Core\Session\AccountInterface $account
* The currently logged in account.
* @param \Drupal\homebox\Entity\HomeboxInterface $homebox
* (optional) The homebox.
*
* @return string
* A \Drupal\Core\Access\AccessInterface constant value.
*/
public function access(AccountInterface $account, HomeboxInterface $homebox = NULL) {
$access_control_handler = $this->entityManager
->getAccessControlHandler('homebox_layout');
// If checking whether a reference of a particular type may be created.
if ($account
->hasPermission('administer homebox_layout')) {
return AccessResult::allowed()
->cachePerPermissions();
}
if ($homebox) {
return $access_control_handler
->createAccess($homebox
->id(), $account, [], TRUE);
}
// No opinion.
return AccessResult::neutral();
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
HomeboxAddAccessCheck:: |
protected | property | The entity manager. | |
HomeboxAddAccessCheck:: |
public | function | Checks access to the reference add page for the reference type. | |
HomeboxAddAccessCheck:: |
public | function | Constructs a EntityCreateAccessCheck object. |