/**
  * @param string $value
  *
  * @return bool
  */
 protected function checkParentIdExists($value)
 {
     if (empty($value)) {
         return true;
     }
     return $this->menuItemRepository->menuItemExists($value);
 }
 /**
  * @param string $routeName
  * @return array
  */
 private function fetchMenuItems($routeName)
 {
     $menuItem = $this->menuItemRepository->getOneMenuItemByUri($routeName);
     if (empty($menuItem)) {
         $menuItem = [];
     }
     return $menuItem;
 }
 /**
  * @param int $parentId
  * @param int $menuId
  *
  * @return bool
  */
 protected function checkIsAllowedMenu($parentId, $menuId)
 {
     if (empty($parentId)) {
         return true;
     }
     $parentMenuId = $this->menuItemRepository->getMenuIdByMenuItemId($parentId);
     return !empty($parentMenuId) && $parentMenuId == $menuId;
 }
Beispiel #4
0
 /**
  * Initializes and pre populates the breadcrumb
  */
 public function prePopulate()
 {
     if ($this->request->getArea() !== Core\Controller\AreaEnum::AREA_ADMIN) {
         $in = [$this->request->getQuery(), $this->request->getUriWithoutPages(), $this->request->getFullPath(), $this->request->getModuleAndController(), $this->request->getModule()];
         $items = $this->menuItemRepository->getMenuItemsByUri($in);
         foreach ($items as $item) {
             $this->appendFromDB($item['title'], $item['uri']);
         }
     }
 }
Beispiel #5
0
 /**
  * @param int    $id
  * @param string $action
  *
  * @return \Symfony\Component\HttpFoundation\RedirectResponse
  * @throws \ACP3\Core\Controller\Exception\ResultNotExistsException
  */
 public function execute($id, $action)
 {
     if ($this->menuItemRepository->menuItemExists($id) === true) {
         $this->sortOperation->execute($id, $action);
         $this->menusCache->saveMenusCache();
         Core\Cache\Purge::doPurge($this->appPath->getCacheDir() . 'http');
         return $this->redirect()->temporary('acp/menus');
     }
     throw new Core\Controller\Exception\ResultNotExistsException();
 }
Beispiel #6
0
 /**
  * @param string $menuItemUri
  * @param bool $createOrUpdateMenuItem
  * @param array $data
  *
  * @return bool
  */
 public function manageMenuItem($menuItemUri, $createOrUpdateMenuItem, array $data = [])
 {
     $menuItem = $this->menuItemRepository->getOneMenuItemByUri($menuItemUri);
     $result = true;
     if ($createOrUpdateMenuItem === true) {
         if (empty($menuItem)) {
             $result = $this->createMenuItem($data, $menuItemUri);
         } else {
             $result = $this->updateMenuItem($data, $menuItem);
         }
     } elseif (!empty($menuItem)) {
         $result = $this->menuItemsModel->delete($menuItem['id']) > 0;
     }
     return $result;
 }
Beispiel #7
0
 /**
  * @param string $menu
  *
  * @return int
  */
 protected function selectMenuItem($menu)
 {
     if ($this->request->getArea() !== Core\Controller\AreaEnum::AREA_ADMIN) {
         $in = [$this->request->getQuery(), $this->request->getUriWithoutPages(), $this->request->getFullPath(), $this->request->getModuleAndController(), $this->request->getModule()];
         return $this->menuItemRepository->getLeftIdByUris($menu, $in);
     }
     return 0;
 }
 /**
  * @param ModelSaveEvent $event
  */
 public function execute(ModelSaveEvent $event)
 {
     if (!$event->isDeleteStatement()) {
         return;
     }
     foreach ($event->getEntryId() as $item) {
         if (!empty($item) && $this->menuRepository->menuExists($item) === true) {
             // Delete the assigned menu items and update the nested set tree
             $menuItems = $this->menuItemRepository->getAllItemsByBlockId($item);
             foreach ($menuItems as $menuItem) {
                 $this->menuItemsModel->delete($menuItem['id']);
             }
             $menuName = $this->menuRepository->getMenuNameById($item);
             $this->cache->getCacheDriver()->delete(Cache::CACHE_ID_VISIBLE . $menuName);
         }
     }
 }
Beispiel #9
0
 /**
  * Saves the visible menu items to the cache
  *
  * @param string $menuIdentifier
  *
  * @return boolean
  */
 public function saveVisibleMenuItemsCache($menuIdentifier)
 {
     return $this->cache->save(self::CACHE_ID_VISIBLE . $menuIdentifier, $this->menuItemRepository->getVisibleMenuItemsByBlockName($menuIdentifier));
 }