/** * @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); } } }