本文整理匯總了PHP中Sonata\AdminBundle\Admin\AdminInterface::getMenuFactory方法的典型用法代碼示例。如果您正苦於以下問題:PHP AdminInterface::getMenuFactory方法的具體用法?PHP AdminInterface::getMenuFactory怎麽用?PHP AdminInterface::getMenuFactory使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Sonata\AdminBundle\Admin\AdminInterface
的用法示例。
在下文中一共展示了AdminInterface::getMenuFactory方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: buildBreadcrumbs
/**
* {@inheritdoc}
* NEXT_MAJOR : make this method private.
*/
public function buildBreadcrumbs(AdminInterface $admin, $action, ItemInterface $menu = null)
{
if (!$menu) {
$menu = $admin->getMenuFactory()->createItem('root');
$menu = $this->createMenuItem($admin, $menu, 'dashboard', 'SonataAdminBundle', array('uri' => $admin->getRouteGenerator()->generate('sonata_admin_dashboard')));
}
$menu = $this->createMenuItem($admin, $menu, sprintf('%s_list', $admin->getClassnameLabel()), null, array('uri' => $admin->hasRoute('list') && $admin->isGranted('LIST') ? $admin->generateUrl('list') : null));
$childAdmin = $admin->getCurrentChildAdmin();
if ($childAdmin) {
$id = $admin->getRequest()->get($admin->getIdParameter());
$menu = $menu->addChild($admin->toString($admin->getSubject()), array('uri' => $admin->hasRoute('edit') && $admin->isGranted('EDIT') ? $admin->generateUrl('edit', array('id' => $id)) : null));
return $this->buildBreadcrumbs($childAdmin, $action, $menu);
}
if ('list' === $action && $admin->isChild()) {
$menu->setUri(false);
} elseif ('create' !== $action && $admin->hasSubject()) {
$menu = $menu->addChild($admin->toString($admin->getSubject()));
} else {
$menu = $this->createMenuItem($admin, $menu, sprintf('%s_%s', $admin->getClassnameLabel(), $action));
}
return $menu;
}