@param $id

@return mixed
@throws NotFoundHttpException
@throws \yii\base\InvalidConfigException
347201
public function actionPdf($id)
    {
        $model = $this->findModel($id);
        $providerWarehouseVoucherItems = new \yii\data\ArrayDataProvider([
            'allModels' => $model->warehouseVoucherItems,
        ]);
        $content = $this->renderAjax('_pdf', [
            'model'                         => $model,
            'providerWarehouseVoucherItems' => $providerWarehouseVoucherItems,
        ]);
        $pdf = new \kartik\mpdf\Pdf([
            'mode'        => \kartik\mpdf\Pdf::MODE_UTF8,
            'format'      => \kartik\mpdf\Pdf::FORMAT_A4,
            'orientation' => \kartik\mpdf\Pdf::ORIENT_PORTRAIT,
            'destination' => \kartik\mpdf\Pdf::DEST_BROWSER,
            'content'     => $content,
            'cssFile'     => '@vendor/kartik-v/yii2-mpdf/assets/kv-mpdf-bootstrap.min.css',
            'cssInline'   => '.kv-heading-1{font-size:18px}',
            'options'     => ['title' => \Yii::$app->name],
            'methods'     => [
                'SetHeader' => [\Yii::$app->name],
                'SetFooter' => ['{PAGENO}'],
            ],
        ]);

        return $pdf->render();
    }
1287470
protected function findModel($id)
    {
        /** @var \yii\web\IdentityInterface $class */
        $class = $this->userClassName;
        if (($user = $class::findIdentity($id)) !== null) {
            return new AdminAssignment($id, $user);
        } else {
            throw new NotFoundHttpException(Yii::t('yuncms', 'The requested page does not exist.'));
        }
    }
1273171
public function getParameterByID($id)
    {
        $param = current(array_filter($this->params, function (Param $param) use ($id) {
            return ($param->id === $id);
        }));

        return ($param) ? $param : null;
    }
481410
protected function findModel($id)
    {
        $item = $this->type === Item::TYPE_ROLE ? Yii::$app->getAuthManager()->getRole($id) :
            Yii::$app->getAuthManager()->getPermission($id);
        if ($item) {
            return new AuthItem($item);
        } else {
            throw new NotFoundHttpException('The requested page does not exist.');
        }
    }
483517
public function actionDownload($id)
    {
        $model = $this->findModel($id);
        if ($model && ($model->isPublic() || $model->isAuthor())) {
            return Yii::$app->response->sendContentAsFile($model->content, $model->title);
        } else {
            Yii::$app->session->setFlash('success', Yii::t('note', 'Note does not exist.'));
            return $this->redirect(['index']);
        }
    }
252136
public function run( $id ) {

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

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

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

			$dataClass	= $template->dataPath;
			$dataKey	= isset( $dataClass::$dataKey ) ? $dataClass::$dataKey : 'data';
			$data		= new $dataClass( $model->getDataMeta( $dataKey ) );

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

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

				$modelService->updateDataMeta( $model, $dataKey, $data->getData() );

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

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

		// Model not found
		throw new NotFoundHttpException( 'Either model or template not found.' );
	}
621333
public function actionUpdate($id)
    {
        $this->layout = static::MAIN_LAYOUT;
        $model = $this->findModel($id);

        if ($model->load(Yii::$app->request->post()) && $model->save()) {
            $this->afterUpdate($model);
            return $this->redirect(['view', 'id' => $model->id]);
        } else {
            if($model->template) {
                return $this->render($model->template, [
                    'model' => $model,
                ]);
            } else {
                return $this->render('update', [
                    'model' => $model,
                ]);
            }
        }
    }
1083793
public function run( $id ) {

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

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

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

			$attributesClass = $template->attributesPath;

			$attributes = new $attributesClass( $model->getDataMeta( 'attributes' ) );

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

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

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

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

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

		// Model not found
		throw new NotFoundHttpException( 'Either model or template not found.' );
	}
462136
protected function getUser($id)
    {
        $user = $this->userManager->findUserBy(['id' => $id]);

        if (null === $user) {
            throw new NotFoundHttpException(sprintf('User (%d) not found', $id));
        }

        return $user;
    }
588210
public function run($id)
    {
        $model = $this->getModel($id);
        $model->setScenario($this->scenario);
        if ($model->load(Yii::$app->getRequest()->post())) {
            if (Yii::$app->getRequest()->isAjax) {
                Yii::$app->getResponse()->format = Response::FORMAT_JSON;
                return ActiveForm::validate($model);
            }
            if ($model->save()) {
                $this->addSuccessFlash();
                return $this->redirect($model);
            } else {
                $this->addErrorFlash();
            }
        }

        return $this->controller->render($this->view, [
            $this->nameVariableModel => $model,
        ]);
    }
311750
public function actionDelete($id)
    {
        $model = $this->findModel($id);
        Yii::$app->getUserAuthManager()->remove($model->item);
        UserRBACHelper::invalidate();
        return $this->redirect(['index']);
    }
313645
public function run($id)
    {
        $model = $this->findModel($id);

        $model->setScenario($this->scenario);
        // Check if there is an Editable ajax request
        if (isset($_POST['hasEditable'])) {
            \Yii::$app->response->format = Response::FORMAT_JSON;
            if ($model->load(\Yii::$app->request->post()) && $model->save()) {
                // return JSON encoded output in the below format
                return ['output'=>'', 'message' =>''];
            } else {
                return ['output' => '', 'message' => Json::htmlEncode($model->getFirstErrors())];
            }
        }
        return ['output'=>'', 'message' => \Yii::t('app', 'Error Parameters.')];
    }
806405
public function actionDelete($id)
    {
        if (Yii::$app->request->isPost) {
            $this->findModel($id)->delete();
        }
        return $this->redirect(['index']);
    }
389365
protected function getPost($id)
    {
        $post = $this->postManager->find($id);

        if (null === $post) {
            throw new NotFoundHttpException(sprintf('Post (%d) not found', $id));
        }

        return $post;
    }
189446
protected function findModel($id)
    {
        $user = $this->finder->findUserById($id);
        if ($user === null) {
            throw new NotFoundHttpException('The requested page does not exist');
        }

        return $user;
    }
517457
protected function findModel($id)
    {
        /** @var \amnah\yii2\user\models\User $user */
        $user = $this->module->model("User");
        $user = $user::findOne($id);
        if ($user) {
            return $user;
        }

        throw new NotFoundHttpException('The requested page does not exist.');
    }
1324424
public function actionFetch($id)
    {
        $model = $this->findModel($id);
        $model->setScenario('update');
        Yii::$app->response->format = Response::FORMAT_HTML;
        return $this->renderAjax('@vendor/frenzelgmbh/cm-address/views/widgets/views/_form_update', ['model' => $model]);
    }