class ReferencePreviewAccessCheck in Bibliography & Citation 2.0.x
Same name and namespace in other branches
- 8 modules/bibcite_entity/src/Access/ReferencePreviewAccessCheck.php \Drupal\bibcite_entity\Access\ReferencePreviewAccessCheck
Determines access to reference previews.
Hierarchy
- class \Drupal\bibcite_entity\Access\ReferencePreviewAccessCheck implements AccessInterface
Expanded class hierarchy of ReferencePreviewAccessCheck
1 string reference to 'ReferencePreviewAccessCheck'
- bibcite_entity.services.yml in modules/
bibcite_entity/ bibcite_entity.services.yml - modules/bibcite_entity/bibcite_entity.services.yml
1 service uses ReferencePreviewAccessCheck
File
- modules/
bibcite_entity/ src/ Access/ ReferencePreviewAccessCheck.php, line 15
Namespace
Drupal\bibcite_entity\AccessView source
class ReferencePreviewAccessCheck implements AccessInterface {
/**
* The entity type manager.
*
* @var \Drupal\Core\Entity\EntityTypeManagerInterface
*/
protected $entityTypeManager;
/**
* Constructs a ReferencePreviewAccessCheck object.
*
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
* The entity manager.
*/
public function __construct(EntityTypeManagerInterface $entity_type_manager) {
$this->entityTypeManager = $entity_type_manager;
}
/**
* Checks access to the reference preview page.
*
* @param \Drupal\Core\Session\AccountInterface $account
* The currently logged in account.
* @param \Drupal\bibcite_entity\Entity\ReferenceInterface $bibcite_reference_preview
* The reference that is being previewed.
*
* @return string
* A \Drupal\Core\Access\AccessInterface constant value.
*/
public function access(AccountInterface $account, ReferenceInterface $bibcite_reference_preview) {
$access_control_handler = $this->entityTypeManager
->getAccessControlHandler('bibcite_reference');
// If checking whether a reference of a particular type may be created.
if ($bibcite_reference_preview
->isNew()) {
return $access_control_handler
->createAccess($bibcite_reference_preview
->bundle(), $account, [], TRUE);
}
else {
return $bibcite_reference_preview
->access('update', $account, TRUE);
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ReferencePreviewAccessCheck:: |
protected | property | The entity type manager. | |
ReferencePreviewAccessCheck:: |
public | function | Checks access to the reference preview page. | |
ReferencePreviewAccessCheck:: |
public | function | Constructs a ReferencePreviewAccessCheck object. |