本文整理汇总了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);
}
示例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);
}
}
示例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());
}
}
示例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());
}