本文整理匯總了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));
}
}