/** * @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); } } }
/** * @param array $formData * @param array $menuItem * @param int $menuItemId * * @return \Symfony\Component\HttpFoundation\RedirectResponse */ protected function executePost(array $formData, array $menuItem, $menuItemId) { return $this->actionHelper->handleEditPostAction(function () use($formData, $menuItem, $menuItemId) { $this->menuItemFormValidation->validate($formData); $formData['mode'] = $this->fetchMenuItemModeForSave($formData); $formData['uri'] = $this->fetchMenuItemUriForSave($formData); return $this->menuItemsModel->save($formData, $menuItemId); }, 'acp/menus'); }
/** * @param array $data * @param array $menuItem * @return bool */ protected function updateMenuItem(array $data, array $menuItem) { return $this->menuItemsModel->save($data, $menuItem['id']) !== false; }
/** * @param string $action * * @return mixed * @throws \ACP3\Core\Controller\Exception\ResultNotExistsException */ public function execute($action = '') { return $this->actionHelper->handleDeleteAction($action, function (array $items) { return $this->menuItemsModel->delete($items); }, null, 'acp/menus'); }