/** * {@inheritdoc} */ public function access(Route $route, Request $request, AccountInterface $account) { // @todo Perhaps read config directly rather than load all importers. $access_controller = $this->entityManager->getAccessController('feeds_feed'); foreach ($this->entityManager->getStorageController('feeds_importer')->loadEnabled() as $importer) { if ($access_controller->createAccess($importer->id(), $account)) { return self::ALLOW; } } return static::DENY; }
/** * Checks access to the node add page for the node type. * * @param \Drupal\Core\Session\AccountInterface $account * The currently logged in account. * @param \Drupal\node\NodeTypeInterface $node_type * (optional) The node type. If not specified, access is allowed if there * exists at least one node type for which the user may create a node. * * @return string * A \Drupal\Core\Access\AccessInterface constant value. */ public function access(AccountInterface $account, NodeTypeInterface $node_type = NULL) { $access_controller = $this->entityManager->getAccessController('node'); // If checking whether a node of a particular type may be created. if ($node_type) { return $access_controller->createAccess($node_type->id(), $account) ? static::ALLOW : static::DENY; } // If checking whether a node of any type may be created. foreach (node_permissions_get_configured_types() as $node_type) { if ($access_controller->createAccess($node_type->id(), $account)) { return static::ALLOW; } } return static::DENY; }
/** * Checks access to create the entity type and bundle for the given route. * * @param \Symfony\Component\Routing\Route $route * The route to check against. * @param \Symfony\Component\HttpFoundation\Request $request * The request object. * @param \Drupal\Core\Session\AccountInterface $account * The currently logged in account. * * @return string * A \Drupal\Core\Access\AccessInterface constant value. */ public function access(Route $route, Request $request, AccountInterface $account) { list($entity_type, $bundle) = explode(':', $route->getRequirement($this->requirementsKey) . ':'); // The bundle argument can contain request argument placeholders like // {name}, loop over the raw variables and attempt to replace them in the // bundle name. If a placeholder does not exist, it won't get replaced. if ($bundle && strpos($bundle, '{') !== FALSE) { foreach ($request->get('_raw_variables')->all() as $name => $value) { $bundle = str_replace('{' . $name . '}', $value, $bundle); } // If we were unable to replace all placeholders, deny access. if (strpos($bundle, '{') !== FALSE) { return static::DENY; } } return $this->entityManager->getAccessController($entity_type)->createAccess($bundle, $account) ? static::ALLOW : static::DENY; }
/** * {@inheritdoc} */ public function access(AccountInterface $account) { $base_table = $this->get_base_table(); $access_controller = $this->entityManager->getAccessController($this->definition['entity_tables'][$base_table]); return $access_controller->fieldAccess('view', $this->getFieldDefinition(), $account); }
/** * Constructs a new NodeRevisionAccessCheck. * * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager * The entity manager. * @param \Drupal\Core\Database\Connection $connection * The database connection. */ public function __construct(EntityManagerInterface $entity_manager, Connection $connection) { $this->nodeStorage = $entity_manager->getStorage('node'); $this->nodeAccess = $entity_manager->getAccessController('node'); $this->connection = $connection; }