當前位置: 首頁>>代碼示例>>PHP>>正文


PHP EntityManagerInterface::getAccessController方法代碼示例

本文整理匯總了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;
 }
開發者ID:alnutile,項目名稱:drunatra,代碼行數:14,代碼來源:FeedAddAccessCheck.php

示例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;
 }
開發者ID:anatalsceo,項目名稱:en-classe,代碼行數:27,代碼來源:NodeAddAccessCheck.php

示例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;
 }
開發者ID:anatalsceo,項目名稱:en-classe,代碼行數:30,代碼來源:EntityCreateAccessCheck.php

示例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);
 }
開發者ID:alnutile,項目名稱:drunatra,代碼行數:9,代碼來源:Field.php

示例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;
 }
開發者ID:anatalsceo,項目名稱:en-classe,代碼行數:14,代碼來源:NodeRevisionAccessCheck.php


注:本文中的Drupal\Core\Entity\EntityManagerInterface::getAccessController方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。