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