1: <?php
2: /**
3: * CInlineAction class file.
4: *
5: * @author Qiang Xue <qiang.xue@gmail.com>
6: * @link http://www.yiiframework.com/
7: * @copyright 2008-2013 Yii Software LLC
8: * @license http://www.yiiframework.com/license/
9: */
10:
11:
12: /**
13: * CInlineAction represents an action that is defined as a controller method.
14: *
15: * The method name is like 'actionXYZ' where 'XYZ' stands for the action name.
16: *
17: * @author Qiang Xue <qiang.xue@gmail.com>
18: * @package system.web.actions
19: * @since 1.0
20: */
21: class CInlineAction extends CAction
22: {
23: /**
24: * Runs the action.
25: * The action method defined in the controller is invoked.
26: * This method is required by {@link CAction}.
27: */
28: public function run()
29: {
30: $method='action'.$this->getId();
31: $this->getController()->$method();
32: }
33:
34: /**
35: * Runs the action with the supplied request parameters.
36: * This method is internally called by {@link CController::runAction()}.
37: * @param array $params the request parameters (name=>value)
38: * @return boolean whether the request parameters are valid
39: * @since 1.1.7
40: */
41: public function runWithParams($params)
42: {
43: $methodName='action'.$this->getId();
44: $controller=$this->getController();
45: $method=new ReflectionMethod($controller, $methodName);
46: if($method->getNumberOfParameters()>0)
47: return $this->runWithParamsInternal($controller, $method, $params);
48:
49: $controller->$methodName();
50: return true;
51: }
52: }
53: