本文整理汇总了PHP中Drupal\Core\Entity\EntityManagerInterface::getAccessController方法的典型用法代码示例。如果您正苦于以下问题:PHP EntityManagerInterface::getAccessController方法的具体用法?PHP EntityManagerInterface::getAccessController怎么用?PHP EntityManagerInterface::getAccessController使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Drupal\Core\Entity\EntityManagerInterface
的用法示例。
在下文中一共展示了EntityManagerInterface::getAccessController方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: access
/**
* {@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;
}
示例2: access
/**
* 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;
}
示例3: access
/**
* 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;
}
示例4: access
/**
* {@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);
}
示例5: __construct
/**
* 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;
}