本文整理汇总了PHP中Knp\Menu\ItemInterface::addChild方法的典型用法代码示例。如果您正苦于以下问题:PHP ItemInterface::addChild方法的具体用法?PHP ItemInterface::addChild怎么用?PHP ItemInterface::addChild使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Knp\Menu\ItemInterface
的用法示例。
在下文中一共展示了ItemInterface::addChild方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: buildCategoryMenu
/**
* @param \Knp\Menu\ItemInterface $menu The item to fill with $routes
* @param array $options The item options
* @param string $currentUri The current URI
*/
public function buildCategoryMenu(ItemInterface $menu, array $options = array(), $currentUri = null)
{
//$categories = $this->categoryManager->getCategoryTree();
//$this->fillMenu($menu, $categories, $options, $currentUri);
$menu->addChild('home', array('route' => 'home'));
$menu->addChild('home2', array('route' => 'home'));
}
示例2: configureSideMenu
/**
* @param MenuItemInterface $menu
* @param $action
* @param AdminInterface $childAdmin
*/
protected function configureSideMenu(MenuItemInterface $menu, $action, AdminInterface $childAdmin = null)
{
$pool = $this->container->get('sonata.admin.pool');
$adminGroups = $pool->getAdminGroups();
foreach ($adminGroups as $name => $adminGroup) {
if (isset($adminGroup['items'])) {
foreach ($adminGroup['items'] as $key => $id) {
$admin = $pool->getInstance($id);
if ($admin->showIn(Admin::CONTEXT_DASHBOARD)) {
$groups[$name]['items'][$key] = $admin;
} else {
unset($groups[$name]['items'][$key]);
}
}
}
if (empty($groups[$name]['items'])) {
unset($groups[$name]);
}
}
$menu->addChild($this->trans('dashboard', [], 'admin'), array('uri' => $this->getRouteGenerator()->generate('sonata_admin_dashboard'), 'attributes' => array('class' => 'home')));
foreach ($groups as $name => $group) {
$parent = $menu->addChild('header_' . $this->trans($name), array('label' => $this->trans($name), 'attributes' => array('class' => 'submenu')));
foreach ($group['items'] as $key => $admin) {
$item = $parent->addChild($this->trans($admin->getLabel()), array('uri' => $admin->generateUrl('list')));
if (get_class($this) == get_class($admin)) {
$parent[$this->trans($admin->getLabel())]->setCurrent(true);
//$item['header_'.$this->trans($name)]->setAttributes(array('class' => 'submenu open'));
}
}
}
}
示例3: configureTabMenu
/**
* {@inheritdoc}
*/
protected function configureTabMenu(MenuItemInterface $menu, $action, AdminInterface $childAdmin = null)
{
if (!$childAdmin && !in_array($action, ['list'])) {
return;
}
$menu->addChild('link_queue_list', ['label' => 'Queues', 'attributes' => ['class' => 'btn', 'icon' => 'fa fa-tasks'], 'route' => 'sonata_queue_list']);
$menu->addChild('link_queue_message_list', ['label' => 'Messages', 'attributes' => ['class' => 'btn', 'icon' => 'fa fa-send'], 'route' => 'sonata_queue_message_list']);
$menu->addChild('link_queue_log_list', ['label' => 'Exceptions', 'attributes' => ['class' => 'btn', 'icon' => 'fa fa-terminal'], 'route' => 'sonata_queue_log_list']);
}
示例4: addAdminMenuItems
/**
* @param \Knp\Menu\ItemInterface $admin
*/
private function addAdminMenuItems(ItemInterface $admin)
{
$context = $this->context;
$admin->addChild('menu.admin.config', array('route' => 'dedipanel_core_config', 'extras' => array('icon' => 'icon-cogs')))->setDisplay($context->isGranted(User::ROLE_SUPER_ADMIN));
$admin->addChild('menu.admin.user', array('route' => 'dedipanel_user_index', 'extras' => array('icon' => 'icon-uni2F')))->setDisplay($context->isGranted('ROLE_DP_ADMIN_USER_INDEX'));
$admin->addChild('menu.admin.group', array('route' => 'dedipanel_group_index', 'extras' => array('icon' => 'icon-users')))->setDisplay($context->isGranted('ROLE_DP_ADMIN_GROUP_INDEX'));
$admin->addChild('menu.admin.game', array('route' => 'dedipanel_game_index', 'extras' => array('icon' => 'icon-steam3')))->setDisplay($context->isGranted('ROLE_DP_ADMIN_GAME_INDEX'));
$admin->addChild('menu.admin.plugin', array('route' => 'dedipanel_plugin_index', 'extras' => array('icon' => 'icon-uni34')))->setDisplay($context->isGranted('ROLE_DP_ADMIN_PLUGIN_INDEX'));
}
示例5: configureSideMenu
/**
* {@inheritdoc}
*/
protected function configureSideMenu(MenuItemInterface $menu, $action, AdminInterface $childAdmin = null)
{
if (!$childAdmin && !in_array($action, array('edit'))) {
return;
}
$admin = $this->isChild() ? $this->getParent() : $this;
$id = $admin->getRequest()->get('id');
$menu->addChild($this->trans('sonata_comment_admin_edit', array(), 'SonataCommentBundle'), array('uri' => $admin->generateUrl('edit', array('id' => $id))));
$menu->addChild($this->trans('sonata_comment_admin_view_comments', array(), 'SonataCommentBundle'), array('uri' => $admin->generateUrl('sonata.comment.admin.comment.list', array('id' => $id))));
}
示例6: configureSideMenu
protected function configureSideMenu(MenuItemInterface $menu, $action, AdminInterface $childAdmin = null)
{
if (!$childAdmin && !in_array($action, array('edit', 'show'))) {
return;
}
$admin = $this->isChild() ? $this->getParent() : $this;
$id = $admin->getRequest()->get('id');
$menu->addChild('view', array('uri' => $admin->generateUrl('show', array('id' => $id))));
$menu->addChild('replies', array('uri' => $admin->generateUrl('sonata.admin.module.ticket.replies.list', array('id' => $id))));
}
示例7: configureSideMenu
/**
* (non-PHPdoc).
*
* @see \Sonata\AdminBundle\Admin\Admin::configureSideMenu()
*/
protected function configureSideMenu(MenuItemInterface $menu, $action, AdminInterface $childAdmin = null)
{
if (!$childAdmin && !in_array($action, ['edit'])) {
return;
}
$admin = $this->isChild() ? $this->getParent() : $this;
$id = $admin->getRequest()->get('id');
$menu->addChild('menu.menu', ['uri' => $admin->generateUrl('edit', ['id' => $id]), 'label' => $this->trans('zapoyok_menu.menu.menu')]);
$menu->addChild('menu.node', ['uri' => $admin->generateUrl('zapoyok_menu.admin.menunode.list', ['id' => $id]), 'label' => $this->trans('zapoyok_menu.menu.nodes')]);
}
示例8: configureSideMenu
/**
* {@inheritdoc}
*/
protected function configureSideMenu(MenuItemInterface $menu, $action, AdminInterface $childAdmin = null)
{
if (!$childAdmin && !in_array($action, array('edit'))) {
return;
}
$admin = $this->isChild() ? $this->getParent() : $this;
$id = $admin->getRequest()->get('id');
$menu->addChild('Tournament', $admin->generateMenuUrl('edit', array('id' => $id)));
$menu->addChild('Peloton', $admin->generateMenuUrl('admin.archery.peloton.list', array('id' => $id)));
}
示例9: buildMainMenu
public function buildMainMenu(Request $request, ItemInterface $root)
{
$root->addChild('Messages', ['route' => 'pjax_message_index'])->getParent()->addChild('New message', ['route' => 'pjax_message_new'])->getParent();
$latests = $root->addChild('latests', ['dropdown' => true]);
/** @var Message $message */
foreach ($this->messageRepository->findBy([], array(), 4) as $message) {
$latests->addChild($message->getId(), ['route' => 'pjax_message_show', 'routeParameters' => ['id' => $message->getId()], 'label' => 'message ' . $message->getId()]);
}
return $root;
}
示例10: configureSideMenu
/**
* @param \Knp\Menu\ItemInterface $menu
* @param $action
* @param null|\Sonata\AdminBundle\Admin\Admin $childAdmin
*
* @return void
*/
protected function configureSideMenu(MenuItemInterface $menu, $action, Admin $childAdmin = null)
{
if (!$childAdmin && !in_array($action, array('edit'))) {
return;
}
$admin = $this->isChild() ? $this->getParent() : $this;
$id = $admin->getRequest()->get('id');
$menu->addChild($this->trans('Content Show'), array('uri' => $admin->generateUrl('show', array('id' => $id))));
$menu->addChild($this->trans('Content Site Show'), array('uri' => $admin->getSubject()->getSitePath(), 'linkAttributes' => array('target' => '_blank')));
}
示例11: configureSideMenu
/**
* {@inheritdoc}
*/
protected function configureSideMenu(MenuItemInterface $menu, $action, AdminInterface $childAdmin = null)
{
if (!$childAdmin && !in_array($action, array('edit'))) {
return;
}
$admin = $this->isChild() ? $this->getParent() : $this;
$id = $admin->getRequest()->get('id');
$menu->addChild($this->trans('customer.sidemenu.link_customer_edit', array(), 'SonataCustomerBundle'), $admin->generateMenuUrl('edit', array('id' => $id)));
$menu->addChild($this->trans('customer.sidemenu.link_address_list', array(), 'SonataCustomerBundle'), $admin->generateMenuUrl('sonata.customer.admin.address.list', array('id' => $id)));
$menu->addChild($this->trans('customer.sidemenu.link_order_list', array(), 'SonataCustomerBundle'), $admin->generateMenuUrl('sonata.order.admin.order.list', array('id' => $id)));
}
示例12: configureTabMenu
/**
* @param MenuItemInterface $menu
* @param $action
* @param AdminInterface $childAdmin
* @return mixed|void
*/
protected function configureTabMenu(MenuItemInterface $menu, $action, AdminInterface $childAdmin = null)
{
if ($childAdmin !== null || !in_array($action, array('edit', 'show'))) {
return;
}
/** @var Movie $movie */
$movie = $this->getSubject();
$router = $this->getConfigurationPool()->getContainer()->get('router');
$menu->addChild($this->trans('form.label_sessions'), array('uri' => $router->generate('movie_movie_child_session_list', array('id' => $movie->getId()))));
$menu->addChild($this->trans('form.label_comments'), array('uri' => $router->generate('movie_movie_child_comment_list', array('id' => $movie->getId()))));
}
示例13: configureTabMenu
/**
* {@inheritdoc}
*/
protected function configureTabMenu(MenuItemInterface $menu, $action, AdminInterface $childAdmin = null)
{
if (!$childAdmin && !in_array($action, array('edit'))) {
return;
}
$admin = $this->isChild() ? $this->getParent() : $this;
$id = $admin->getRequest()->get('id');
$menu->addChild($this->trans('employee', array(), 'AppBundle'), $admin->generateMenuUrl('edit', array('id' => $id)));
$menu->addChild($this->trans('payroll_list', array(), 'AppBundle'), $admin->generateMenuUrl('app.payroll.list', array('id' => $id)));
$menu->addChild($this->trans('vacation_list', array(), 'AppBundle'), $admin->generateMenuUrl('app.vacation.list', array('id' => $id)));
$menu->addChild($this->trans('timesheet_list', array(), 'AppBundle'), $admin->generateMenuUrl('app.timesheet.list', array('id' => $id)));
}
示例14: configureSideMenu
/**
* {@inheritdoc}
*/
protected function configureSideMenu(MenuItemInterface $menu, $action, AdminInterface $childAdmin = null)
{
if (!$childAdmin && !in_array($action, array('edit'))) {
return;
}
$admin = $this->isChild() ? $this->getParent() : $this;
$id = $admin->getRequest()->get('id');
$menu->addChild($this->trans('sidemenu.link_edit_post', array(), 'SonataNewsBundle'), array('uri' => $admin->generateUrl('edit', array('id' => $id))));
if ($this->hasSubject() && $this->getSubject()->getId() !== null) {
$menu->addChild($this->trans('sidemenu.link_view_post'), array('uri' => $admin->getRouteGenerator()->generate('sonata_news_view', array('permalink' => $this->permalinkGenerator->generate($this->getSubject())))));
}
}
示例15: addSignedInuser
private function addSignedInuser(ItemInterface $root)
{
$user = $this->getSignedInUser();
if ($user) {
$user = $root->addChild($user->getEmail());
$user->addChild('web.menu.web', array('route' => 'homepage'));
$user->addChild('web.menu.admin', array('route' => 'admin_homepage'));
$user->addChild('web.menu.logout', array('route' => 'fos_user_security_logout'));
} else {
$root->addChild('web.menu.login', array('route' => 'fos_user_security_login'));
}
return $user;
}