@@ 75-95 (lines=21) @@ | ||
72 | $parents = []; |
|
73 | } |
|
74 | ||
75 | foreach ($galleries as $folder) { |
|
76 | $menuitem = new TopMenuItem($menu); |
|
77 | $menuitem->setRoute('VictoireMediaBundle_folder_show'); |
|
78 | $menuitem->setRouteparams(['folderId' => $folder->getId()]); |
|
79 | $menuitem->setInternalname($folder->getName()); |
|
80 | $menuitem->setParent($parent); |
|
81 | $menuitem->setRole($folder->getRel()); |
|
82 | if (isset($currentFolder) && (stripos($request->attributes->get('_route'), $menuitem->getRoute()) !== false || in_array($request->attributes->get('_route'), $allRoutes))) { |
|
83 | if ($currentFolder->getId() == $folder->getId()) { |
|
84 | $menuitem->setActive(true); |
|
85 | } else { |
|
86 | foreach ($parents as $_parent) { |
|
87 | if ($_parent->getId() == $folder->getId()) { |
|
88 | $menuitem->setActive(true); |
|
89 | break; |
|
90 | } |
|
91 | } |
|
92 | } |
|
93 | } |
|
94 | $children[] = $menuitem; |
|
95 | } |
|
96 | } elseif ('VictoireMediaBundle_folder_show' == $parent->getRoute()) { |
|
97 | $parentRouteParams = $parent->getRouteparams(); |
|
98 | /* @var \Victoire\Bundle\MediaBundle\Entity\Folder $parentFolder */ |
|
@@ 125-145 (lines=21) @@ | ||
122 | $parentGalleries = []; |
|
123 | } |
|
124 | ||
125 | foreach ($galleries as $folder) { |
|
126 | $menuitem = new MenuItem($menu); |
|
127 | $menuitem->setRoute('VictoireMediaBundle_folder_show'); |
|
128 | $menuitem->setRouteparams(['folderId' => $folder->getId()]); |
|
129 | $menuitem->setInternalname($folder->getName()); |
|
130 | $menuitem->setParent($parent); |
|
131 | $menuitem->setRole($folder->getRel()); |
|
132 | if (isset($currentFolder) && (stripos($request->attributes->get('_route'), $menuitem->getRoute()) === 0 || in_array($request->attributes->get('_route'), $allRoutes))) { |
|
133 | if ($currentFolder->getId() == $folder->getId()) { |
|
134 | $menuitem->setActive(true); |
|
135 | } else { |
|
136 | foreach ($parentGalleries as $parentFolder) { |
|
137 | if ($parentFolder->getId() == $folder->getId()) { |
|
138 | $menuitem->setActive(true); |
|
139 | break; |
|
140 | } |
|
141 | } |
|
142 | } |
|
143 | } |
|
144 | $children[] = $menuitem; |
|
145 | } |
|
146 | ||
147 | foreach ($allRoutes as $name => $route) { |
|
148 | $menuitem = new MenuItem($menu); |