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