当前位置: 首页>>代码示例>>PHP>>正文


PHP Pool::getAdminServiceIds方法代码示例

本文整理汇总了PHP中Sonata\AdminBundle\Admin\Pool::getAdminServiceIds方法的典型用法代码示例。如果您正苦于以下问题:PHP Pool::getAdminServiceIds方法的具体用法?PHP Pool::getAdminServiceIds怎么用?PHP Pool::getAdminServiceIds使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Sonata\AdminBundle\Admin\Pool的用法示例。


在下文中一共展示了Pool::getAdminServiceIds方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getRoles

 /**
  * @return array
  */
 public function getRoles()
 {
     $roles = array();
     $rolesReadOnly = array();
     if (!$this->securityContext->getToken()) {
         return array($roles, $rolesReadOnly);
     }
     // get roles from the Admin classes
     foreach ($this->pool->getAdminServiceIds() as $id) {
         try {
             $admin = $this->pool->getInstance($id);
         } catch (\Exception $e) {
             continue;
         }
         $isMaster = $admin->isGranted('MASTER');
         $securityHandler = $admin->getSecurityHandler();
         // TODO get the base role from the admin or security handler
         $baseRole = $securityHandler->getBaseRole($admin);
         if (strlen($baseRole) == 0) {
             // the security handler related to the admin does not provide a valid string
             continue;
         }
         foreach ($admin->getSecurityInformation() as $role => $permissions) {
             $role = sprintf($baseRole, $role);
             if ($isMaster) {
                 // if the user has the MASTER permission, allow to grant access the admin roles to other users
                 $roles[$role] = $role;
             } elseif ($this->securityContext->isGranted($role)) {
                 // although the user has no MASTER permission, allow the currently logged in user to view the role
                 $rolesReadOnly[$role] = $role;
             }
         }
     }
     $isMaster = $this->securityContext->isGranted('ROLE_SUPER_ADMIN');
     // get roles from the service container
     foreach ($this->rolesHierarchy as $name => $rolesHierarchy) {
         if ($this->securityContext->isGranted($name) || $isMaster) {
             $roles[$name] = $name . ': ' . implode(', ', $rolesHierarchy);
             foreach ($rolesHierarchy as $role) {
                 if (!isset($roles[$role])) {
                     $roles[$role] = $role;
                 }
             }
         }
     }
     return array($roles, $rolesReadOnly);
 }
开发者ID:morille,项目名称:SonataUserBundle,代码行数:50,代码来源:EditableRolesBuilder.php

示例2: extract

 /**
  * Extract messages to MessageCatalogue.
  *
  * @return MessageCatalogue
  *
  * @throws \Exception|\RuntimeException
  */
 public function extract()
 {
     if ($this->catalogue) {
         throw new \RuntimeException('Invalid state');
     }
     $this->catalogue = new MessageCatalogue();
     foreach ($this->adminPool->getAdminServiceIds() as $id) {
         $admin = $this->getAdmin($id);
         $this->translator = $admin->getTranslator();
         $this->labelStrategy = $admin->getLabelTranslatorStrategy();
         $this->domain = $admin->getTranslationDomain();
         $admin->setTranslator($this);
         $admin->setSecurityHandler($this);
         $admin->setLabelTranslatorStrategy($this);
         //            foreach ($admin->getChildren() as $child) {
         //                $child->setTranslator($this);
         //            }
         // call the different public method
         $methods = array('getShow' => array(array()), 'getDatagrid' => array(array()), 'getList' => array(array()), 'getForm' => array(array()), 'getBreadcrumbs' => array(array('list'), array('edit'), array('create'), array('update'), array('batch'), array('delete')));
         if ($this->logger) {
             $this->logger->info(sprintf('Retrieving message from admin:%s - class: %s', $admin->getCode(), get_class($admin)));
         }
         foreach ($methods as $method => $calls) {
             foreach ($calls as $args) {
                 try {
                     call_user_func_array(array($admin, $method), $args);
                 } catch (\Exception $e) {
                     if ($this->logger) {
                         $this->logger->error(sprintf('ERROR : admin:%s - Raise an exception : %s', $admin->getCode(), $e->getMessage()));
                     }
                     throw $e;
                 }
             }
         }
     }
     $catalogue = $this->catalogue;
     $this->catalogue = false;
     return $catalogue;
 }
开发者ID:robhunt3r,项目名称:SonataAdminBundle,代码行数:46,代码来源:AdminExtractor.php

示例3: testGetAdminServiceIds

 public function testGetAdminServiceIds()
 {
     $this->pool->setAdminServiceIds(array('sonata.user.admin.group1', 'sonata.user.admin.group2', 'sonata.user.admin.group3'));
     $this->assertEquals(array('sonata.user.admin.group1', 'sonata.user.admin.group2', 'sonata.user.admin.group3'), $this->pool->getAdminServiceIds());
 }
开发者ID:r1pp3rj4ck,项目名称:SonataAdminBundle,代码行数:5,代码来源:PoolTest.php

示例4: warmUp

 /**
  * {@inheritdoc}
  */
 public function warmUp($cacheDir)
 {
     foreach ($this->pool->getAdminServiceIds() as $id) {
         $this->cache->load($this->pool->getInstance($id));
     }
 }
开发者ID:robhunt3r,项目名称:SonataAdminBundle,代码行数:9,代码来源:RoutesCacheWarmUp.php


注:本文中的Sonata\AdminBundle\Admin\Pool::getAdminServiceIds方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。