本文整理汇总了PHP中Knp\Menu\FactoryInterface::createFromArray方法的典型用法代码示例。如果您正苦于以下问题:PHP FactoryInterface::createFromArray方法的具体用法?PHP FactoryInterface::createFromArray怎么用?PHP FactoryInterface::createFromArray使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Knp\Menu\FactoryInterface
的用法示例。
在下文中一共展示了FactoryInterface::createFromArray方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get
/**
* Build menu.
*
* @param string $alias
* @param array $options
* @return ItemInterface
*/
public function get($alias, array $options = [])
{
$this->assertAlias($alias);
if (!array_key_exists($alias, $this->menus)) {
if ($this->cache && $this->cache->contains($alias)) {
$menuData = $this->cache->fetch($alias);
$this->menus[$alias] = $this->factory->createFromArray($menuData);
} else {
$menu = $this->factory->createItem($alias);
/** @var BuilderInterface $builder */
// try to find builder for the specified menu alias
if (array_key_exists($alias, $this->builders)) {
foreach ($this->builders[$alias] as $builder) {
$builder->build($menu, $options, $alias);
}
}
// In any case we must run common builder
if (array_key_exists(self::COMMON_BUILDER_ALIAS, $this->builders)) {
foreach ($this->builders[self::COMMON_BUILDER_ALIAS] as $builder) {
$builder->build($menu, $options, $alias);
}
}
$this->menus[$alias] = $menu;
$this->eventDispatcher->dispatch(ConfigureMenuEvent::getEventName($alias), new ConfigureMenuEvent($this->factory, $menu));
$this->sort($menu);
if ($this->cache) {
$this->cache->save($alias, $menu->toArray());
}
}
}
return $this->menus[$alias];
}