| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  |  * MenuBuilder KnpMenu. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  |  * PHP Version 5 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  |  * @author     Quétier Laurent <[email protected]> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  |  * @copyright  2014 Dev-Int GLSR | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  |  * @license    http://opensource.org/licenses/gpl-license.php GNU Public License | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  |  * @version    since 1.0.0 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  |  * @link       https://github.com/Dev-Int/glsr | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  | namespace AppBundle\Menu; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  | use Knp\Menu\FactoryInterface; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  | use Symfony\Component\DependencyInjection\ContainerAwareInterface; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  | use Symfony\Component\DependencyInjection\ContainerAwareTrait; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  |  * class MenuBuilder. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  |  * @category   Menu | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  | class MenuBuilder implements ContainerAwareInterface | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  | { | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 28 |  |  |     use ContainerAwareTrait; | 
            
                                                                        
                            
            
                                    
            
            
                | 29 |  |  |     public function buildMainMenu(FactoryInterface $factory, array $options) | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                        
                            
            
                                    
            
            
                | 30 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 31 |  |  |         $menu = $factory->createItem('root'); | 
            
                                                                        
                            
            
                                    
            
            
                | 32 |  |  |         $menu->setChildrenAttribute('class', 'nav navbar-nav'); | 
            
                                                                        
                            
            
                                    
            
            
                | 33 |  |  |          | 
            
                                                                        
                            
            
                                    
            
            
                | 34 |  |  |         $menu->addChild('manage', array('label' => 'menu.management')) | 
            
                                                                        
                            
            
                                    
            
            
                | 35 |  |  |             ->setExtra('translation_domain', 'messages') | 
            
                                                                        
                            
            
                                    
            
            
                | 36 |  |  |             ->setAttribute('dropdown', true) | 
            
                                                                        
                            
            
                                    
            
            
                | 37 |  |  |             ->setAttribute('icon', 'fa fa-dashboard'); | 
            
                                                                        
                            
            
                                    
            
            
                | 38 |  |  |          | 
            
                                                                        
                            
            
                                    
            
            
                | 39 |  |  |         $menu['manage']->addChild('suppliers', array( | 
            
                                                                        
                            
            
                                    
            
            
                | 40 |  |  |             'label' => 'title', | 
            
                                                                        
                            
            
                                    
            
            
                | 41 |  |  |             'route' => 'supplier' | 
            
                                                                        
                            
            
                                    
            
            
                | 42 |  |  |         )) | 
            
                                                                        
                            
            
                                    
            
            
                | 43 |  |  |             ->setExtra('translation_domain', 'gs_suppliers') | 
            
                                                                        
                            
            
                                    
            
            
                | 44 |  |  |             ->setAttribute('icon', 'fa fa-barcode'); | 
            
                                                                        
                            
            
                                    
            
            
                | 45 |  |  |   | 
            
                                                                        
                            
            
                                    
            
            
                | 46 |  |  |         $menu['manage']->addChild('article', array( | 
            
                                                                        
                            
            
                                    
            
            
                | 47 |  |  |             'label' => 'title', | 
            
                                                                        
                            
            
                                    
            
            
                | 48 |  |  |             'route' => 'article' | 
            
                                                                        
                            
            
                                    
            
            
                | 49 |  |  |         )) | 
            
                                                                        
                            
            
                                    
            
            
                | 50 |  |  |             ->setExtra('translation_domain', 'gs_articles') | 
            
                                                                        
                            
            
                                    
            
            
                | 51 |  |  |             ->setAttribute('icon', 'fa fa-shopping-basket'); | 
            
                                                                        
                            
            
                                    
            
            
                | 52 |  |  |   | 
            
                                                                        
                            
            
                                    
            
            
                | 53 |  |  |         $menu['manage']->addChild('inventory', array( | 
            
                                                                        
                            
            
                                    
            
            
                | 54 |  |  |             'label' => 'title_short', | 
            
                                                                        
                            
            
                                    
            
            
                | 55 |  |  |             'route' => 'inventory' | 
            
                                                                        
                            
            
                                    
            
            
                | 56 |  |  |         )) | 
            
                                                                        
                            
            
                                    
            
            
                | 57 |  |  |             ->setExtra('translation_domain', 'gs_inventories') | 
            
                                                                        
                            
            
                                    
            
            
                | 58 |  |  |             ->setAttribute('icon', 'fa fa-tasks'); | 
            
                                                                        
                            
            
                                    
            
            
                | 59 |  |  |   | 
            
                                                                        
                            
            
                                    
            
            
                | 60 |  |  |         $menu['manage']->addChild('orders', array( | 
            
                                                                        
                            
            
                                    
            
            
                | 61 |  |  |             'label' => 'title_short', | 
            
                                                                        
                            
            
                                    
            
            
                | 62 |  |  |             'route' => 'orders' | 
            
                                                                        
                            
            
                                    
            
            
                | 63 |  |  |         )) | 
            
                                                                        
                            
            
                                    
            
            
                | 64 |  |  |             ->setExtra('translation_domain', 'gs_orders') | 
            
                                                                        
                            
            
                                    
            
            
                | 65 |  |  |             ->setAttribute('icon', 'fa fa-shopping-cart'); | 
            
                                                                        
                            
            
                                    
            
            
                | 66 |  |  |   | 
            
                                                                        
                            
            
                                    
            
            
                | 67 |  |  |         $menu['manage']->addChild('deliveries', array( | 
            
                                                                        
                            
            
                                    
            
            
                | 68 |  |  |             'label' => 'title_short', | 
            
                                                                        
                            
            
                                    
            
            
                | 69 |  |  |             'route' => 'deliveries' | 
            
                                                                        
                            
            
                                    
            
            
                | 70 |  |  |         )) | 
            
                                                                        
                            
            
                                    
            
            
                | 71 |  |  |             ->setExtra('translation_domain', 'gs_deliveries') | 
            
                                                                        
                            
            
                                    
            
            
                | 72 |  |  |             ->setAttribute('icon', 'fa fa-truck'); | 
            
                                                                        
                            
            
                                    
            
            
                | 73 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 74 |  |  |         return $menu; | 
            
                                                                        
                            
            
                                    
            
            
                | 75 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 |  |  |   | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 |  |  |     public function buildUserMenu(FactoryInterface $factory, array $options) | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 |  |  |         $menu = $factory->createItem('root'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 |  |  |         $menu->setChildrenAttribute('class', 'nav navbar-nav navbar-right'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 81 |  |  |   | 
            
                                                                                                            
                            
            
                                    
            
            
                | 82 |  |  |         $context = $this->container->get('security.authorization_checker'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 83 |  |  |         if ($context->isGranted('IS_AUTHENTICATED_REMEMBERED')) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 84 |  |  |             /* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 85 |  |  |              *  Menu Administration | 
            
                                                                                                            
                            
            
                                    
            
            
                | 86 |  |  |              */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 87 |  |  |             $menu->addChild('entities', array('label' => 'menu.configuration')) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 88 |  |  |                 ->setExtra('translation_domain', 'messages') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 89 |  |  |                 ->setAttribute('dropdown', true) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 90 |  |  |                 ->setAttribute('class', 'multi-level') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 91 |  |  |                 ->setAttribute('icon', 'glyphicon glyphicon-cog'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 92 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 93 |  |  |             $menu['entities'] | 
            
                                                                                                            
                            
            
                                    
            
            
                | 94 |  |  |                 ->addChild('company', array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 95 |  |  |                     'route' => 'company', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 96 |  |  |                     'label' => 'gestock.settings.company.title' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 97 |  |  |                 )) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 98 |  |  |                 ->setExtra('translation_domain', 'messages') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 99 |  |  |                 ->setAttribute('icon', 'glyphicon glyphicon-tower'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 100 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 101 |  |  |             $menu['entities'] | 
            
                                                                                                            
                            
            
                                    
            
            
                | 102 |  |  |                 ->addChild('applcation', array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 103 |  |  |                     'route' => 'application', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 104 |  |  |                     'label' => 'gestock.settings.settings.title' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 105 |  |  |                 )) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 106 |  |  |                 ->setExtra('translation_domain', 'messages') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 107 |  |  |                 ->setAttribute('icon', 'glyphicon glyphicon-wrench'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 108 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 109 |  |  |             $divers = $menu['entities'] | 
            
                                                                                                            
                            
            
                                    
            
            
                | 110 |  |  |                 ->addChild('divers', array('label' => 'gestock.settings.diverse.title')) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 111 |  |  |                 ->setExtra('translation_domain', 'messages') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 112 |  |  |                 ->setAttribute('dropdown', true) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 113 |  |  |                 ->setAttribute('class', 'dropdown-submenu') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 114 |  |  |                 ->setAttribute('icon', 'glyphicon glyphicon-info-sign'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 115 |  |  |              | 
            
                                                                                                            
                            
            
                                    
            
            
                | 116 |  |  |             $divers | 
            
                                                                                                            
                            
            
                                    
            
            
                | 117 |  |  |                 ->addChild('familylog', array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 118 |  |  |                     'route' => 'familylog', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 119 |  |  |                     'label' => 'gestock.settings.diverse.familylog' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 120 |  |  |                 )) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 121 |  |  |                 ->setAttribute('icon', 'glyphicon glyphicon-tag'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 122 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 123 |  |  |             $divers | 
            
                                                                                                            
                            
            
                                    
            
            
                | 124 |  |  |                 ->addChild('zonestorage', array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 125 |  |  |                     'route' => 'zonestorage', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 126 |  |  |                     'label' => 'gestock.settings.diverse.zonestorage' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 127 |  |  |                 )) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 128 |  |  |                 ->setAttribute('icon', 'glyphicon glyphicon-map-marker'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 129 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 130 |  |  |             $divers | 
            
                                                                                                            
                            
            
                                    
            
            
                | 131 |  |  |                 ->addChild('unitstorage', array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 132 |  |  |                     'route' => 'unitstorage', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 133 |  |  |                     'label' => 'gestock.settings.diverse.unitstorage' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 134 |  |  |                 )) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 135 |  |  |                 ->setAttribute('icon', 'fa fa-cubes'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 136 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 137 |  |  |             $divers | 
            
                                                                                                            
                            
            
                                    
            
            
                | 138 |  |  |                 ->addChild('tva', array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 139 |  |  |                     'route' => 'tva', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 140 |  |  |                     'label' => 'gestock.settings.diverse.vat' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 141 |  |  |                 )) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 142 |  |  |                 ->setAttribute('icon', 'glyphicon glyphicon-piggy-bank'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 143 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 144 |  |  |             $menu['entities'] | 
            
                                                                                                            
                            
            
                                    
            
            
                | 145 |  |  |                 ->addChild('divider') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 146 |  |  |                 ->setAttribute('class', 'divider'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 147 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 148 |  |  |             $menu['entities'] | 
            
                                                                                                            
                            
            
                                    
            
            
                | 149 |  |  |                 ->addChild('users', array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 150 |  |  |                     'route' => 'user', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 151 |  |  |                     'label' => 'menu.users')) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 152 |  |  |                 ->setAttribute('icon', 'glyphicon glyphicon-user'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 153 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 154 |  |  |             $menu['entities'] | 
            
                                                                                                            
                            
            
                                    
            
            
                | 155 |  |  |                 ->addChild('groups', array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 156 |  |  |                     'route' => 'group', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 157 |  |  |                     'label' => 'menu.groups')) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 158 |  |  |                 ->setAttribute('icon', 'fa fa-users'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 159 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 160 |  |  |         /* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 161 |  |  |          *  Menu Profile | 
            
                                                                                                            
                            
            
                                    
            
            
                | 162 |  |  |          */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 163 |  |  |         $context2 = $this->container->get('security.token_storage'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 164 |  |  |         if ($context->isGranted('IS_AUTHENTICATED_REMEMBERED')) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 165 |  |  |             $menu->addChild('profile', array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 166 |  |  |                         'label' => $context2->getToken()->getUser()->getUsername())) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 167 |  |  |                 ->setAttribute('dropdown', true) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 168 |  |  |                 ->setAttribute('icon', 'fa fa-user'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 169 |  |  |              | 
            
                                                                                                            
                            
            
                                    
            
            
                | 170 |  |  |             $menu['profile']->addChild('layout.logout', array('route' => 'fos_user_security_logout')) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 171 |  |  |                 ->setExtra('translation_domain', 'FOSUserBundle') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 172 |  |  |                 ->setAttribute('icon', 'fa fa-unlink'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 173 |  |  |         } else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 174 |  |  |             $menu->addChild('profile', array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 175 |  |  |                         'label' => 'menu.administration' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 176 |  |  |                 )) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 177 |  |  |                 ->setExtra('translation_domain', 'messages') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 178 |  |  |                 ->setAttribute('dropdown', true) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 179 |  |  |                 ->setAttribute('icon', 'fa fa-user'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 180 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 181 |  |  |         $menu['profile']->addChild('menu.other_login', array('route' => 'fos_user_security_login')) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 182 |  |  |             ->setAttribute('icon', 'fa fa-link'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 183 |  |  |   | 
            
                                                                                                            
                            
            
                                    
            
            
                | 184 |  |  |         return $menu; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 185 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 186 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 187 |  |  |  | 
            
                        
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.