本文整理汇总了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);
}
示例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;
}
示例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());
}
示例4: warmUp
/**
* {@inheritdoc}
*/
public function warmUp($cacheDir)
{
foreach ($this->pool->getAdminServiceIds() as $id) {
$this->cache->load($this->pool->getInstance($id));
}
}