| 1 |
<?php |
| 2 |
|
| 3 |
/** |
| 4 |
* InvalidAction Exception. |
| 5 |
* |
| 6 |
* Used for identifying actions that are invalid in some way. |
| 7 |
* |
| 8 |
* @package ActionScheduler |
| 9 |
*/ |
| 10 |
class ActionScheduler_InvalidActionException extends \InvalidArgumentException implements ActionScheduler_Exception { |
| 11 |
|
| 12 |
/** |
| 13 |
* Create a new exception when the action's schedule cannot be fetched. |
| 14 |
* |
| 15 |
* @param string $action_id The action ID with bad args. |
| 16 |
* @param mixed $schedule Passed schedule. |
| 17 |
* @return static |
| 18 |
*/ |
| 19 |
public static function from_schedule( $action_id, $schedule ) { |
| 20 |
$message = sprintf( |
| 21 |
/* translators: 1: action ID 2: schedule */ |
| 22 |
__( 'Action [%1$s] has an invalid schedule: %2$s', 'action-scheduler' ), |
| 23 |
$action_id, |
| 24 |
var_export( $schedule, true ) // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_var_export |
| 25 |
); |
| 26 |
|
| 27 |
return new static( $message ); |
| 28 |
} |
| 29 |
|
| 30 |
/** |
| 31 |
* Create a new exception when the action's args cannot be decoded to an array. |
| 32 |
* |
| 33 |
* @param string $action_id The action ID with bad args. |
| 34 |
* @param mixed $args Passed arguments. |
| 35 |
* @return static |
| 36 |
*/ |
| 37 |
public static function from_decoding_args( $action_id, $args = array() ) { |
| 38 |
$message = sprintf( |
| 39 |
/* translators: 1: action ID 2: arguments */ |
| 40 |
__( 'Action [%1$s] has invalid arguments. It cannot be JSON decoded to an array. $args = %2$s', 'action-scheduler' ), |
| 41 |
$action_id, |
| 42 |
var_export( $args, true ) // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_var_export |
| 43 |
); |
| 44 |
|
| 45 |
return new static( $message ); |
| 46 |
} |
| 47 |
} |
| 48 |
|