Skip to content

Commit

Permalink
fix-9:
Browse files Browse the repository at this point in the history
82: interface administration
83: service pour instancier le menu
  • Loading branch information
HAFFAF Abdelhak committed Jun 16, 2014
1 parent a5392e7 commit 4e7602d
Showing 1 changed file with 23 additions and 19 deletions.
42 changes: 23 additions & 19 deletions Subscriber/MenuSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,27 +43,32 @@ public static function getSubscribedEvents()
*/
public function onGenerateMain(GenericEvent $event)
{
$menu = $event->getSubject();
$root = $menu->getRoot();
$structureMenu = $root->getChild('structure');
$builder = $event->getSubject();

if (!$structureMenu) {
$structureMenu = $root->addChild(
'structure',
array(
'label' => 'Structure',
'url' => '#',
'linkAttributes' => array(
'class' => 'dropdown-toggle',
'icon' => 'building',
if (!$builder->childExists('structure')) {
$builder
->addChild(
'structure',
array(
'label' => 'Structure',
'url' => '#',
'linkAttributes' => array(
'class' => 'dropdown-toggle',
'icon' => 'building',
)
),
array(
'children-attributes' => array(
'class' => 'submenu'
)
)
)
);
);
}

if ($this->security->isGranted('ROLE_ADMIN')) {
$structureMenu->addChild(
'context',
$builder
->addChildFor(
'structure',
'structure_context',
array(
'label' => 'Context',
'url' => '#',
Expand All @@ -72,6 +77,5 @@ public function onGenerateMain(GenericEvent $event)
)
)
);
}
}
}
}

0 comments on commit 4e7602d

Please sign in to comment.