yii\base\Controller ----
432729
public function actions() {

		$user = Yii::$app->core->getUser();

		return [
			// Avatar
			'assign-avatar' => [ 'class' => 'cmsgears\core\common\actions\content\avatar\Assign', 'model' => $user ],
			'clear-avatar' => [ 'class' => 'cmsgears\core\common\actions\content\avatar\Clear', 'model' => $user ],
			// Banner
			'assign-banner' => [ 'class' => 'cmsgears\core\common\actions\content\banner\Assign', 'model' => $user ],
			'clear-banner' => [ 'class' => 'cmsgears\core\common\actions\content\banner\Clear', 'model' => $user ],
			// Video
			'assign-video' => [ 'class' => 'cmsgears\core\common\actions\content\video\Assign', 'model' => $user ],
			'clear-video' => [ 'class' => 'cmsgears\core\common\actions\content\video\Clear', 'model' => $user ],
			// Gallery
			'update-gallery' => [ 'class' => 'cmsgears\core\common\actions\gallery\Update', 'model' => $user ],
			'get-gallery-item' => [ 'class' => 'cmsgears\core\common\actions\gallery\item\Read', 'model' => $user ],
			'add-gallery-item' => [ 'class' => 'cmsgears\core\common\actions\gallery\item\Create', 'model' => $user ],
			'update-gallery-item' => [ 'class' => 'cmsgears\core\common\actions\gallery\item\Update', 'model' => $user ],
			'delete-gallery-item' => [ 'class' => 'cmsgears\core\common\actions\gallery\item\Delete', 'model' => $user ],
			// Options
			'assign-option' => [ 'class' => 'cmsgears\core\common\actions\option\Assign', 'model' => $user ],
			'remove-option' => [ 'class' => 'cmsgears\core\common\actions\option\Remove', 'model' => $user ],
			'delete-option' => [ 'class' => 'cmsgears\core\common\actions\option\Delete', 'model' => $user ],
			'toggle-option' => [ 'class' => 'cmsgears\core\common\actions\option\Toggle', 'model' => $user ],
			// Metas
			'add-meta' => [ 'class' => 'cmsgears\core\common\actions\meta\Create', 'model' => $user ],
			'update-meta' => [ 'class' => 'cmsgears\core\common\actions\meta\Update', 'model' => $user ],
			'toggle-meta' => [ 'class' => 'cmsgears\core\common\actions\meta\Toggle', 'model' => $user ],
			'delete-meta' => [ 'class' => 'cmsgears\core\common\actions\meta\Delete', 'model' => $user ],
			'settings' => [ 'class' => 'cmsgears\core\common\actions\meta\UpdateMultiple', 'model' => $user ],
			// Address
			'get-address' => [ 'class' => 'cmsgears\core\common\actions\address\Read', 'model' => $user ],
			'add-address' => [ 'class' => 'cmsgears\core\common\actions\address\Create', 'model' => $user ],
			'update-address' => [ 'class' => 'cmsgears\core\common\actions\address\Update', 'model' => $user ],
			'delete-address' => [ 'class' => 'cmsgears\core\common\actions\address\Delete', 'model' => $user ],
			// Data Object - Use current logged in user to update the config and settings
			'set-data' => [ 'class' => 'cmsgears\core\common\actions\data\data\Set', 'model' => $user ],
			'remove-data' => [ 'class' => 'cmsgears\core\common\actions\data\data\Remove', 'model' => $user ],
			'set-attribute' => [ 'class' => 'cmsgears\core\common\actions\data\attribute\Set', 'model' => $user ],
			'remove-attribute' => [ 'class' => 'cmsgears\core\common\actions\data\attribute\Remove', 'model' => $user ],
			'set-config' => [ 'class' => 'cmsgears\core\common\actions\data\config\Set', 'model' => $user ],
			'remove-config' => [ 'class' => 'cmsgears\core\common\actions\data\config\Remove', 'model' => $user ],
			'set-setting' => [ 'class' => 'cmsgears\core\common\actions\data\setting\Set', 'model' => $user ],
			'remove-setting' => [ 'class' => 'cmsgears\core\common\actions\data\setting\Remove', 'model' => $user ]
		];
	}
752220
public function hasController()
    {
        return $this->def->getService() !== null &&
            $this->def->getService()->getRouterBase() !== null;
    }
1266417
public function actionActivate ()
		{
			if (Yii::$app->request->isAjax)
			{
				$post = Yii::$app->request->post();
				$page = Page::findOne($post[ 'id' ]);
				$page->updateAttributes([ 'active' => $page->active ? 0 : 1 ]);

				echo $page->active;
			}
			Yii::$app->end();
		}
43191
public function init()
    {
        // Autoload the models and components directory 
        $this->setImport(array(
            'api.models.*',
            'api.components.*',
        ));
        
        // Disable layout rendering
        $this->layout = false;
        
        // Disable logging for the API
        foreach(Yii::app()->log->routes as $k=>$v)
        {
            if (get_class($v) == 'CWebLogRoute' || get_class($v) == "CProfileLogRoute")
                Yii::app()->log->routes[$k]->enabled = false; 
        }
        
        // Set default components and routes
        Yii::app()->setComponents(array(
            'errorHandler' => array(
                'errorAction'  => 'api/default/error',
            ),
            'messages' => array(
                'class' => 'cii.components.CiiPHPMessageSource',
                'basePath' => Yii::getPathOfAlias('application.modules.api')
            )
        ));
    }
663495
private function createController(): void
    {
        $aFields  = $this->getArguments();
        $aCreated = [];

        try {

            $aControllers = array_filter(
                array_map(function ($sController) {
                    return implode('/', array_map('ucfirst', explode('/', ucfirst(trim($sController)))));
                }, explode(',', $aFields['CONTROLLER_NAME']))
            );
            $aMethods     = array_filter(
                array_map(function ($sMethod) {
                    return lcfirst(trim($sMethod));
                }, explode(',', $aFields['METHODS']))
            );

            sort($aControllers);

            foreach ($aControllers as $sController) {

                $aControllerBits = explode('/', $sController);
                $aControllerBits = array_map('ucfirst', $aControllerBits);

                if (count($aControllerBits) > 2) {
                    throw new ConsoleException('Controllers cannot be deeper than one directory');
                }

                $aFields['MODULE_NAME']     = getFromArray(0, $aControllerBits);
                $aFields['CONTROLLER_NAME'] = getFromArray(1, $aControllerBits, $aFields['MODULE_NAME']);
                $this->oOutput->write('Creating controller <comment>' . $sController . '</comment>... ');


                if (count($aControllerBits) == 2) {
                    //  A path has been specified, splice in the correct folder structure
                    $aLastControllerBits = array_splice($aControllerBits, -1, 1);
                    $aControllerBits     = array_merge(
                        array_map('lcfirst', $aControllerBits),
                        ['controllers'],
                        array_map('ucfirst', $aLastControllerBits)
                    );
                } else {
                    //  The controller should be in a folder called itself
                    $aControllerBits = array_merge(
                        array_map('lcfirst', $aControllerBits),
                        ['controllers'],
                        array_map('ucfirst', $aControllerBits)
                    );
                }

                $aViewBits = $aControllerBits;
                array_splice($aViewBits, -2, 1, ['views']);

                $sControllerPath     = self::CONTROLLER_PATH . implode('/', array_slice($aControllerBits, 0, -1)) . '/';
                $sViewPath           = self::CONTROLLER_PATH . implode('/', array_slice($aViewBits, 0, -1)) . '/';
                $sControllerFilename = end($aControllerBits) . '.php';
                $sClassName          = ucfirst(underscoreToCamelcase(end($aControllerBits)));

                $aFields['CONTROLLER_PATH']     = $sControllerPath;
                $aFields['CONTROLLER_FILENAME'] = $sControllerFilename;
                $aFields['CONTROLLER_CLASS']    = $sClassName;
                $aFields['VIEW_PATH']           = $sViewPath;

                //  Check if the controller already exists
                if (file_exists($sControllerPath . $sControllerFilename)) {
                    throw new ConsoleException(
                        'Controller "' . $sController . '" already exists at "' . $sControllerPath . $sControllerFilename . '"'
                    );
                }

                //  Generate methods
                if ($aFields['MODULE_NAME'] === $aFields['CONTROLLER_NAME']) {
                    $sViewPathPrefix = '';
                    $sViewPrefix     = lcfirst($aFields['CONTROLLER_NAME']) . '/';
                } else {
                    $sViewPathPrefix = $aFields['CONTROLLER_NAME'] . '/';
                    $sViewPrefix     = lcfirst($aFields['MODULE_NAME']) . '/' . $aFields['CONTROLLER_NAME'] . '/';
                }

                $aMethodStrings = [];
                $aViews         = [];
                reset($aMethods);
                foreach ($aMethods as $sMethod) {

                    $aViews[]         = $sViewPathPrefix . $sMethod;
                    $aMethodStrings[] = '';
                    $aMethodStrings[] = $this->getResource(
                        'template/controller_method.php',
                        [
                            'METHOD_NAME' => $sMethod,
                            'METHOD_VIEW' => $sViewPrefix . $sMethod,
                        ]
                    );
                    $aMethodStrings[] = '';
                    $aMethodStrings[] = '// --------------------------------------------------------------------------';
                }

                //  Remove the first item (blank string) and the last two (separators)
                $aMethodStrings = array_slice($aMethodStrings, 1, -2);

                //  Add leading tabs
                array_walk(
                    $aMethodStrings,
                    function (&$sLine) {
                        $sLine = trim($sLine);
                        if (!empty($sLine)) {
                            $aLines = explode("\n", $sLine);
                            foreach ($aLines as &$sSingleLine) {
                                $sSingleLine = $this->tabs(1) . $sSingleLine;
                            }
                            $sLine = implode("\n", $aLines);
                        }
                    }
                );

                $aFields['METHODS'] = implode("\n", $aMethodStrings);

                //  Ensure the path exists
                $this->createPath($aFields['CONTROLLER_PATH']);

                //  Create the controller and write to it
                $this->createFile(
                    $aFields['CONTROLLER_PATH'] . $aFields['CONTROLLER_FILENAME'],
                    $this->getResource('template/controller.php', $aFields)
                );
                $aCreated[] = $aFields['CONTROLLER_PATH'] . $aFields['CONTROLLER_FILENAME'];
                $this->oOutput->writeln('<info>done!</info>');

                //  Create the views
                $this->oOutput->write('Creating views for controller <comment>' . $sController . '</comment>... ');
                $this->createPath($aFields['VIEW_PATH']);

                foreach ($aViews as $sView) {
                    $sViewPath    = $aFields['VIEW_PATH'] . $sView . '.php';
                    $sViewSubPath = dirname($sView);
                    if ($sViewSubPath !== '.') {
                        $this->createPath($aFields['VIEW_PATH'] . $sViewSubPath);
                    }
                    $this->createFile(
                        $sViewPath,
                        $this->getResource(
                            'template/view.php',
                            [
                                'VIEW' => preg_replace('#^' . NAILS_APP_PATH . '#', '', $sViewPath),
                            ]
                        )
                    );
                    $aCreated[] = $sView;

                }
                $this->oOutput->writeln('<info>done!</info>');
            }

        } catch (ConsoleException $e) {
            $this->oOutput->writeln('<error>failed!</error>');
            //  Clean up created models
            if (!empty($aCreated)) {
                $this->oOutput->writeln('<error>Cleaning up - removing newly created files</error>');
                foreach ($aCreated as $sPath) {
                    @unlink($sPath);
                }
            }
            throw new ConsoleException($e->getMessage());
        }
    }
242029
function run()
    {
        $res = $this->resolve();

        $ctrl = isset($res['controller']) && $res['controller'] !== null ? $res['controller'] : $this->defaultController;
        $action = isset($res['action']) && $res['action'] !== null ? $res['action'] : $this->defaultAction;

        //Name format to Controller namespace
        $tmp = explode('\\', str_replace('/', '\\', $ctrl));
        $ctrl = '\\Controller';
        foreach($tmp as $tmp1){
            $ctrl .= '\\'.ucfirst($tmp1);
        }

        //instantiate the controller
        $controller = new $ctrl(['params' => $res['params'], 'request' => $this->request]);

        $this->params = $res['params'];

        if (method_exists($controller, $action))
            return $controller->$action();
        else
            return $controller->{static::$defaultAction}();
    }
1199887
public function init()
	{
		parent::init();
		if($this->basePath===null)
			$this->basePath=Yii::getPathOfAlias('application.messages');
	}
1283496
public function run() {

		if( isset( $this->model ) ) {

			$modelCommentService = Yii::$app->factory->get( 'modelCommentService' );

			$user = Yii::$app->user->getIdentity();

			$modelClass = $modelCommentService->getModelClass();

			$modelComment	= new $modelClass;
			$commentForm	= new Comment();

			$modelComment->siteId		= Yii::$app->core->getSiteId();
			$modelComment->parentId		= $this->model->id;
			$modelComment->parentType	= $this->parentType;

			$modelComment->status	= $this->status;
			$modelComment->type		= $this->modelType;

			// To set name and email in case user is logged in. The same details can be fetched from user table using createdBy column.
			if( $this->setUser && isset( $user ) ) {

				$modelComment->name		= $user->getName();
				$modelComment->email	= $user->email;
			}

			if( isset( $this->scenario ) ) {

				$commentForm->scenario = $this->scenario;
			}

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

				$modelComment->copyForUpdateFrom( $commentForm, [ 'baseId', 'bannerId', 'videoId', 'avatarUrl', 'websiteUrl', 'rating', 'anonymous', 'content' ] );

				if( !$this->setUser || !isset( $user ) ) {

					$modelComment->copyForUpdateFrom( $commentForm, [ 'name', 'email' ] );
				}

				$modelComment = $modelCommentService->create( $modelComment );

				if( isset( $modelComment ) ) {

					// Refresh model for further processing
					$modelComment->refresh();

					// Set controller model for post processing
					if( Yii::$app->controller->hasProperty( 'modelComment' ) ) {

						Yii::$app->controller->modelComment = $modelComment;
					}

					// Attach media to comment if allowed and available
					if( $this->media ) {

						$filesCount = count( Yii::$app->request->post( $this->mediaModel ) );

						$files = $this->initFiles( $filesCount );

						if( File::loadMultiple( $files, Yii::$app->request->post(), $this->mediaModel ) && File::validateMultiple( $files ) ) {

							foreach( $files as $file ) {

								$modelCommentService->attachMedia( $modelComment, $file, $this->mediaType, ModelComment::TYPE_COMMENT );
							}
						}
					}

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

			// Generate Validation Errors
			$errors = AjaxUtil::generateErrorMessage( $commentForm );

			// Trigger Ajax Failure
			return AjaxUtil::generateFailure( Yii::$app->coreMessage->getMessage( CoreGlobal::ERROR_REQUEST ), $errors );
		}

		return AjaxUtil::generateFailure( Yii::$app->coreMessage->getMessage( CoreGlobal::ERROR_NOT_FOUND ) );
	}
1304868
protected function createController()
    {
        Artisan::call('make:controller', [
            'name' => $controller = $this->controllerWithoutMethod($this->action())
        ]);
        $this->addMethodToController($controller, $this->controllerMethod($this->action()));
        $this->info('Controller ' . $controller .' created.');
        $this->createView($this->argument('link'));
    }
28160
public function run() {

		try {
			
			//初始化
			$this->init();

			//触发uri路由
			$this->make('router')->dispatch();

			//reset GET
			$_GET = $this->make('router')->getQueryArray();
			foreach ($_GET as $ik => $iv) {
				if (is_string($ik)) {
					$_REQUEST[$ik] = $iv;
				}
			}

			$this->runControllerAction();

			//结束
			$this->finish(0);

		} catch (\Exception $exception) {
			
			if ($this->currentController == null) {
				$this->currentController = new Controller($this, ''); //默认的controller
			}
			
			//触发事件
			$this->eventDispatcher->dispatchEvent(new \Fasim\Event\ExceptionEvent(\Fasim\Event\Event::$EXCEPTION, $exception));

			$config = $this->make('config');
			$view = $this->currentController->getView();
			$view->getLoader()->setPaths([ FS_PATH . 'View' ]);


			$debug = $this->make('config')->get('debug') === true;
			$traceString = str_replace("\n", "<br />\n", $traceString);
			$error = [
				'code' => $exception->getCode(),
				'message' => $exception->getMessage(),
				'file' => $exception->getFile(),
				'line' => $exception->getLine(),
				'trace' => $exception->getTrace()
			];
			$data = [
				'error' => $error,
				'debug' => $debug
			];
			
			if (file_exists(FS_PATH . 'View' . DIRECTORY_SEPARATOR . 'error' . $exception->getCode() . '.html')) {
				echo $view->render('error' . $exception->getCode() . '.html', $data);
			} else {
				echo $view->render('error500.html', $data);
			}
		
			//结束
			$this->finish(-1);
		}
	}
859054
public function init() 
	{
		if(!Yii::app()->user->isGuest) {
			if(Yii::app()->user->level == 1) {
				$arrThemes = $this->currentTemplate('admin');
				Yii::app()->theme = $arrThemes['folder'];
				$this->layout = $arrThemes['layout'];
				$this->moduleHandle = Yii::app()->moduleHandle;
				$this->applyViewPath(__dir__, false);
			}
		} else
			$this->redirect(Yii::app()->createUrl('site/login'));
	}
342773
public function instanceController(): Controller
    {
        $this->sawContainer->setEnvironment(SawEnv::controller());

        return new Controller(
            $this->container->get('WorkCycle'),
            $this->container->get(ControllerCore::class),
            $this->container->get('ControllerServer'),
            $this->container->get(CommandDispatcher::class),
            $this->daemonConfig->getControllerPid() // todo
        );
    }
556571
public function init()
    {
        if (!$this->namespace)
        {
            $this->namespace = \Yii::$app->controller->uniqueId;
        }

        if (!$this->indexUrl && \Yii::$app->controller && isset(\Yii::$app->controller->url))
        {
            $this->indexUrl = \Yii::$app->controller->url;
        }

        if (!$this->indexUrl)
        {
            $this->indexUrl = \Yii::$app->request->url;
        }

        $this->filter;

        if ($classes = ArrayHelper::getValue($this->options, 'class'))
        {
            $this->options = ArrayHelper::merge($this->options, [
                'class' => $classes . 'sx-admin-filters-form form-horizontal'
            ]);
        } else
        {
            $this->options = ArrayHelper::merge($this->options, [
                'class' => 'sx-admin-filters-form form-horizontal'
            ]);
        }



        parent::init();

    }
624469
public function run()
    {
        /** @var Model $model */
        $model = $this->model;
        $options = $this->options;
        unset($options['id']);

        // Add model meta
        $modelClassName = $model::className();
        $modelMeta = $model::meta();
        if (\Yii::$app->has('frontendState')) {
            \Yii::$app->frontendState->set('config.types.metas.' . $modelClassName, $modelMeta);
        } else {
            $jsArgs = [Json::encode($modelClassName), Json::encode($modelMeta)];
            \Yii::$app->view->registerJs('__appTypes.addModelMeta(' . implode(', ', $jsArgs) . ')', View::POS_END, 'app-form-' . $model::className());
        }

        // Add enums
        foreach ($model::meta() as $item) {
            if (!empty($item['enumClassName'])) {
                /** @var Enum $enumClass */
                $enumClass = $item['enumClassName'];
                $enumClassName = $enumClass::className();
                $props = [
                    'labels' => $enumClass::getLabels(),
                ];

                if (\Yii::$app->has('frontendState')) {
                    \Yii::$app->frontendState->set('config.types.enums.' . $enumClassName, $props);
                } else {
                    $jsArgs = [Json::encode($enumClassName), Json::encode($props)];
                    \Yii::$app->view->registerJs('__appTypes.addEnum(' . implode(', ', $jsArgs) . ')', View::POS_END, 'app-enum-' . $enumClass::className());
                }
            }
        }

        // Render field
        $props = array_merge([
            'formId' => $this->field ? $this->field->form->id : 'f' . ++self::$idCounter,
            'model' => $model::className(),
            'prefix' => $model->formName(),
            'attribute' => Html::getAttributeName($this->attribute),
        ], $options);
        if (\Yii::$app->has('frontendState')) {
            \Yii::$app->frontendState->add('config.types.toRenderField', [$this->id, $props]);
        } else {
            $jsArgs = [Json::encode($this->id), Json::encode($props)];
            \Yii::$app->view->registerJs('__appTypes.renderField(' . implode(', ', $jsArgs) . ')', View::POS_END, $this->id);
        }
        return Html::tag('span', '', ['id' => $this->id]);
    }
248020
protected function defaultBaseAuthUrl()
    {
        $baseAuthUrl = [
            Yii::$app->controller->getRoute()
        ];
        $params = $_GET;
        unset($params[$this->clientIdGetParamName]);
        $baseAuthUrl = array_merge($baseAuthUrl, $params);

        return $baseAuthUrl;
    }
1101303
public function actionView()
    {
        $view = Yii::$app->getRequest()->get('type');
        if (isset($view)) {
            Yii::$app->session['view'] = $view;
        }
        $this->goBack( Yii::$app->getRequest()->getHeaders()->get('referer') );
    }
747752
public function getControllerClasses()
    {
        $moduleName = $this->getVarValue('moduleName', false);
    
        return (empty($moduleName) || !Yii::$app->hasModule($moduleName)) ? [] : Yii::$app->getModule($moduleName)->getControllerFiles();
    }