Runs action

@param null $applicablePropertyModelId

@return string
@throws \yii\web\NotFoundHttpException
@throws \yii\web\ServerErrorHttpException
351492
public function run($applicablePropertyModelId = null)
    {
        $applicablePropertyModels = $this->applicablePropertyModels();

        $currentApplicablePropertyModel =
            isset($applicablePropertyModels[$applicablePropertyModelId]) ?
                $applicablePropertyModels[$applicablePropertyModelId] :
                reset($applicablePropertyModels);

        if ($currentApplicablePropertyModel === false) {
            if ($applicablePropertyModelId === null) {
                throw new ServerErrorHttpException("You should have at least 1 applicable_property_models row");
            } else {
                throw new NotFoundHttpException("ApplicablePropertyModels row not found for specified id");
            }
        }

        $model = new PropertyGroup();
        $model->setScenario('search');
        $params = Yii::$app->request->get();
        $dataProvider = $model->search($currentApplicablePropertyModel['id'], $params);

        return $this->render([
            'applicablePropertyModels' => $applicablePropertyModels,
            'currentApplicablePropertyModel' => $currentApplicablePropertyModel,
            'dataProvider' => $dataProvider,
            'model' => $model,
            'editPropertyGroupActionId' => $this->editPropertyGroupActionId,
        ]);
    }
315156
public function run()
    {
        $model = Yii::createObject($this->modelClass);
        $event = $this->getFormEvent($model);

        $this->trigger(self::EVENT_BEFORE_REQUEST, $event);

        $load = $model->load(Yii::$app->request->post());

        if (Yii::$app->request->isAjax) {
            Yii::$app->response->format = Response::FORMAT_JSON;

            return ActiveForm::validate($model);
        }

        if ($load && $model->validate()) {
            if ($model->sendEmail()) {
                $this->trigger(self::EVENT_AFTER_REQUEST, $event);
                Yii::$app->getSession()->setFlash('success', $this->successMessage);

                return $this->redirectTo(Yii::$app->getHomeUrl());
            } else {
                Yii::$app->getSession()->setFlash('error', $this->errorMessage);
            }
        }

        return $this->controller->render($this->view, [
            'model' => $model,
        ]);
    }
1188827
public function run( $id ) {

		$modelService = $this->controller->modelService;

		// Find Model
		$model		= $modelService->getById( $id );
		$template	= isset( $model->template ) ? $model->template : Yii::$app->factory->get( 'templateService' )->getGlobalBySlugType( CoreGlobal::TEMPLATE_DEFAULT, $modelService->getParentType() );

		// Update/Render if exist
		if( isset( $model ) && isset( $template ) ) {

			$configClass	= $template->configPath;
			$config			= new $configClass( $model->getDataMeta( 'config' ) );

			$this->controller->setViewPath( $template->configForm );

			if( $config->load( Yii::$app->request->post(), $config->getClassName() ) && $config->validate() ) {

				$modelService->updateDataMeta( $model, 'config', $config );

				return $this->controller->redirect( $this->controller->returnUrl );
			}

			return $this->controller->render( 'config', [
				'model' => $model,
				'config' => $config
			]);
		}

		// Model not found
		//throw new NotFoundHttpException( Yii::$app->coreMessage->getMessage( CoreGlobal::ERROR_NOT_FOUND ) );
		throw new NotFoundHttpException( 'Either model or template not found.' );
	}
686007
protected function findModel(string $id)
    {
        $item = Yii::$app->authManager->getRule($id);

        if (!empty($item)) {
            return new BizRuleModel($item);
        }

        throw new NotFoundHttpException(Yii::t('yii2mod.rbac', 'The requested page does not exist.'));
    }
673170
public function fetchModelFromProvider($modelId, $providerName = null)
    {
        // @codingStandardsIgnoreStart
        @\trigger_error(
            'Use \ContaoCommunityAlliance\DcGeneral\Controller\ModelCollector::getModel()',
            E_USER_DEPRECATED
        );
        // @codingStandardsIgnoreEnd

        return $this->modelCollector->getModel($modelId, $providerName);
    }
710050
public function move(int $id, ModelInterface $thread): PodiumResponse
    {
        $postMover = $this->getMover($id);

        if ($postMover === null) {
            throw new ModelNotFoundException('Post of given ID can not be found.');
        }

        $postMover->prepareThread($thread);

        return $postMover->move();
    }
1343370
public function run() {

		$column	= Yii::$app->request->post( 'column' );
		$action	= Yii::$app->request->post( 'action' );
		$target	= Yii::$app->request->post( 'target' );

		if( isset( $action ) && isset( $column ) && isset( $target ) ) {

			$target	= preg_split( '/,/', $target );

			$this->modelService->applyBulkByTargetId( $column, $action, $target, $this->config );

			// Trigger Ajax Success
			return AjaxUtil::generateSuccess( Yii::$app->coreMessage->getMessage( CoreGlobal::MESSAGE_REQUEST ) );
		}

		// Trigger Ajax Failure
		return AjaxUtil::generateFailure( Yii::$app->coreMessage->getMessage( CoreGlobal::ERROR_REQUEST ) );
	}
788382
public function run()
    {
        if (isset($this->beforeDeleteCallback)) {
            call_user_func($this->beforeDeleteCallback, $this);
        }

        /* @var $modelClass \yii\db\ActiveRecord */
        $modelClass = $this->modelClass;
        $models = $modelClass::findAll([$this->primaryKey => Yii::$app->request->post('ids')]);
        if (empty($models)) {
            throw new NotFoundHttpException(Yii::t('yii', 'Page not found.'));
        } else {
            foreach ($models as $model) {
                $model->delete();
            }
            if (isset($this->afterDeleteCallback)) {
                call_user_func($this->afterDeleteCallback, $this);
            }

            return $this->redirect();
        }
    }
1078645
public function renderPagetabPropertiesAction()
	{
		$idPage = $this->params()->fromRoute('idPage', $this->params()->fromQuery('idPage', ''));
		$melisKey = $this->params()->fromRoute('melisKey', '');
		$pageStyle = null;
		$pathAppConfigForm = self::PagePropertiesAppConfigPath;
		 
		/**
		 * Get the config for this form
		 */
		$melisMelisCoreConfig = $this->serviceLocator->get('MelisCoreConfig');
		$pageStyleTable = $this->getServiceLocator()->get('MelisEngineTablePageStyle');
		
		$appConfigForm = $melisMelisCoreConfig->getFormMergedAndOrdered(
		    self::PagePropertiesAppConfigPath,
		    'meliscms_page_properties',
		    $idPage . '_'
		);

		/** Overriding the Page properties form by calling listener */
        $modifiedForm =  $this->getEventManager()->trigger(
            'modify_page_properties_form_config',
            $this,
            ['appConfigForm' => $appConfigForm]
        )->last();
        if (!empty($modifiedForm)) {
            $appConfigForm = $modifiedForm;
        }

		if (!empty($idPage))
		{
			// Lang not changeable after creation, config array defines the form in "new" state
			$appConfigForm = $melisMelisCoreConfig->setFormFieldDisabled($appConfigForm, 'plang_lang_id', true);
			$appConfigForm = $melisMelisCoreConfig->setFormFieldRequired($appConfigForm, 'plang_lang_id', false);
		}
		 
		/**
		 * Get the data to fill the form
		 */
		if (!empty($idPage))
		{
			$melisPage = $this->serviceLocator->get('MelisEnginePage');
			$datasPage = $melisPage->getDatasPage($idPage, 'saved');
			$datasPageTree = $datasPage->getMelisPageTree();
			$pageStyle = $pageStyleTable->getEntryByField('pstyle_page_id', $idPage)->current();
		}
		else
			$datasPageTree = null;
		 
		/**
		 * Generate the form through factory and change ElementManager to
		 * have access to our custom Melis Elements
		 * Bind with datas
		 */
		$factory = new \Zend\Form\Factory();
		$formElements = $this->serviceLocator->get('FormElementManager');
		$factory->setFormElementManager($formElements);
		$appConfigForm['attributes']['action'] .= '?idPage=' . $idPage;
		$propertyForm = $factory->createForm($appConfigForm);
		
		// service for handling Melis Multi Value Input (tags)
		if (!empty($datasPageTree)) {
		    // modify the values of the dates to render to its locale
		    $container = new Container('meliscore');
		    $locale = $container['melis-lang-locale'];
		    $melisTranslation = $this->getServiceLocator()->get('MelisCoreTranslation');
		    
		    $datasPageTree->page_creation_date = strftime($melisTranslation->getDateFormatByLocate($locale), strtotime($datasPageTree->page_creation_date));
		    $datasPageTree->page_edit_date = strftime($melisTranslation->getDateFormatByLocate($locale), strtotime($datasPageTree->page_edit_date));
            $propertyForm->bind($datasPageTree);
		}
		
		if(!empty($pageStyle)){
		    $propertyForm->setData(array('style_id' => $pageStyle->pstyle_style_id));
		}
		
		/**
		 * Send back the view and add the form config inside
		*/
		$view = new ViewModel();
		$view->setVariable('meliscms_page_properties', $propertyForm);
		$view->idPage = $idPage;
		$view->melisKey = $melisKey;
	
		return $view;
	}
331458
protected function findModel($id)
    {
        $item = Yii::$app->authManager->getRule($id);
        if ($item) {
            return new AdminBizRule($item);
        } else {
            throw new NotFoundHttpException(Yii::t('app', 'The requested page does not exist.'));
        }
    }
44731
protected function findModel($id)
    {
        $item = Yii::$app->authManager->getRule($id);
        if ($item) {
            return new BizRule($item);
        } else {
            throw new NotFoundHttpException('The requested page does not exist.');
        }
    }
799690
public function run( $id ) {

		$action	= Yii::$app->request->post( 'action' );
		$model	= $this->modelService->getById( $id );

		if( isset( $action ) && isset( $model ) ) {

			$action		= str_replace( '-', '', ucwords( $action, '-' ) );
			$action		= lcfirst( $action );
			$service	= $this->modelService;
			$result		= $service->$action( $model, $this->config );

			// Trigger Ajax Success
			if( $result ) {

				return AjaxUtil::generateSuccess( Yii::$app->coreMessage->getMessage( CoreGlobal::MESSAGE_REQUEST ) );
			}
		}

		// Trigger Ajax Failure
		return AjaxUtil::generateFailure( Yii::$app->coreMessage->getMessage( CoreGlobal::ERROR_REQUEST ) );
	}
527527
public static function getAutoAddedGroupsIds($applicablePropertyModelId)
    {
        return Yii::$app->cache->lazy(
            function () use ($applicablePropertyModelId) {
                return array_map(
                    function ($item) {
                        return intval($item);
                    },
                    PropertyGroup::find()
                        ->select('id')
                        ->where(['applicable_property_model_id' => $applicablePropertyModelId, 'is_auto_added' => 1])
                        ->orderBy(['sort_order' => SORT_ASC])
                        ->column()
                );
            },
            'AutoAddedGroupsIds:' . $applicablePropertyModelId,
            86400 // @todo Add dependencies
        );
    }
1194640
public function run($id = null)
    {
        $model = $this->initModel($id);

        $wasNew = $model->isNewRecord;

        $loaded = $this->load($model, Yii::$app->getRequest());
        // always call this to validate every AJAX call, even if it's a GET
        if (($response = $this->validateAjax($model)) !== false) {
            return $response;
        }
        if ($loaded && $this->beforeSave($model)) {
            $trx = $model->getDb()->beginTransaction();
            if (!$this->save($model)) {
                throw new ServerErrorHttpException('Failed to create the object for unknown reason.');
            }
            $trx->commit();

            $this->afterSave($model, $wasNew);
        }

        return $this->getResponse($model);
    }
1184722
public function run()
    {
        $id = yii::$app->getRequest()->get($this->paramSign, null);
        if (! $id) throw new BadRequestHttpException(yii::t('app', "{$this->paramSign} doesn't exit"));
        /* @var $model yii\db\ActiveRecord */
        $model = call_user_func([$this->modelClass, 'findOne'], $id);
        if (! $model) throw new BadRequestHttpException(yii::t('app', "Cannot find model by $id"));
        $model->setScenario( $this->scenario );

        if (yii::$app->getRequest()->getIsPost()) {
            if ($model->load(Yii::$app->getRequest()->post()) && $model->save()) {
                if( yii::$app->getRequest()->getIsAjax() ){
                    yii::$app->getSession()->setFlash('success', yii::t('app', 'Update Success'));
                    return [];
                }else {
                    yii::$app->getSession()->setFlash('success', yii::t('app', 'Update Success'));
                    if( $this->successRedirect ) return $this->controller->redirect($this->successRedirect);
                    return $this->controller->refresh();
                }
            } else {
                $errors = $model->getErrors();
                $err = '';
                foreach ($errors as $v) {
                    $err .= $v[0] . '<br>';
                }
                if( yii::$app->getRequest()->getIsAjax() ){
                    throw new UnprocessableEntityHttpException($err);
                }else {
                    yii::$app->getSession()->setFlash('error', $err);
                }
                $model = call_user_func([$this->modelClass, 'findOne'], $id);
            }
        }

        $this->viewFile === null && $this->viewFile = $this->id;
        $data = [
            'model' => $model,
        ];
        if( is_array($this->data) ){
            $data = array_merge($data, $this->data);
        }elseif ($this->data instanceof \Closure){
            $data = call_user_func_array($this->data, [$model, $this]);
        }
        return $this->controller->render($this->viewFile, $data);
    }
72864
protected function findModel(int $id)
    {
        $settingModelClass = $this->modelClass;

        if (($model = $settingModelClass::findOne($id)) !== null) {
            return $model;
        } else {
            throw new NotFoundHttpException(Yii::t('yii2mod.settings', 'The requested page does not exist.'));
        }
    }
42390
public function runActionId($actionID = '')
    {
        if (null !== ($action = $this->createAction($actionID))) {
            if ($this->getModule()->beforeControllerAction($this, $action)) {
                $this->runAction($action);
                $this->getModule()->afterControllerAction($this, $action);
            }
        } else {
            $this->missingAction($actionID);
        }
    }