* GroupController implements the CRUD actions for Group model. */ class GroupController extends CrudController { public $modelClass = 'app\models\Group'; public $modelSearchClass = 'app\models\search\GroupSearch'; public function runAction($id, $params = []) { if (\Yii::$app->user->identity->banned_at) { $ids = ['create']; if (in_array($id, $ids)) { \Yii::$app->session->setFlash('danger', 'Доступ запрещен, необходимо пополнить баланс'); return $this->redirect(['/']); } } return parent::runAction($id, $params); }
{ public $modelClass = 'app\models\Group'; public $modelSearchClass = 'app\models\search\GroupSearch'; public function runAction($id, $params = []) { if (\Yii::$app->user->identity->banned_at) { $ids = ['create']; if (in_array($id, $ids)) { \Yii::$app->session->setFlash('danger', 'Доступ запрещен, необходимо пополнить баланс'); return $this->redirect(['/']); } }
$parts = $this->createController($route); if (is_array($parts)) { /* @var $controller Controller */ list($controller, $actionID) = $parts; $oldController = Yii::$app->controller; Yii::$app->controller = $controller; $result = $controller->runAction($actionID, $params); if ($oldController !== null) { Yii::$app->controller = $oldController; } return $result; }
$params = $this->catchAll; unset($params[0]); } try { Yii::debug("Route requested: '$route'", __METHOD__); $this->requestedRoute = $route; $result = $this->runAction($route, $params); if ($result instanceof Response) { return $result; } $response = $this->getResponse(); if ($result !== null) {
{ try { $this->state = self::STATE_BEFORE_REQUEST; $this->trigger(self::EVENT_BEFORE_REQUEST); $this->state = self::STATE_HANDLING_REQUEST; $response = $this->handleRequest($this->getRequest()); $this->state = self::STATE_AFTER_REQUEST; $this->trigger(self::EVENT_AFTER_REQUEST); $this->state = self::STATE_SENDING_RESPONSE; $response->send();
require(__DIR__ . '/../vendor/autoload.php'); require(__DIR__ . '/../vendor/yiisoft/yii2/Yii.php'); $config = require(__DIR__ . '/../config/web.php'); (new yii\web\Application($config))->run();