| 1 |
<?php |
| 2 |
|
| 3 |
/** |
| 4 |
* Class ActionScheduler_Action |
| 5 |
*/ |
| 6 |
class ActionScheduler_Action { |
| 7 |
protected $hook = ''; |
| 8 |
protected $args = array(); |
| 9 |
/** |
| 10 |
* @var ActionScheduler_Schedule |
| 11 |
*/ |
| 12 |
protected $schedule = NULL; |
| 13 |
protected $group = ''; |
| 14 |
|
| 15 |
public function __construct( $hook, array $args = array(), ActionScheduler_Schedule $schedule = NULL, $group = '' ) { |
| 16 |
$schedule = empty( $schedule ) ? new ActionScheduler_NullSchedule() : $schedule; |
| 17 |
$this->set_hook($hook); |
| 18 |
$this->set_schedule($schedule); |
| 19 |
$this->set_args($args); |
| 20 |
$this->set_group($group); |
| 21 |
} |
| 22 |
|
| 23 |
public function execute() { |
| 24 |
return do_action_ref_array( $this->get_hook(), array_values( $this->get_args() ) ); |
| 25 |
} |
| 26 |
|
| 27 |
/** |
| 28 |
* @param string $hook |
| 29 |
*/ |
| 30 |
protected function set_hook( $hook ) { |
| 31 |
$this->hook = $hook; |
| 32 |
} |
| 33 |
|
| 34 |
public function get_hook() { |
| 35 |
return $this->hook; |
| 36 |
} |
| 37 |
|
| 38 |
protected function set_schedule( ActionScheduler_Schedule $schedule ) { |
| 39 |
$this->schedule = $schedule; |
| 40 |
} |
| 41 |
|
| 42 |
/** |
| 43 |
* @return ActionScheduler_Schedule |
| 44 |
*/ |
| 45 |
public function get_schedule() { |
| 46 |
return $this->schedule; |
| 47 |
} |
| 48 |
|
| 49 |
protected function set_args( array $args ) { |
| 50 |
$this->args = $args; |
| 51 |
} |
| 52 |
|
| 53 |
public function get_args() { |
| 54 |
return $this->args; |
| 55 |
} |
| 56 |
|
| 57 |
/** |
| 58 |
* @param string $group |
| 59 |
*/ |
| 60 |
protected function set_group( $group ) { |
| 61 |
$this->group = $group; |
| 62 |
} |
| 63 |
|
| 64 |
/** |
| 65 |
* @return string |
| 66 |
*/ |
| 67 |
public function get_group() { |
| 68 |
return $this->group; |
| 69 |
} |
| 70 |
|
| 71 |
/** |
| 72 |
* @return bool If the action has been finished |
| 73 |
*/ |
| 74 |
public function is_finished() { |
| 75 |
return FALSE; |
| 76 |
} |
| 77 |
} |
| 78 |
|