Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

58 lines
1.8KB

  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. }