If menu item does not exist or is not allowed, redirect to index

@return \Gems_Snippets_ModelFormSnippetAbstract
349831
protected function setAfterSaveRoute()
    {
        parent::setAfterSaveRoute();

        if (is_array($this->afterSaveRouteUrl)) {
            // Make sure controller is set
            if (!array_key_exists('controller', $this->afterSaveRouteUrl)) {
                $this->afterSaveRouteUrl['controller'] = $this->request->getControllerName();
            }

            // Search array for menu item
            $find['controller'] = $this->afterSaveRouteUrl['controller'];
            $find['action'] = $this->afterSaveRouteUrl['action'];

            // If not allowed, redirect to index
            if (null == $this->menu->find($find)) {
                $this->afterSaveRouteUrl['action'] = 'index';
                $this->resetRoute = true;
            }
        }
        // \MUtil_Echo::track($this->routeAction, $this->resetRoute);

        return $this;
    }
328864
public function indexAction()
    {
        // Clear the user identity, if any. (#370)
        if (PHP_SESSION_ACTIVE !== session_status()) {
            session_start();
        }
        session_destroy();

        $form    = $this->installForm;
        $prereqs = $this->plugin('Install/Prerequisites')->check();
    
        return $this->createViewModel(
            array(
                'prerequisites' => $prereqs,
                'form'          => $form,
                'lang'          => $this->params('lang'),
            )
        );
    }
463533
public function index() {
        if ($this->overrideAction('index')) {
            return;
        }

        $this->paginate = array_merge(array(
            'limit' => 25,
            'order' => array($this->Model->alias . '.' . $this->Model->displayField => 'ASC'),
            'contain' => array_keys($this->Model->belongsTo)
        ), $this->Model->admin['paginate']);

        $this->AdminToolbar->setBelongsToData($this->Model);

        // Filters
        if (!empty($this->request->params['named'])) {
            $this->paginate['conditions'] = $this->AdminToolbar->parseFilterConditions($this->Model, $this->request->params['named']);
        }

        // Batch delete
        if ($this->request->is('post')) {
            if (!$this->Model->admin['batchProcess']) {
                throw new ForbiddenException(__d('admin', 'Batch Access Protected'));
            }

            $action = $this->request->data[$this->Model->alias]['batch_action'];
            $items = $this->request->data[$this->Model->alias]['items'];
            $processed = array();

            foreach ($items as $id) {
                if (!$id) {
                    continue;
                }

                if ($action === 'delete_item') {
                    if ($this->Model->delete($id, true)) {
                        $processed[] = $id;
                    }
                } else {
                    if (call_user_func(array($this->Model, $action), $id)) {
                        $processed[] = $id;
                    }
                }
            }

            $count = count($processed);

            if ($count > 0) {
                $this->AdminToolbar->logAction(ActionLog::BATCH_DELETE, $this->Model, '', sprintf('Processed IDs: %s', implode(', ', $processed)));
                $this->AdminToolbar->setFlashMessage(__d('admin', '%s %s have been processed', array($count, mb_strtolower($this->Model->pluralName))));

                $this->request->data[$this->Model->alias] = array();
            }
        }

        $this->set('results', $this->paginate($this->Model));
        $this->overrideView('index');
    }
436374
public function SearchForm() {
        $languages=SnippetLanguage::get()
                                        ->leftJoin('Snippet', '"Snippet"."LanguageID"="SnippetLanguage"."ID"')
                                        ->where('"SnippetLanguage"."Hidden"=0 OR "Snippet"."ID" IS NOT NULL')
                                        ->sort('Name');
        
        $fields=new FieldList(
                            new TextField('q[Term]', _t('CodeBank.KEYWORD', '_Keyword')),
                            $classDropdown=new DropdownField(
                                                            'q[LanguageID]',
                                                            _t('CodeBank.LANGUAGE', '_Language'),
                                                            $languages->map('ID', 'Name')
                                                        )
                        );
        
        
        $classDropdown->setEmptyString(_t('CodeBank.ALL_LANGUAGES', '_All Languages'));
        
        
        $actions=new FieldList(
                            FormAction::create('doSearch', _t('CodeBank.APPLY_FILTER', '_Apply Filter'))->setUseButtonTag(true)
                        );
        
        
        $form=Form::create($this, 'SearchForm', $fields, $actions)
                                                                ->addExtraClass('cms-search-form')
                                                                ->setFormMethod('GET')
                                                                ->setFormAction($this->Link())
                                                                ->disableSecurityToken()
                                                                ->unsetValidator();
        $form->loadDataFrom($this->request->getVars());
    
        $this->extend('updateSearchForm', $form);
        return $form;
    }
1117635
public function actionIndex()
    {
        /** @var SearchForm $model */
        $model = $this->module->createFormModel('SearchForm');
        if (isset($_REQUEST['SearchForm'])) {
            $model->attributes = $_REQUEST['SearchForm'];
            $model->validate();
            $errors = $model->getErrors();
            $model->setAttributes(array_fill_keys(array_keys($errors), null));
        }

        if (Yii::$app->response->format === Response::FORMAT_JSON) {
            $serializer = new Serializer;
            return $serializer->serialize($model->getIdentity()->getDataProvider($model));
        }

        return $this->render('index', ['model' => $model]);
    }
463790
public function index()
    {
        $frontMenus = MenuFacade::all();
        $categories = Category::all();
        $menus = $this->repository->parentsAll();

        return view('avored-ecommerce::menu.index')
                    ->with('categories', $categories)
                    ->with('frontMenus', $frontMenus)
                    ->with('menus', $menus);
    }
999304
public function indexesAction()
    {
        return $this->viewHandler->handle(
            View::create(
                array_map(
                    function($indexName) {
                        $indexConfiguration = $this->indexConfigurationProvider->getIndexConfiguration($indexName);

                        return $indexConfiguration ?: new IndexConfiguration($indexName);
                    },
                    $this->getAllowedIndexes()
                )
            )
        );
    }
1293700
public function indexAction()
    {
        $form = $this->formSearch;

        if ($this->getRequest()
                 ->isPost()
        ) {
            $form->setData(
                $this->params()
                     ->fromPost()
            );

            if ($form->isValid()) {
                return $this->redirect()
                            ->toRoute(
                                'mp3-search',
                                [
                                    'name' => $this->params()
                                                   ->fromPost('name')
                                ]
                            );
            }
        }

        $service = $this->serviceIndex
            ->index(
                $this->params()
                     ->fromRoute()
            );

        return (new ViewModel())
            ->setTemplate('mp3/mp3/search')
            ->setVariables(
                [
                    'form'          => $form,
                    'paginator'     => $service['paginator'],
                    'path'          => $service['path'],
                    'totalLength'   => $service['totalLength'],
                    'totalFileSize' => $service['totalFileSize'],
                    'search'        => $service['search'],
                    'dir'           => $this->params()
                                            ->fromRoute('dir')
                ]
            );
    }
817326
public function indexingFormAction()
    {
        $form = $this->formFactory->create(
            new AdminForm\IndexingType($this->configHandler->getLockedParamaters()),
            $this->configHandler->getPlatformConfig()
        );

        if ($this->request->getMethod() === 'POST') {
            $form->handleRequest($this->request);

            if ($form->isValid()) {
                $this->configHandler->setParameter('google_meta_tag', $form['google_meta_tag']->getData());

                $this->addFlashMessage('parameters_save_success');

                return $this->redirect($this->generateUrl('claro_admin_index'));
            }
        }

        return array('form' => $form->createView());
    }
1303300
public function indexAction()
    {
        $this->html->h2($this->getTopicTitle());

        $displayColumns = array('link'     => '',
                                'context'  => $this->_('Context'),
                                'maxLevel' => $this->_('Max level'),
                                'level'    => $this->_('Level'));

        foreach($this->_upgrades->getUpgradesInfo() as $row) {
            $menuItem = $this->menu->findAllowedController($this->_getParam('controller'), 'show');
            if ($menuItem) {
                $row['link'] = $menuItem->toActionLinkLower($this->getRequest(), $row);
            }
            $data[] = $row;
        }
        $this->addSnippet('SelectiveTableSnippet', 'data', $data, 'class', 'browser table', 'columns', $displayColumns);
        $this->html->br();
        $this->compatibilityReportAction();
    }
978309
public function StatusForm() {
		$existing = $this->getEditingLocks($this->data());

		if ($existing && $existing['user'] != Member::currentUser()->Email) {
			$fields = FieldList::create(
							new ReadonlyField('ExistingEditor', '', _t('WikiPage.EXISTINGEDITOR', 'This page is currently locked for editing by ' . $existing['user'] . ' until ' . $existing['expires']))
			);
			$actions = FieldList::create();
		} else {
			$fields = FieldList::create();
			$actions = FieldList::create(
							new FormAction('startediting', _t('WikiPage.STARTEDIT', 'Edit Page'))
			);
		}

		return new Form($this, 'StatusForm', $fields, $actions);
	}
828488
public function actionIndex()
    {
        $model = new Location();
        if ($model->load(\Yii::$app->request->post()) && $model->save()) {
            $model = new Location(); //reset model
        }

        $searchModel = new LocationSearch(['pagination' => TRUE]);
        $dataProvider = $searchModel->search(\Yii::$app->request->queryParams);

        return $this->render('index', [
                    'searchModel' => $searchModel,
                    'dataProvider' => $dataProvider,
                    'model' => $model,
        ]);
    }
706177
public function isSortable() 
    {
        $this->getSearchCriteria();
        $sortable = new \stdClass;
        if($this->searchModel->Menu_id > 0) {
            $sortable->sortable = true;
            $sortable->link = Url::toRoute(['sort', 'Menu_id' => $this->searchModel->Menu_id]);
        } else {
            $sortable->sortable = false;
            $sortable->message = 'Filter on a menu first';
        }
        return $sortable;
    }
74956
public function update($menu = null, $model, FormRequest $request)
    {
        $data = $request->all();
        $data['parent_id'] = $data['parent_id'] ?: null;
        $data['page_id'] = $data['page_id'] ?: null;
        $this->repository->update($data);

        return $this->redirect($request, $model);
    }
392644
public function actionIndex()
    {
        $model = $this->getModel();

        $data = Yii::$app->request->post($model->formName());
        if (empty($data)) {
            $data = $this->getThemeSettingsStorage()->get();
        }

        if (Yii::$app->request->getIsPost() && $model->load($data) && $model->validate()) {
            $this->getThemeSettingsStorage()->set($model);
            $this->setGlobalOrientation($model->filterOrientation);
            Yii::$app->session->setFlash('success', Yii::t('hiqdev.thememanager', 'Layout settings saved.'));
        }

        if (Yii::$app->request->isAjax) {
            return $this->renderAjax('//settings/_form', compact('model'));
        }

        return $this->render('index', compact('model'));
    }
154154
public function index()
    {
        // Look for overriden views
        $this->overrideViews();

        // Get models to show
        $results = $this->makeIndexQuery()->paginate($this->perPage());

        // Render the view using the `listing` builder
        $listing = Listing::createFromController($this, $results);
        if ($this->parent) {
            $listing->parent($this->parent);

            // The layout header may have a many to many autocomplete
            $this->layout->with($this->autocompleteViewVars());
        }

        // Render view
        return $this->populateView($listing);
    }
1190920
public function indexAction()
    {
        if ($this->util->getMaintenanceLock()->isLocked()) {
            $this->addSnippet($this->maintenanceModeSnippets);
            return;
        }

        // Make sure to return to the forward screen
        $this->currentUser->setSurveyReturn();

        $request = $this->getRequest();
        $tracker = $this->loader->getTracker();
        $form    = $tracker->getAskTokenForm(array(
            'displayOrder' => array('element', 'description', 'errors'),
            'labelWidthFactor' => 0.8
            ));

        if ($request->isPost() && $form->isValid($request->getParams())) {
            $this->_forward('forward');
            return;
        }

        $form->populate($request->getParams());
        $this->displayTokenForm($form);
    }