Example #1
0
 /**
  * Найти список выбранных элементов по текущему URL
  * @param string $location
  * @return array
  */
 protected function getSelectedIds($location)
 {
     if (isset($this->selectedCache[$location])) {
         return $this->selectedCache[$location];
     }
     $structureItem = $this->structureManager->getCurrentItem();
     if (is_null($structureItem)) {
         return $this->selectedCache[$location] = [];
     }
     $menuRepository = $this->entityManager->getRepository('OctavaMenuBundle:Menu');
     $items = $menuRepository->getActiveByStructureIdAndLocation($structureItem->getId(), $location);
     if (!sizeof($items)) {
         return $this->selectedCache[$location] = [];
     }
     $firstItem = array_shift($items);
     $result = [$firstItem->getId() => $firstItem->getId()];
     $currentItem = $firstItem;
     while ($parentItem = $currentItem->getParent()) {
         /** @var Menu $parentItem */
         $result[$parentItem->getId()] = $parentItem->getId();
         $currentItem = $parentItem;
     }
     $result = array_reverse($result, true);
     return $this->selectedCache[$location] = $result;
 }
Example #2
0
 public function getStructureId()
 {
     $currentItem = $this->structureManager->getCurrentItem();
     return !is_null($currentItem) ? $currentItem->getId() : 0;
 }