← All changes
|
vendor/woocommerce/action-scheduler/classes/actions/ActionScheduler_Action.php
+67
-11
1.5.1
→
trunk
View file →
| @@ -3,12 +3,34 @@ | ||
| 3 | 3 | /** |
| 4 | 4 | * Class ActionScheduler_Action |
| 5 | 5 | */ |
| 6 | 6 | class ActionScheduler_Action { |
| 7 | + /** | |
| 8 | + * Action's hook. | |
| 9 | + * | |
| 10 | + * @var string | |
| 11 | + */ | |
| 7 | 12 | protected $hook = ''; |
| 13 | + | |
| 14 | + /** | |
| 15 | + * Action's args. | |
| 16 | + * | |
| 17 | + * @var array<string, mixed> | |
| 18 | + */ | |
| 8 | 19 | protected $args = array(); |
| 9 | - /** @var ActionScheduler_Schedule */ | |
| 10 | - protected $schedule = NULL; | |
| 20 | + | |
| 21 | + /** | |
| 22 | + * Action's schedule. | |
| 23 | + * | |
| 24 | + * @var ActionScheduler_Schedule | |
| 25 | + */ | |
| 26 | + protected $schedule = null; | |
| 27 | + | |
| 28 | + /** | |
| 29 | + * Action's group. | |
| 30 | + * | |
| 31 | + * @var string | |
| 32 | + */ | |
| 11 | 33 | protected $group = ''; |
| 12 | 34 | |
| 13 | 35 | /** |
| 14 | 36 | * Priorities are conceptually similar to those used for regular WordPress actions. |
| @@ -22,14 +44,22 @@ | ||
| 22 | 44 | * @var int |
| 23 | 45 | */ |
| 24 | 46 | protected $priority = 10; |
| 25 | 47 | |
| 26 | - public function __construct( $hook, array $args = array(), ActionScheduler_Schedule $schedule = NULL, $group = '' ) { | |
| 48 | + /** | |
| 49 | + * Construct. | |
| 50 | + * | |
| 51 | + * @param string $hook Action's hook. | |
| 52 | + * @param mixed[] $args Action's arguments. | |
| 53 | + * @param null|ActionScheduler_Schedule $schedule Action's schedule. | |
| 54 | + * @param string $group Action's group. | |
| 55 | + */ | |
| 56 | + public function __construct( $hook, array $args = array(), ?ActionScheduler_Schedule $schedule = null, $group = '' ) { | |
| 27 | 57 | $schedule = empty( $schedule ) ? new ActionScheduler_NullSchedule() : $schedule; |
| 28 | - $this->set_hook($hook); | |
| 29 | - $this->set_schedule($schedule); | |
| 30 | - $this->set_args($args); | |
| 31 | - $this->set_group($group); | |
| 58 | + $this->set_hook( $hook ); | |
| 59 | + $this->set_schedule( $schedule ); | |
| 60 | + $this->set_args( $args ); | |
| 61 | + $this->set_group( $group ); | |
| 32 | 62 | } |
| 33 | 63 | |
| 34 | 64 | /** |
| 35 | 65 | * Executes the action. |
| @@ -56,23 +86,35 @@ | ||
| 56 | 86 | do_action_ref_array( $hook, array_values( $this->get_args() ) ); |
| 57 | 87 | } |
| 58 | 88 | |
| 59 | 89 | /** |
| 60 | - * @param string $hook | |
| 90 | + * Set action's hook. | |
| 91 | + * | |
| 92 | + * @param string $hook Action's hook. | |
| 61 | 93 | */ |
| 62 | 94 | protected function set_hook( $hook ) { |
| 63 | 95 | $this->hook = $hook; |
| 64 | 96 | } |
| 65 | 97 | |
| 98 | + /** | |
| 99 | + * Get action's hook. | |
| 100 | + */ | |
| 66 | 101 | public function get_hook() { |
| 67 | 102 | return $this->hook; |
| 68 | 103 | } |
| 69 | 104 | |
| 105 | + /** | |
| 106 | + * Set action's schedule. | |
| 107 | + * | |
| 108 | + * @param ActionScheduler_Schedule $schedule Action's schedule. | |
| 109 | + */ | |
| 70 | 110 | protected function set_schedule( ActionScheduler_Schedule $schedule ) { |
| 71 | 111 | $this->schedule = $schedule; |
| 72 | 112 | } |
| 73 | 113 | |
| 74 | 114 | /** |
| 115 | + * Action's schedule. | |
| 116 | + * | |
| 75 | 117 | * @return ActionScheduler_Schedule |
| 76 | 118 | */ |
| 77 | 119 | public function get_schedule() { |
| 78 | 120 | return $this->schedule; |
| @@ -77,18 +119,28 @@ | ||
| 77 | 119 | public function get_schedule() { |
| 78 | 120 | return $this->schedule; |
| 79 | 121 | } |
| 80 | 122 | |
| 123 | + /** | |
| 124 | + * Set action's args. | |
| 125 | + * | |
| 126 | + * @param mixed[] $args Action's arguments. | |
| 127 | + */ | |
| 81 | 128 | protected function set_args( array $args ) { |
| 82 | 129 | $this->args = $args; |
| 83 | 130 | } |
| 84 | 131 | |
| 132 | + /** | |
| 133 | + * Get action's args. | |
| 134 | + */ | |
| 85 | 135 | public function get_args() { |
| 86 | 136 | return $this->args; |
| 87 | 137 | } |
| 88 | 138 | |
| 89 | 139 | /** |
| 90 | - * @param string $group | |
| 140 | + * Section action's group. | |
| 141 | + * | |
| 142 | + * @param string $group Action's group. | |
| 91 | 143 | */ |
| 92 | 144 | protected function set_group( $group ) { |
| 93 | 145 | $this->group = $group; |
| 94 | 146 | } |
| @@ -93,8 +145,10 @@ | ||
| 93 | 145 | $this->group = $group; |
| 94 | 146 | } |
| 95 | 147 | |
| 96 | 148 | /** |
| 149 | + * Action's group. | |
| 150 | + * | |
| 97 | 151 | * @return string |
| 98 | 152 | */ |
| 99 | 153 | public function get_group() { |
| 100 | 154 | return $this->group; |
| @@ -100,12 +154,14 @@ | ||
| 100 | 154 | return $this->group; |
| 101 | 155 | } |
| 102 | 156 | |
| 103 | 157 | /** |
| 104 | - * @return bool If the action has been finished | |
| 158 | + * Action has not finished. | |
| 159 | + * | |
| 160 | + * @return bool | |
| 105 | 161 | */ |
| 106 | 162 | public function is_finished() { |
| 107 | - return FALSE; | |
| 163 | + return false; | |
| 108 | 164 | } |
| 109 | 165 | |
| 110 | 166 | /** |
| 111 | 167 | * Sets the priority of the action. |