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


PHP Pool::getAdminGroups方法代码示例

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


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

示例1: createSidebarMenu

 /**
  * Builds sidebar menu.
  *
  * @return ItemInterface
  */
 public function createSidebarMenu()
 {
     $menu = $this->factory->createItem('root');
     foreach ($this->pool->getAdminGroups() as $name => $group) {
         $extras = array('icon' => $group['icon'], 'label_catalogue' => $group['label_catalogue'], 'roles' => $group['roles']);
         $menuProvider = isset($group['provider']) ? $group['provider'] : 'sonata_group_menu';
         $subMenu = $this->provider->get($menuProvider, array('name' => $name, 'group' => $group));
         $subMenu = $menu->addChild($subMenu);
         $subMenu->setExtras(array_merge($subMenu->getExtras(), $extras));
     }
     $event = new ConfigureMenuEvent($this->factory, $menu);
     $this->eventDispatcher->dispatch(ConfigureMenuEvent::SIDEBAR, $event);
     return $event->getMenu();
 }
开发者ID:robhunt3r,项目名称:SonataAdminBundle,代码行数:19,代码来源:MenuBuilder.php

示例2: getKnpMenu

 /**
  * Get KnpMenu
  *
  * @param Request $request
  *
  * @return ItemInterface
  */
 public function getKnpMenu(Request $request = null)
 {
     $menuFactory = new MenuFactory();
     $menu = $menuFactory->createItem('root')->setExtra('request', $request);
     foreach ($this->pool->getAdminGroups() as $name => $group) {
         $menu->addChild($name, array('label' => $group['label']))->setAttributes(array('icon' => $group['icon'], 'label_catalogue' => $group['label_catalogue']))->setExtra('roles', $group['roles']);
         foreach ($group['items'] as $item) {
             if (array_key_exists('admin', $item) && $item['admin'] != null) {
                 $admin = $this->pool->getInstance($item['admin']);
                 // skip menu item if no `list` url is available or user doesn't have the LIST access rights
                 if (!$admin->hasRoute('list') || !$admin->isGranted('LIST')) {
                     continue;
                 }
                 $label = $admin->getLabel();
                 $route = $admin->generateUrl('list');
                 $translationDomain = $admin->getTranslationDomain();
             } else {
                 $label = $item['label'];
                 $route = $this->router->generate($item['route'], $item['route_params']);
                 $translationDomain = $group['label_catalogue'];
                 $admin = null;
             }
             $menu[$name]->addChild($label, array('uri' => $route))->setExtra('translationdomain', $translationDomain)->setExtra('admin', $admin);
         }
     }
     return $menu;
 }
开发者ID:jerome-fix,项目名称:SonataAdminBundle,代码行数:34,代码来源:SonataAdminExtension.php

示例3: createSidebarMenu

 /**
  * Builds sidebar menu.
  *
  * @return ItemInterface
  */
 public function createSidebarMenu()
 {
     $menu = $this->factory->createItem('root', array('extras' => array('request' => $this->request)));
     foreach ($this->pool->getAdminGroups() as $name => $group) {
         $attributes = array();
         $extras = array('icon' => $group['icon'], 'label_catalogue' => $group['label_catalogue'], 'roles' => $group['roles']);
         // Check if the menu group is built by a menu provider
         if (isset($group['provider'])) {
             $subMenu = $this->provider->get($group['provider']);
             $menu->addChild($subMenu)->setExtras(array_merge($subMenu->getExtras(), $extras))->setAttributes(array_merge($subMenu->getAttributes(), $attributes));
             continue;
         }
         // The menu group is built by config
         $menu->addChild($name, array('label' => $group['label'], 'attributes' => $attributes, 'extras' => $extras));
         foreach ($group['items'] as $item) {
             if (isset($item['admin']) && !empty($item['admin'])) {
                 $admin = $this->pool->getInstance($item['admin']);
                 // skip menu item if no `list` url is available or user doesn't have the LIST access rights
                 if (!$admin->hasRoute('list') || !$admin->isGranted('LIST')) {
                     continue;
                 }
                 $label = $admin->getLabel();
                 $options = $admin->generateMenuUrl('list');
                 $options['extras'] = array('translation_domain' => $admin->getTranslationDomain(), 'admin' => $admin);
             } else {
                 $label = $item['label'];
                 $options = array('route' => $item['route'], 'routeParameters' => $item['route_params'], 'extras' => array('translation_domain' => $group['label_catalogue']));
             }
             $menu[$name]->addChild($label, $options);
         }
         if (0 === count($menu[$name]->getChildren())) {
             $menu->removeChild($name);
         }
     }
     $event = new ConfigureMenuEvent($this->factory, $menu);
     $this->eventDispatcher->dispatch(ConfigureMenuEvent::SIDEBAR, $event);
     return $event->getMenu();
 }
开发者ID:clavier-souris,项目名称:SonataAdminBundle,代码行数:43,代码来源:MenuBuilder.php

示例4: testGetAdminGroups

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


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