本文整理匯總了PHP中Sonata\AdminBundle\Admin\Pool::hasAdminByClass方法的典型用法代碼示例。如果您正苦於以下問題:PHP Pool::hasAdminByClass方法的具體用法?PHP Pool::hasAdminByClass怎麽用?PHP Pool::hasAdminByClass使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Sonata\AdminBundle\Admin\Pool
的用法示例。
在下文中一共展示了Pool::hasAdminByClass方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: testGetAdminForClassWhenAdminClassIsSet
public function testGetAdminForClassWhenAdminClassIsSet()
{
$this->pool->setAdminServiceIds(array('sonata.user.admin.group1'));
$this->pool->setAdminClasses(array('someclass' => array('sonata.user.admin.group1')));
$this->assertTrue($this->pool->hasAdminByClass('someclass'));
$this->assertSame('adminUserClass', $this->pool->getAdminByClass('someclass'));
}
示例2: supports
/**
* {@inheritdoc}
*/
public function supports(PuliResource $resource)
{
if (false === $resource instanceof CmfResource) {
return false;
}
$payload = $resource->getPayload();
// sonata has dependency on ClassUtils so this is fine.
$class = ClassUtils::getClass($payload);
return $this->pool->hasAdminByClass($class);
}
示例3: enhance
/**
* {@inheritdoc}
*/
public function enhance(array $data, Resource $resource)
{
$object = $resource->getPayload();
// sonata has dependency on ClassUtils so this is fine.
$class = ClassUtils::getClass($object);
if (false === $this->pool->hasAdminByClass($class)) {
return $data;
}
$admin = $this->pool->getAdminByClass($class);
$links = array();
$routeCollection = $admin->getRoutes();
foreach ($routeCollection->getElements() as $code => $route) {
$routeName = $route->getDefault('_sonata_name');
$url = $this->urlGenerator->generate($routeName, array($admin->getIdParameter() => $admin->getUrlsafeIdentifier($object)), true);
$routeRole = substr($code, strlen($admin->getCode()) + 1);
$links[$routeRole] = $url;
}
$data['label'] = $admin->toString($object);
$data['sonata_label'] = $admin->getLabel();
$data['sonata_links'] = $links;
return $data;
}