Нет описания

ActionScheduler_InvalidActionException.php 1.2KB

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