-
Notifications
You must be signed in to change notification settings - Fork 0
/
MenuModuleBundle.php
60 lines (50 loc) · 1.52 KB
/
MenuModuleBundle.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<?php
namespace SmartCore\Module\Menu;
use SmartCore\Bundle\CMSBundle\Module\ModuleBundle;
use SmartCore\Module\Menu\DependencyInjection\Compiler\FormPass;
use SmartCore\Module\Menu\Entity\Menu;
use Symfony\Component\DependencyInjection\ContainerBuilder;
class MenuModuleBundle extends ModuleBundle
{
protected $adminMenuBeforeCode = '<i class="fa fa-indent"></i>';
/**
* Получить виджеты для рабочего стола.
*
* @return array
*/
public function getDashboard()
{
$em = $this->container->get('doctrine.orm.default_entity_manager');
$r = $this->container->get('router');
$menus = $em->getRepository(Menu::class)->findAll();
$data = [
'title' => 'Меню',
'items' => [],
];
foreach ($menus as $menu) {
$data['items']['edit_menu_'.$menu->getId()] = [
'title' => 'Редактировать меню: <b>'.$menu->getName().'</b>',
'descr' => '',
'url' => $r->generate('smart_module.menu.admin_menu', ['menu_id' => $menu->getId()]),
];
}
return $data;
}
/**
* @param ContainerBuilder $container
*/
public function build(ContainerBuilder $container)
{
parent::build($container);
$container->addCompilerPass(new FormPass());
}
/**
* @return array
*/
public function getRequiredParams()
{
return [
'menu_id',
];
}
}