예제 #1
0
파일: Edit.php 프로젝트: acp3/module-menus
 /**
  * @param int $id
  *
  * @return array|\Symfony\Component\HttpFoundation\RedirectResponse
  * @throws \ACP3\Core\Controller\Exception\ResultNotExistsException
  */
 public function execute($id)
 {
     $menuItem = $this->menuItemsModel->getOneById($id);
     if (empty($menuItem) === false) {
         $this->title->setPageTitlePostfix($menuItem['title']);
         if ($this->request->getPost()->count() !== 0) {
             return $this->executePost($this->request->getPost()->all(), $menuItem, $id);
         }
         if ($this->articlesHelpers) {
             $matches = [];
             if (count($this->request->getPost()->all()) == 0 && $menuItem['mode'] == 4) {
                 preg_match_all(Menus\Helpers\MenuItemsList::ARTICLES_URL_KEY_REGEX, $menuItem['uri'], $matches);
             }
             $this->view->assign('articles', $this->articlesHelpers->articlesList(!empty($matches[2]) ? $matches[2][0] : ''));
         }
         $this->view->assign($this->menuItemFormFieldsHelper->createMenuItemFormFields($menuItem['block_id'], $menuItem['parent_id'], $menuItem['left_id'], $menuItem['right_id'], $menuItem['display']));
         return ['mode' => $this->fetchMenuItemTypes($menuItem['mode']), 'modules' => $this->fetchModules($menuItem), 'target' => $this->formsHelper->linkTargetChoicesGenerator('target', $menuItem['target']), 'form' => array_merge($menuItem, $this->request->getPost()->all()), 'form_token' => $this->formTokenHelper->renderFormToken()];
     }
     throw new Core\Controller\Exception\ResultNotExistsException();
 }