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


PHP Pool::setAdminGroups方法代码示例

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


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

示例1: testGetDashboardGroups

 public function testGetDashboardGroups()
 {
     $admin_group1 = $this->getMock('Sonata\\AdminBundle\\Admin\\AdminInterface');
     $admin_group1->expects($this->once())->method('showIn')->will($this->returnValue(true));
     $admin_group2 = $this->getMock('Sonata\\AdminBundle\\Admin\\AdminInterface');
     $admin_group2->expects($this->once())->method('showIn')->will($this->returnValue(false));
     $container = $this->getMock('Symfony\\Component\\DependencyInjection\\ContainerInterface');
     $container->expects($this->any())->method('get')->will($this->onConsecutiveCalls($admin_group1, $admin_group2));
     $pool = new Pool($container, 'Sonata Admin', '/path/to/pic.png');
     $pool->setAdminGroups(array('adminGroup1' => array('items' => array('itemKey' => 'sonata.user.admin.group1')), 'adminGroup2' => array('itmes' => array('itemKey' => 'sonata.user.admin.group1')), 'adminGroup3' => array('items' => array('itemKey' => 'sonata.user.admin.group2'))));
     $groups = $pool->getDashboardGroups();
     $this->assertCount(1, $groups);
 }
开发者ID:natxet,项目名称:SonataAdminBundle,代码行数:13,代码来源:PoolTest.php

示例2: testGetKnpMenuWithNotGrantedList

 public function testGetKnpMenuWithNotGrantedList()
 {
     $request = $this->getMock('Symfony\\Component\\HttpFoundation\\Request');
     $adminGroups = array('bar' => array('label' => 'foo', 'icon' => '<i class="fa fa-edit"></i>', 'label_catalogue' => 'SonataAdminBundle', 'items' => array(array('admin' => 'sonata_admin_foo_service', 'label' => 'fooLabel')), 'item_adds' => array(), 'roles' => array()));
     $this->pool->setAdminGroups($adminGroups);
     $this->admin->expects($this->once())->method('hasRoute')->with($this->equalTo('list'))->will($this->returnValue(true));
     $this->admin->expects($this->any())->method('isGranted')->with($this->equalTo('LIST'))->will($this->returnValue(false));
     $menu = $this->twigExtension->getKnpMenu($request);
     $this->assertInstanceOf('Knp\\Menu\\ItemInterface', $menu);
     $this->assertArrayHasKey('bar', $menu->getChildren());
     foreach ($menu->getChildren() as $key => $child) {
         $this->assertInstanceOf('Knp\\Menu\\MenuItem', $child);
         $this->assertEquals('bar', $child->getName());
         $this->assertEquals($adminGroups['bar']['label'], $child->getLabel());
         // menu items
         $children = $child->getChildren();
         $this->assertCount(0, $children);
     }
 }
开发者ID:jerome-fix,项目名称:SonataAdminBundle,代码行数:19,代码来源:SonataAdminExtensionTest.php

示例3: testGetKnpMenuWithProvider

 public function testGetKnpMenuWithProvider()
 {
     $request = $this->getMock('Symfony\\Component\\HttpFoundation\\Request');
     $adminGroups = array("bar" => array("provider" => 'my_menu', "label_catalogue" => '', "icon" => '<i class="fa fa-edit"></i>', "roles" => array()));
     $this->pool->setAdminGroups($adminGroups);
     $menu = $this->twigExtension->getKnpMenu($request);
     $this->assertInstanceOf('Knp\\Menu\\ItemInterface', $menu);
     $this->assertArrayHasKey('bar', $menu->getChildren());
     foreach ($menu->getChildren() as $key => $child) {
         $this->assertInstanceOf('Knp\\Menu\\MenuItem', $child);
         $this->assertEquals("bar", $child->getName());
         $this->assertEquals("bar", $child->getLabel());
         // menu items
         $children = $child->getChildren();
         $this->assertCount(1, $children);
         $this->assertArrayHasKey('foo', $children);
         $this->assertInstanceOf('Knp\\Menu\\MenuItem', $child['foo']);
         $this->assertEquals('foo', $child['foo']->getLabel());
     }
 }
开发者ID:kwuerl,项目名称:SonataAdminBundle,代码行数:20,代码来源:SonataAdminExtensionTest.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::setAdminGroups方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。