Aucune description

ActionScheduler_LogEntry.php 1.7KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <?php
  2. /**
  3. * Class ActionScheduler_LogEntry
  4. */
  5. class ActionScheduler_LogEntry {
  6. /**
  7. * @var int $action_id
  8. */
  9. protected $action_id = '';
  10. /**
  11. * @var string $message
  12. */
  13. protected $message = '';
  14. /**
  15. * @var Datetime $date
  16. */
  17. protected $date;
  18. /**
  19. * Constructor
  20. *
  21. * @param mixed $action_id Action ID
  22. * @param string $message Message
  23. * @param Datetime $date Datetime object with the time when this log entry was created. If this parameter is
  24. * not provided a new Datetime object (with current time) will be created.
  25. */
  26. public function __construct( $action_id, $message, $date = null ) {
  27. /*
  28. * ActionScheduler_wpCommentLogger::get_entry() previously passed a 3rd param of $comment->comment_type
  29. * to ActionScheduler_LogEntry::__construct(), goodness knows why, and the Follow-up Emails plugin
  30. * hard-codes loading its own version of ActionScheduler_wpCommentLogger with that out-dated method,
  31. * goodness knows why, so we need to guard against that here instead of using a DateTime type declaration
  32. * for the constructor's 3rd param of $date and causing a fatal error with older versions of FUE.
  33. */
  34. if ( null !== $date && ! is_a( $date, 'DateTime' ) ) {
  35. _doing_it_wrong( __METHOD__, 'The third parameter must be a valid DateTime instance, or null.', '2.0.0' );
  36. $date = null;
  37. }
  38. $this->action_id = $action_id;
  39. $this->message = $message;
  40. $this->date = $date ? $date : new Datetime;
  41. }
  42. /**
  43. * Returns the date when this log entry was created
  44. *
  45. * @return Datetime
  46. */
  47. public function get_date() {
  48. return $this->date;
  49. }
  50. public function get_action_id() {
  51. return $this->action_id;
  52. }
  53. public function get_message() {
  54. return $this->message;
  55. }
  56. }