CommentPayload.php
1 year ago
PostPayload.php
2 years ago
UserPayload.php
3 years ago
index.php
3 years ago
PostPayload.php
35 lines
| 1 | <?php declare(strict_types = 1); |
| 2 | |
| 3 | namespace MailPoet\Automation\Integrations\WordPress\Payloads; |
| 4 | |
| 5 | if (!defined('ABSPATH')) exit; |
| 6 | |
| 7 | |
| 8 | use MailPoet\Automation\Engine\Integration\Payload; |
| 9 | use MailPoet\Automation\Engine\WordPress; |
| 10 | |
| 11 | class PostPayload implements Payload { |
| 12 | /** @var int */ |
| 13 | private $postId; |
| 14 | |
| 15 | /** @var WordPress */ |
| 16 | private $wp; |
| 17 | |
| 18 | public function __construct( |
| 19 | int $postId, |
| 20 | WordPress $wp |
| 21 | ) { |
| 22 | $this->postId = $postId; |
| 23 | $this->wp = $wp; |
| 24 | } |
| 25 | |
| 26 | public function getPostId(): int { |
| 27 | return $this->postId; |
| 28 | } |
| 29 | |
| 30 | public function getPost(): ?\WP_Post { |
| 31 | $post = $this->wp->getPost($this->postId); |
| 32 | return $post instanceof \WP_Post ? $post : null; |
| 33 | } |
| 34 | } |
| 35 |