当前位置: 首页>>代码示例>>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;未经允许,请勿转载。