本文整理汇总了PHP中Knp\Menu\ItemInterface类的典型用法代码示例。如果您正苦于以下问题:PHP ItemInterface类的具体用法?PHP ItemInterface怎么用?PHP ItemInterface使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ItemInterface类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: setActive
/**
* Set active class to current item and all its parents (so it is automatically opened)
*
* @param ItemInterface $item
*/
protected function setActive(ItemInterface $item = null)
{
if ($item) {
$this->setActive($item->getParent());
$item->setAttribute('class', $item->getAttribute('class', '') . ' active');
}
}
开发者ID:hyperlator,项目名称:GeneratorBundle,代码行数:12,代码来源:AdmingeneratorMenuBuilder.php
示例2: createDropdownMenuItem
/**
* Create the dropdown menu.
*
* @param ItemInterface $rootItem
* @param string $title
* @param array $attributes
* @param string $caret
*
* @return \Knp\Menu\ItemInterface
*/
public function createDropdownMenuItem(ItemInterface $rootItem, $title, $attributes = [], $caret = true)
{
// Add child to dropdown, still normal KnpMenu usage
$options = array_merge(['dropdown' => true, 'childrenAttributes' => ['class' => 'vic-dropdown-menu'], 'attributes' => ['class' => 'vic-dropdown', 'data-toggle' => 'vic-dropdown'], 'linkAttributes' => ['class' => 'vic-dropdown-toggle', 'data-toggle' => 'vic-dropdown'], 'uri' => '#'], $attributes);
$menu = $rootItem->addChild($title, $options)->setExtra('caret', $caret);
return $menu;
}
开发者ID:global01,项目名称:victoire,代码行数:17,代码来源:MenuBuilder.php
示例3: 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'));
}
}
}
}
开发者ID:bamper,项目名称:symfony-ecommerce,代码行数:36,代码来源:BaseAdmin.php
示例4: configureSideMenu
protected function configureSideMenu(MenuItemInterface $menu, $action, AdminInterface $childAdmin = null)
{
if (!in_array($action, array('edit', 'create'))) {
return;
}
$id = $this->getRequest()->get('id');
$vars = $menu->addChild('Variables', array('route' => 'tsk_contract_default_variables', 'attr' => array('onclick' => 'alert("foo"); return false;')));
$contract = $vars->addChild('Contract');
$contract->addChild('getAmount');
$contract->addChild('getProgram');
$contract->addChild('getExpireDate');
$contract->addChild('getRolloverTokens');
$contract->addChild('getContractNumTokens');
$contract->addChild('getProgramLegalDescription');
$student = $vars->addChild('Student');
$student->addChild('getContact.getFirstName');
$student->addChild('getContact.getLastName');
$student->addChild('getContact.getAddress1');
$student->addChild('getContact.getAddress2');
$student->addChild('getContact.getCity');
$student->addChild('getContact.getState');
$student->addChild('getContact.getPostalcode');
$student->addChild('getContact.getPhone');
$school = $vars->addChild('School');
$school->addChild('getContact.getState');
$org = $vars->addChild('Org');
$org->addChild('getName');
}
开发者ID:sgh1986915,项目名称:symfony-tsk,代码行数:28,代码来源:ContractTemplateAdmin.php
示例5: matchItem
/**
* @param ItemInterface $item
*
* @return bool|null
*/
public function matchItem(ItemInterface $item)
{
if (null === $this->getRequest()) {
return null;
}
$route = $this->getRequest()->attributes->get('_route');
$routeParameters = $this->getRequest()->attributes->get('_route_params');
if (null === $route) {
return null;
}
$routes = (array) $item->getExtra('routes', array());
foreach ($routes as $testedRoute) {
if ($route == $testedRoute['route']) {
if (is_array($routeParameters) && 0 < count($routeParameters)) {
if (isset($testedRoute['parameters']) && is_array($testedRoute['parameters'])) {
$matching = true;
foreach ($routeParameters as $index => $value) {
if ('_' != substr($index, 0, 1)) {
if (!isset($testedRoute['parameters'][$index]) || ($testedRoute['parameters'][$index] != $value && 0 < $testedRoute['parameters'][$index] || !is_numeric($value))) {
$matching = false;
}
}
}
if ($matching) {
return true;
}
}
} else {
return true;
}
}
}
return null;
}
开发者ID:pmdevelopment,项目名称:tool-bundle,代码行数:39,代码来源:RouteVoter.php
示例6: matchItem
/**
* {@inheritDoc}
*/
public function matchItem(ItemInterface $item)
{
if ($item->getUri() === $this->getRequestUri()) {
return true;
}
return null;
}
开发者ID:wemakecustom,项目名称:menu-part-bundle,代码行数:10,代码来源:RequestVoter.php
示例7: addChildNodes
private function addChildNodes(ItemInterface $menu, MenuItem $menuItem)
{
$child = $menu->addChild($menuItem->getName(), $this->createMenuOptions($menuItem));
foreach ($menuItem->getChildren() as $childItem) {
$this->addChildNodes($child, $childItem);
}
}
开发者ID:gravity-cms,项目名称:menu-bundle,代码行数:7,代码来源:MenuBuilder.php
示例8: addConfigurationMenu
/**
* @param ItemInterface $menu
*/
private function addConfigurationMenu(ItemInterface $menu)
{
$child = $menu->addChild('configuration')->setLabel('sylius.menu.admin.main.configuration.header');
if (!$child->hasChildren()) {
$menu->removeChild('configuration');
}
}
开发者ID:sidibea,项目名称:Sylius,代码行数:10,代码来源:MainMenuBuilder.php
示例9: configureTabMenu
/**
* @throws InvalidConfigurationException
*/
public function configureTabMenu(AdminInterface $admin, MenuItemInterface $menu, $action, AdminInterface $childAdmin = null)
{
if (!($subject = $admin->getSubject())) {
return;
}
if (!$subject instanceof RouteReferrersReadInterface && !$subject instanceof Route) {
throw new InvalidConfigurationException(sprintf('%s can only be used on subjects which implement Symfony\\Cmf\\Component\\Routing\\RouteReferrersReadInterface or Symfony\\Component\\Routing\\Route.', __CLASS__));
}
if ($subject instanceof PrefixInterface && !is_string($subject->getId())) {
// we have an unpersisted dynamic route
return;
}
$defaults = array();
if ($subject instanceof TranslatableInterface) {
if ($locale = $subject->getLocale()) {
$defaults['_locale'] = $locale;
}
}
try {
$uri = $this->router->generate($subject, $defaults);
} catch (RoutingExceptionInterface $e) {
// we have no valid route
return;
}
$menu->addChild($this->translator->trans('admin.menu_frontend_link_caption', array(), 'CmfRoutingBundle'), array('uri' => $uri, 'attributes' => array('class' => 'sonata-admin-menu-item', 'role' => 'menuitem'), 'linkAttributes' => array('class' => 'sonata-admin-frontend-link', 'role' => 'button', 'target' => '_blank', 'title' => $this->translator->trans('admin.menu_frontend_link_title', array(), 'CmfRoutingBundle'))));
}
开发者ID:symfony-cmf,项目名称:routing-bundle,代码行数:29,代码来源:FrontendLinkExtension.php
示例10: matchItem
/**
* {@inheritdoc}
*/
public function matchItem(ItemInterface $item)
{
if (($page = $this->getPage()) && $page->getId() !== null) {
return $item->getExtra('_page_id', null) === $page->getId();
}
return;
}
开发者ID:symedit,项目名称:symedit,代码行数:10,代码来源:PageVoter.php
示例11: matchItem
/**
* Checks whether an item is current.
*
* If the voter is not able to determine a result,
* it should return null to let other voters do the job.
*
* @param \Knp\Menu\ItemInterface $item The item
*
* @return boolean|null
*/
public function matchItem(ItemInterface $item)
{
if ($item->getUri() === $this->container->get('request')->getRequestUri()) {
return true;
}
return false;
}
开发者ID:rmzamora,项目名称:bootstrap-bundle,代码行数:17,代码来源:RequestVoter.php
示例12: 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'));
}
开发者ID:ragebat,项目名称:chamilo-lms,代码行数:12,代码来源:MainMenuBuilder.php
示例13: matchItem
public function matchItem(ItemInterface $item)
{
if (null === $this->request) {
return null;
}
$route = $this->request->attributes->get('_route');
if (null === $route) {
return null;
}
$routes = (array) $item->getExtra('routes', array());
$parameters = (array) $item->getExtra('routesParameters', array());
foreach ($routes as $testedRoute) {
if (is_string($testedRoute)) {
$testedRoute = array('route' => $testedRoute);
// BC layer for the configuration of route params
if (isset($parameters[$testedRoute['route']])) {
$testedRoute['parameters'] = $parameters[$testedRoute['route']];
trigger_error('Using the routeParameters extra is deprecated. The parameters should be passed along the route.', E_USER_DEPRECATED);
}
}
if (!is_array($testedRoute)) {
throw new \InvalidArgumentException('Routes extra items must be strings or arrays.');
}
if ($this->isMatchingRoute($testedRoute)) {
return true;
}
}
return null;
}
开发者ID:andrewkrug,项目名称:repucaution,代码行数:29,代码来源:RouteVoter.php
示例14: addUserMenu
protected function addUserMenu(ItemInterface $menu)
{
$menu->addChild('User', array('uri' => '#', 'label' => sprintf('<i class="fa fa-shield"></i> <span>%s</span><i class="fa fa-angle-double-left pull-right"></i></a>', $this->translator->trans('menu.user.title', array(), $this->translationDomain)), 'extras' => array('safe_label' => true), 'attributes' => array('class' => 'treeview')));
$menu['User']->setChildrenAttribute('class', 'treeview-menu');
$menu['User']->addChild('Add', array('label' => $this->translator->trans('menu.user.add', array(), $this->translationDomain), 'route' => 'symfonian_indonesia_admin_security_user_new', 'attributes' => array('class' => 'treeview')));
$menu['User']->addChild('List', array('label' => $this->translator->trans('menu.user.list', array(), $this->translationDomain), 'route' => 'symfonian_indonesia_admin_security_user_list', 'attributes' => array('class' => 'treeview')));
}
开发者ID:deryfebriantara,项目名称:AdminBundle,代码行数:7,代码来源:Builder.php
示例15: build
/**
* {@inheritDoc}
*/
public function build(ItemInterface $menu, array $options = array(), $alias = null)
{
if (!$this->componentRegistry->hasAllowedProcessor()) {
return;
}
$menu->addChild('orob2b.product.frontend.quick_add.title', ['route' => 'orob2b_product_frontend_quick_add', 'extras' => ['position' => 500, 'description' => 'orob2b.product.frontend.quick_add.description']]);
}
开发者ID:adam-paterson,项目名称:orocommerce,代码行数:10,代码来源:QuickAddMenuBuilder.php
示例16: render
public function render(ItemInterface $item, array $options = array())
{
$options = array_merge(array('currentClass' => 'active'), $options);
if ($item->isRoot()) {
$item->setChildrenAttribute('class', trim('nav navbar-nav ' . $item->getChildrenAttribute('class')));
}
return parent::render($item, $options);
}
开发者ID:symforce,项目名称:symforce-admin,代码行数:8,代码来源:BootstrapRenderer.php
示例17: matchItem
/**
* Checks whether an item is current.
*
* If the voter is not able to determine a result,
* it should return null to let other voters do the job.
*
* @param \Knp\Menu\ItemInterface $item The item
*
* @return boolean|null
*/
public function matchItem(ItemInterface $item)
{
$uri = str_replace(array('/', '.'), array('\\/', '\\.'), $item->getUri());
if (preg_match('/' . $uri . '/', $this->container->get('request')->getRequestUri())) {
return true;
}
return false;
}
开发者ID:rmzamora,项目名称:bootstrap-bundle,代码行数:18,代码来源:RequestRegexVoter.php
示例18: flattenMenuItems
/**
* Get a flattened array containing references to all of the items
*
* @param ItemInterface $item The menu item
* @param bool $isTop Is the initial menu item starting at the top-level?
* @return array
*/
public static function flattenMenuItems(ItemInterface $item, $isTop = true)
{
$arr = $isTop ? [] : [$item];
foreach ($item->getChildren() as $child) {
$arr = array_merge($arr, self::flattenMenuItems($child, false));
}
return $arr;
}
开发者ID:igorvbelousov,项目名称:toc,代码行数:15,代码来源:TOCTestUtils.php
示例19: configureTabMenu
protected function configureTabMenu(MenuItemInterface $menu, $action, AdminInterface $childAdmin = null)
{
$admin = $this->isChild() ? $this->getParent() : $this;
$id = $admin->getRequest()->get('id');
!$id && $menu->addChild("Refresh currency values", array('uri' => $admin->generateUrl('refresh')));
parent::configureTabMenu($menu, $action, $childAdmin);
// TODO: Change the autogenerated stub
}
开发者ID:bordeux,项目名称:language-bundle,代码行数:8,代码来源:CurrencyAdmin.php
示例20: buildProfileMenu
/**
* @param ItemInterface $menu The item to fill with $routes
* @param array $itemOptions
*/
public function buildProfileMenu(ItemInterface $menu, array $itemOptions = array())
{
foreach ($this->routes as $route) {
$menu->addChild($this->translator->trans($route['label'], array(), $route['domain']), array_merge($itemOptions, array('route' => $route['route'], 'routeParameters' => $route['route_parameters'])));
}
$event = new ProfileMenuEvent($menu);
$this->eventDispatcher->dispatch('sonata.user.profile.configure_menu', $event);
}
开发者ID:morille,项目名称:SonataUserBundle,代码行数:12,代码来源:ProfileMenuBuilder.php
注:本文中的Knp\Menu\ItemInterface类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论