|--- yii\base\BaseObject |--- Component |--- Action <-- 本节 |--- InlineAction
|--- Controller |--- ErrorHandler |--- Model |--- DynamicModel
|--- Request |--- Response |--- Security |--- Theme |--- View |--- Widget |--- yii\di\ServiceLocator |--- Module |--- Application
|--- Behavior |--- ActionFilter
|--- Event |--- ActionEvent |--- ModelEvent |--- ViewEvent |--- WidgetEvent
|
|--- \ErrorException |--- ErrorException
|--- \Exception |--- Exception |--- InvalidConfigException |--- UserException |--- InvalidRouteException
|--- NotSupportedException |--- UnknownClassException |--- UnknownPropertyException
|--- ExitException
|--- \BadMethodCallException |--- InvalidParamException |--- InvalidArgumentException |--- ViewNotFoundException
|--- InvalidCallException |--- UnknownMethodException
|--- \UnexpectedValueException |--- InvalidValueException
|
Action
Action is the base class for all controller action classes.
Action 提供了一种重用 action method code。Action 类中的 action 方法可以在多个控制器或不同的项目中使用。
派生类必须实现名为 run()
的方法。这个方法将在请求动作时被控制器调用。
run()
方法可以具有参数,这些参数将根据其名称自动填充用户输入值。
public function run($id, $type = 'book') { ... }
|
属性:
@property-read string $uniqueId
this action 在整个应用程序中的唯一 ID。
public function runWithParams($params) { if (!method_exists($this, 'run')) { throw new InvalidConfigException(get_class($this) . ' must define a "run()" method.'); } $args = $this->controller->bindActionParams($this, $params); Yii::debug('Running action: ' . get_class($this) . '::run(), invoked by ' . get_class($this->controller), __METHOD__); if (Yii::$app->requestedParams === null) { Yii::$app->requestedParams = $args; } if ($this->beforeRun()) { $result = call_user_func_array([$this, 'run'], $args); $this->afterRun();
return $result; }
return null; }
|
未完
– EOF –