You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I would like to create a menu sidebar navigation. I implemented the interface but I had this error:
xxBundle\Model\MenuItemModel contains 16 abstract methods and must therefore be declared abstract or implement the remaining methods (Avanzu\AdminThemeBundle\Model\MenuItemInterface::getIdentifier, Avanzu\AdminThemeBundle\Model\MenuItemInterface::getLabel, Avanzu\AdminThemeBundle\Model\MenuItemInterface::getRoute, ...)
My code Model:
<?php
namespace jpBundle\Model
use Avanzu\AdminThemeBundle\Model\MenuItemInterface as ThemeMenuItem;
class MenuItemModel implements ThemeMenuItem {
// ...
// implement interface methods
// ...
}
My code Event Listener:
<?php
namespace xxBundle\EventListener;
// ...
use xxBundle\Model\MenuItemModel;
use Avanzu\AdminThemeBundle\Event\SidebarMenuEvent;
use Symfony\Component\HttpFoundation\Request;
class MyMenuItemListListener {
// ...
public function onSetupMenu(SidebarMenuEvent $event) {
$request = $event->getRequest();
foreach ($this->getMenu($request) as $item) {
$event->addItem($item);
}
}
protected function getMenu(Request $request) {
// Build your menu here by constructing a MenuItemModel array
$menuItems = array(
$blog = new MenuItemModel('ItemId', 'ItemDisplayName', 'jp_admin_abonnement', array(/* options */), 'iconclasses fa fa-plane')
);
// Add some children
// A child with an icon
$blog->addChild(new MenuItemModel('ChildOneItemId', 'ChildOneDisplayName', 'child_1_route', array(), 'fa fa-rss-square'));
// A child with default circle icon
$blog->addChild(new MenuItemModel('ChildTwoItemId', 'ChildTwoDisplayName', 'child_2_route'));
return $this->activateByRoute($request->get('_route'), $menuItems);
}
protected function activateByRoute($route, $items) {
foreach($items as $item) {
if($item->hasChildren()) {
$this->activateByRoute($route, $item->getChildren());
}
else {
if($item->getRoute() == $route) {
$item->setIsActive(true);
}
}
}
return $items;
}
}
Can you help me please?
The text was updated successfully, but these errors were encountered:
I would like to create a menu sidebar navigation. I implemented the interface but I had this error:
xxBundle\Model\MenuItemModel contains 16 abstract methods and must therefore be declared abstract or implement the remaining methods (Avanzu\AdminThemeBundle\Model\MenuItemInterface::getIdentifier, Avanzu\AdminThemeBundle\Model\MenuItemInterface::getLabel, Avanzu\AdminThemeBundle\Model\MenuItemInterface::getRoute, ...)
My code Model:
My code Event Listener:
Can you help me please?
The text was updated successfully, but these errors were encountered: