當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。