Chris@0: 'entity.manager']; Chris@18: Chris@18: /** Chris@18: * The entity type manager service. Chris@0: * Chris@18: * @var \Drupal\Core\Entity\EntityTypeManagerInterface Chris@0: */ Chris@18: protected $entityTypeManager; Chris@0: Chris@0: /** Chris@0: * Constructs a EntityCreateAccessCheck object. Chris@0: * Chris@18: * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager Chris@18: * The entity type manager service. Chris@0: */ Chris@18: public function __construct(EntityTypeManagerInterface $entity_type_manager) { Chris@18: $this->entityTypeManager = $entity_type_manager; Chris@0: } Chris@0: Chris@0: /** Chris@0: * Checks access to the node preview page. Chris@0: * Chris@0: * @param \Drupal\Core\Session\AccountInterface $account Chris@0: * The currently logged in account. Chris@0: * @param \Drupal\node\NodeInterface $node_preview Chris@0: * The node that is being previewed. Chris@0: * Chris@0: * @return string Chris@0: * A \Drupal\Core\Access\AccessInterface constant value. Chris@0: */ Chris@0: public function access(AccountInterface $account, NodeInterface $node_preview) { Chris@0: if ($node_preview->isNew()) { Chris@18: $access_controller = $this->entityTypeManager->getAccessControlHandler('node'); Chris@0: return $access_controller->createAccess($node_preview->bundle(), $account, [], TRUE); Chris@0: } Chris@0: else { Chris@0: return $node_preview->access('update', $account, TRUE); Chris@0: } Chris@0: } Chris@0: Chris@0: }