You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
			
				
					50 lines
				
				1.5 KiB
			
		
		
			
		
	
	
					50 lines
				
				1.5 KiB
			| 
											14 years ago
										 | <?php
 | ||
|  | /**
 | ||
|  |  * @link http://www.yiiframework.com/
 | ||
| 
											13 years ago
										 |  * @copyright Copyright (c) 2008 Yii Software LLC
 | ||
| 
											14 years ago
										 |  * @license http://www.yiiframework.com/license/
 | ||
|  |  */
 | ||
|  | 
 | ||
| 
											14 years ago
										 | namespace yii\base;
 | ||
| 
											14 years ago
										 | 
 | ||
|  | /**
 | ||
| 
											14 years ago
										 |  * InlineAction represents an action that is defined as a controller method.
 | ||
| 
											14 years ago
										 |  *
 | ||
| 
											13 years ago
										 |  * The name of the controller method is available via [[actionMethod]] which
 | ||
|  |  * is set by the [[controller]] who creates this action.
 | ||
| 
											14 years ago
										 |  *
 | ||
|  |  * @author Qiang Xue <qiang.xue@gmail.com>
 | ||
| 
											14 years ago
										 |  * @since 2.0
 | ||
| 
											14 years ago
										 |  */
 | ||
| 
											14 years ago
										 | class InlineAction extends Action
 | ||
| 
											14 years ago
										 | {
 | ||
|  | 	/**
 | ||
| 
											13 years ago
										 | 	 * @var string the controller method that  this inline action is associated with
 | ||
|  | 	 */
 | ||
|  | 	public $actionMethod;
 | ||
|  | 
 | ||
|  | 	/**
 | ||
|  | 	 * @param string $id the ID of this action
 | ||
|  | 	 * @param Controller $controller the controller that owns this action
 | ||
|  | 	 * @param string $actionMethod the controller method that  this inline action is associated with
 | ||
|  | 	 * @param array $config name-value pairs that will be used to initialize the object properties
 | ||
|  | 	 */
 | ||
|  | 	public function __construct($id, $controller, $actionMethod, $config = array())
 | ||
|  | 	{
 | ||
|  | 		$this->actionMethod = $actionMethod;
 | ||
|  | 		parent::__construct($id, $controller, $config);
 | ||
|  | 	}
 | ||
|  | 
 | ||
|  | 	/**
 | ||
| 
											14 years ago
										 | 	 * 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).
 | ||
| 
											14 years ago
										 | 	 */
 | ||
| 
											14 years ago
										 | 	public function runWithParams($params)
 | ||
| 
											14 years ago
										 | 	{
 | ||
| 
											13 years ago
										 | 		$args = $this->controller->bindActionParams($this, $params);
 | ||
|  | 		return (int)call_user_func_array(array($this->controller, $this->actionMethod), $args);
 | ||
| 
											14 years ago
										 | 	}
 | ||
|  | }
 |