* @since 2.0 */ class Action extends Component { /** * @var string ID of the action */ public $id; /** * @var Controller the controller that owns this action */ public $controller; /** * @param string $id the ID of this action * @param Controller $controller the controller that owns this action * @param array $config name-value pairs that will be used to initialize the object properties */ public function __construct($id, $controller, $config = array()) { $this->id = $id; $this->controller = $controller; parent::__construct($config); } /** * Runs this action with the specified parameters. * This method is mainly invoked by the controller. * @param array $params action parameters * @return integer the exit status (0 means normal, non-zero means abnormal). */ public function runWithParams($params) { try { $ps = ReflectionHelper::extractMethodParams($this, 'run', $params); } catch (Exception $e) { $this->controller->invalidActionParams($this, $e); return 1; } if ($params !== $ps) { $this->controller->extraActionParams($this, $ps, $params); } return (int)call_user_func_array(array($this, 'run'), $ps); } }