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


PHP EntityTypeInterface::getAdminPermission方法代碼示例

本文整理匯總了PHP中Drupal\Core\Entity\EntityTypeInterface::getAdminPermission方法的典型用法代碼示例。如果您正苦於以下問題:PHP EntityTypeInterface::getAdminPermission方法的具體用法?PHP EntityTypeInterface::getAdminPermission怎麽用?PHP EntityTypeInterface::getAdminPermission使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Drupal\Core\Entity\EntityTypeInterface的用法示例。


在下文中一共展示了EntityTypeInterface::getAdminPermission方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: checkCreateAccess

 /**
  * Performs create access checks.
  *
  * This method is supposed to be overwritten by extending classes that
  * do their own custom access checking.
  *
  * @param \Drupal\Core\Session\AccountInterface $account
  *   The user for which to check access.
  * @param array $context
  *   An array of key-value pairs to pass additional context when needed.
  * @param string|null $entity_bundle
  *   (optional) The bundle of the entity. Required if the entity supports
  *   bundles, defaults to NULL otherwise.
  *
  * @return bool|null
  *   TRUE if access was granted, FALSE if access was denied and NULL if access
  *   could not be determined.
  */
 protected function checkCreateAccess(AccountInterface $account, array $context, $entity_bundle = NULL)
 {
     if ($admin_permission = $this->entityType->getAdminPermission()) {
         return $account->hasPermission($admin_permission);
     } else {
         return NULL;
     }
 }
開發者ID:anatalsceo,項目名稱:en-classe,代碼行數:26,代碼來源:EntityAccessController.php

示例2: checkCreateAccess

 /**
  * Performs create access checks.
  *
  * This method is supposed to be overwritten by extending classes that
  * do their own custom access checking.
  *
  * @param \Drupal\Core\Session\AccountInterface $account
  *   The user for which to check access.
  * @param array $context
  *   An array of key-value pairs to pass additional context when needed.
  * @param string|null $entity_bundle
  *   (optional) The bundle of the entity. Required if the entity supports
  *   bundles, defaults to NULL otherwise.
  *
  * @return \Drupal\Core\Access\AccessResultInterface
  *   The access result.
  */
 protected function checkCreateAccess(AccountInterface $account, array $context, $entity_bundle = NULL)
 {
     if ($admin_permission = $this->entityType->getAdminPermission()) {
         return AccessResult::allowedIfHasPermission($account, $admin_permission);
     } else {
         // No opinion.
         return AccessResult::neutral();
     }
 }
開發者ID:nstielau,項目名稱:drops-8,代碼行數:26,代碼來源:EntityAccessControlHandler.php

示例3: getCollectionRoute

 /**
  * Gets the collection route.
  *
  * @param \Drupal\Core\Entity\EntityTypeInterface $entity_type
  *   The entity type.
  *
  * @return \Symfony\Component\Routing\Route|null
  *   The generated route, if available.
  */
 protected function getCollectionRoute(EntityTypeInterface $entity_type)
 {
     if ($entity_type->hasLinkTemplate('collection') && $entity_type->hasListBuilderClass()) {
         $entity_type_id = $entity_type->id();
         $route = new Route($entity_type->getLinkTemplate('collection'));
         $route->setDefaults(['_entity_list' => $entity_type_id, '_title' => (string) $entity_type->getLabel()])->setRequirement('_permission', $entity_type->getAdminPermission())->setOption('_admin_route', TRUE);
         return $route;
     }
 }
開發者ID:drupalbristol,項目名稱:drupal-bristol-website,代碼行數:18,代碼來源:SponsorEntityTypeHtmlRouteProvider.php

示例4: deleteMultipleFormRoute

 /**
  * Returns the delete multiple form route.
  *
  * @param \Drupal\Core\Entity\EntityTypeInterface $entity_type
  *   The entity type.
  *
  * @return \Symfony\Component\Routing\Route|null
  *   The generated route, if available.
  */
 protected function deleteMultipleFormRoute(EntityTypeInterface $entity_type)
 {
     if ($entity_type->hasLinkTemplate('delete-multiple-form')) {
         $route = new Route($entity_type->getLinkTemplate('delete-multiple-form'));
         $route->setDefault('_form', '\\Drupal\\entity\\Form\\DeleteMultiple');
         $route->setDefault('entity_type_id', $entity_type->id());
         $route->setRequirement('_permission', $entity_type->getAdminPermission());
         return $route;
     }
 }
開發者ID:CIGIHub,項目名稱:bsia-drupal8,代碼行數:19,代碼來源:DeleteMultipleRouteProvider.php

示例5: testAccessDelete

 /**
  * @covers ::checkAccess
  *
  * @dataProvider providerTestAccessDelete
  */
 public function testAccessDelete($is_new, $is_fallback, $expected)
 {
     $this->entityType->getAdminPermission()->willReturn('test permission');
     $page = $this->prophesize(PageInterface::class);
     $page->isNew()->willReturn($is_new);
     $page->isFallbackPage()->willReturn($is_fallback);
     $page->uuid()->shouldBeCalled();
     $page->getEntityTypeId()->shouldBeCalled();
     // Ensure that the cache tag is added for the temporary conditions.
     if ($is_new || $is_fallback) {
         $this->setUpCacheContextsManager();
         $page->getCacheTags()->willReturn(['page:1']);
         $page->getCacheContexts()->willReturn([]);
         $page->getCacheMaxAge()->willReturn(0);
     }
     $account = $this->prophesize(AccountInterface::class);
     $account->hasPermission('test permission')->willReturn(TRUE);
     $account->id()->shouldBeCalled();
     $this->assertSame($expected, $this->pageAccess->access($page->reveal(), 'delete', NULL, $account->reveal()));
 }
開發者ID:pulibrary,項目名稱:recap,代碼行數:25,代碼來源:PageAccessTest.php

示例6: getSettingsFormRoute

 /**
  * Gets the settings form route.
  *
  * @param \Drupal\Core\Entity\EntityTypeInterface $entity_type
  *   The entity type.
  *
  * @return \Symfony\Component\Routing\Route|null
  *   The generated route, if available.
  */
 protected function getSettingsFormRoute(EntityTypeInterface $entity_type)
 {
     if (!$entity_type->getBundleEntityType()) {
         $route = new Route("/admin/structure/{$entity_type->id()}/settings");
         $route->setDefaults(['_form' => 'Drupal\\drupalbristol_sponsors\\Form\\SponsorEntitySettingsForm', '_title' => "{$entity_type->getLabel()} settings"])->setRequirement('_permission', $entity_type->getAdminPermission())->setOption('_admin_route', TRUE);
         return $route;
     }
 }
開發者ID:drupalbristol,項目名稱:drupal-bristol-website,代碼行數:17,代碼來源:SponsorEntityHtmlRouteProvider.php

示例7: getCollectionRoute

 /**
  * Gets the collection route.
  *
  * @param \Drupal\Core\Entity\EntityTypeInterface $entity_type
  *   The entity type.
  *
  * @return \Symfony\Component\Routing\Route|null
  *   The generated route, if available.
  */
 protected function getCollectionRoute(EntityTypeInterface $entity_type)
 {
     // If the entity type does not provide an admin permission, there is no way
     // to control access, so we cannot provide a route in a sensible way.
     if ($entity_type->hasLinkTemplate('collection') && $entity_type->hasListBuilderClass() && ($admin_permission = $entity_type->getAdminPermission())) {
         $route = new Route($entity_type->getLinkTemplate('collection'));
         $route->addDefaults(['_entity_list' => $entity_type->id(), '_title' => '@label entities', '_title_arguments' => ['@label' => $entity_type->getLabel()]])->setRequirement('_permission', $admin_permission);
         return $route;
     }
 }
開發者ID:eigentor,項目名稱:tommiblog,代碼行數:19,代碼來源:DefaultHtmlRouteProvider.php

示例8: getAdminPermission

 protected function getAdminPermission(EntityTypeInterface $entity_type)
 {
     switch ($entity_type->id()) {
         case 'node':
             return 'administer nodes';
         default:
             return $entity_type->getAdminPermission();
     }
 }
開發者ID:tedbow,項目名稱:scheduled-updates-demo,代碼行數:9,代碼來源:ModerationStateWidget.php


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