您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

InlineAction.php 1.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <?php
  2. /**
  3. * @link http://www.yiiframework.com/
  4. * @copyright Copyright (c) 2008 Yii Software LLC
  5. * @license http://www.yiiframework.com/license/
  6. */
  7. namespace yii\base;
  8. use Yii;
  9. /**
  10. * InlineAction represents an action that is defined as a controller method.
  11. *
  12. * The name of the controller method is available via [[actionMethod]] which
  13. * is set by the [[controller]] who creates this action.
  14. *
  15. * @author Qiang Xue <qiang.xue@gmail.com>
  16. * @since 2.0
  17. */
  18. class InlineAction extends Action
  19. {
  20. /**
  21. * @var string the controller method that this inline action is associated with
  22. */
  23. public $actionMethod;
  24. /**
  25. * @param string $id the ID of this action
  26. * @param Controller $controller the controller that owns this action
  27. * @param string $actionMethod the controller method that this inline action is associated with
  28. * @param array $config name-value pairs that will be used to initialize the object properties
  29. */
  30. public function __construct($id, $controller, $actionMethod, $config = [])
  31. {
  32. $this->actionMethod = $actionMethod;
  33. parent::__construct($id, $controller, $config);
  34. }
  35. /**
  36. * Runs this action with the specified parameters.
  37. * This method is mainly invoked by the controller.
  38. * @param array $params action parameters
  39. * @return mixed the result of the action
  40. */
  41. public function runWithParams($params)
  42. {
  43. $args = $this->controller->bindActionParams($this, $params);
  44. Yii::trace('Running action: ' . get_class($this->controller) . '::' . $this->actionMethod . '()', __METHOD__);
  45. if (Yii::$app->requestedParams === null) {
  46. Yii::$app->requestedParams = $args;
  47. }
  48. return call_user_func_array([$this->controller, $this->actionMethod], $args);
  49. }
  50. }