本文整理汇总了PHP中Knp\Menu\ItemInterface::setUri方法的典型用法代码示例。如果您正苦于以下问题:PHP ItemInterface::setUri方法的具体用法?PHP ItemInterface::setUri怎么用?PHP ItemInterface::setUri使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Knp\Menu\ItemInterface
的用法示例。
在下文中一共展示了ItemInterface::setUri方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: decorate
public function decorate(KnpMenuItem $knpMenuItem, AdminMenuItem $adminMenuItem)
{
if ($adminMenuItem instanceof RoutableItem && $adminMenuItem->getRoute()) {
$knpMenuItem->setUri($this->router->generate($adminMenuItem->getRoute(), $adminMenuItem->getRouteParameters()));
$routes = $knpMenuItem->getExtra('routes', array());
$routes[] = array('route' => $adminMenuItem->getRoute(), 'parameters' => $adminMenuItem->getRouteParameters());
$knpMenuItem->setExtra('routes', $routes);
}
}
示例2: decorate
public function decorate(KnpMenuItem $knpMenuItem, AdminMenuItem $adminMenuItem)
{
$knpMenuItem->setUri('#');
if ($adminMenuItem->hasOption('attr')) {
$knpMenuItem->setAttributes($adminMenuItem->getOption('attr'));
}
if ($adminMenuItem->hasChildren()) {
$knpMenuItem->setAttribute('dropdown', true);
}
}
示例3: buildItem
/**
* Configures the newly created item with the passed options
*
* @param ItemInterface $item
* @param array $options
*/
public function buildItem(ItemInterface $item, array $options)
{
if (!empty($options['path'])) {
$item->setUri(site_url($options['path']));
}
if (!empty($options['icon_class'])) {
$item->setLabel('<i class="' . $options['icon_class'] . '"></i> ' . $item->getLabel());
$item->setExtra('safe_label', true);
}
$this->buildExtras($item, $options);
}
示例4: buildItem
/**
* Build an item based on options
* @param ItemInterface $item
* @param array $options
*/
public function buildItem(ItemInterface $item, array $options)
{
if ($options['navbar']) {
$item->setChildrenAttribute('class', 'nav navbar-nav');
}
if ($options['pills']) {
$item->setChildrenAttribute('class', 'nav nav-pills');
}
if ($options['stacked']) {
$class = $item->getChildrenAttribute('class');
$item->setChildrenAttribute('class', $class . ' nav-stacked');
}
if ($options['dropdown-header']) {
$item->setAttribute('role', 'presentation')->setAttribute('class', 'dropdown-header')->setUri(null);
}
if ($options['list-group']) {
//echo "BLUBBB";
$item->setChildrenAttribute('class', 'list-group');
$item->setAttribute('class', 'list-group-item');
}
//var_dump($item->getLabel(), $item->getChildrenAttributes());
if ($options['list-group-item']) {
$item->setAttribute('class', 'list-group-item');
}
if ($options['dropdown']) {
$item->setUri('#')->setAttribute('class', 'dropdown')->setLinkAttribute('class', 'dropdown-toggle')->setLinkAttribute('data-toggle', 'dropdown')->setChildrenAttribute('class', 'dropdown-menu')->setChildrenAttribute('role', 'menu');
if ($options['caret']) {
$item->setExtra('caret', 'true');
}
}
if ($options['divider']) {
$item->setLabel('')->setUri(null)->setAttribute('role', 'presentation')->setAttribute('class', 'divider');
}
if ($options['pull-right']) {
$class = $item->getChildrenAttribute('class', '');
$item->setChildrenAttribute('class', $class . ' pull-right');
}
if ($options['icon']) {
$item->setExtra('icon', $options['icon']);
}
}
示例5: createLink
protected function createLink(ItemInterface $itemInterface, Menu $menu)
{
$uri = $this->routerInterface->generate($menu->getPage());
$itemInterface->setUri($uri);
}
示例6: setContext
/**
* Set uri, display context to menu item
*
* @param MenuItemInterface $item
* @param array $routeParameters
* @param array $options
*
* @return MenuFactoryInterface
*/
protected function setContext(MenuItemInterface $item, array $routeParameters = array(), array $options = array())
{
$display = true;
$rootItem = !$item->getName();
$token = $this->security->getToken();
if ($token) {
if ($options['roles'] && !$this->security->isGranted($options['roles'])) {
$display = false;
}
if ($display) {
foreach ((array) $item->getExtra('oids') as $oidItem) {
if (!$this->security->isGranted($oidItem['permissions'], $oidItem['oid'])) {
$display = false;
break;
}
}
}
}
if ($options['route'] && !$rootItem) {
$acceptedRouteParameters = array_intersect_key($routeParameters, $options['routeAcceptedParameters']);
if ($options['routeRequiredParameters'] === $options['routeAcceptedParameters']) {
$uri = $this->router->generate($options['route'], $acceptedRouteParameters, $options['routeAbsolute']);
$item->setUri($uri);
} else {
$display = false;
}
}
if (!$display) {
if ($options['showNonAuthorized'] && !$token) {
$display = true;
}
if ($options['showAsText']) {
$display = true;
$item->setUri(null);
}
}
if (!$display) {
$item->setDisplay(false);
}
return $this;
}
示例7: buildItem
/**
* Configures the newly created item with the passed options
*
* @param ItemInterface $item
* @param array $options
*/
public function buildItem(ItemInterface $item, array $options)
{
$item->setUri($options['uri'])->setLabel($options['label'])->setAttributes($options['attributes'])->setLinkAttributes($options['linkAttributes'])->setChildrenAttributes($options['childrenAttributes'])->setLabelAttributes($options['labelAttributes'])->setCurrent($options['current'])->setDisplay($options['display'])->setDisplayChildren($options['displayChildren']);
$this->buildExtras($item, $options);
}