Fields
1 year ago
Payloads
1 year ago
SubjectTransformers
2 years ago
Subjects
5 months ago
ContextFactory.php
2 months ago
WordPressIntegration.php
2 years ago
index.php
3 years ago
WordPressIntegration.php
52 lines
| 1 | <?php declare(strict_types = 1); |
| 2 | |
| 3 | namespace MailPoet\Automation\Integrations\WordPress; |
| 4 | |
| 5 | if (!defined('ABSPATH')) exit; |
| 6 | |
| 7 | |
| 8 | use MailPoet\Automation\Engine\Integration; |
| 9 | use MailPoet\Automation\Engine\Registry; |
| 10 | use MailPoet\Automation\Integrations\WordPress\Subjects\CommentSubject; |
| 11 | use MailPoet\Automation\Integrations\WordPress\Subjects\PostSubject; |
| 12 | use MailPoet\Automation\Integrations\WordPress\Subjects\UserSubject; |
| 13 | use MailPoet\Automation\Integrations\WordPress\SubjectTransformers\CommentSubjectToPostSubjectTransformer; |
| 14 | |
| 15 | class WordPressIntegration implements Integration { |
| 16 | /** @var UserSubject */ |
| 17 | private $userSubject; |
| 18 | |
| 19 | /** @var CommentSubject */ |
| 20 | private $commentSubject; |
| 21 | |
| 22 | /** @var PostSubject */ |
| 23 | private $postSubject; |
| 24 | |
| 25 | private $commentToPost; |
| 26 | |
| 27 | /** @var ContextFactory */ |
| 28 | private $contextFactory; |
| 29 | |
| 30 | public function __construct( |
| 31 | UserSubject $userSubject, |
| 32 | CommentSubject $commentSubject, |
| 33 | PostSubject $postSubject, |
| 34 | CommentSubjectToPostSubjectTransformer $commentToPost, |
| 35 | ContextFactory $contextFactory |
| 36 | ) { |
| 37 | $this->userSubject = $userSubject; |
| 38 | $this->commentSubject = $commentSubject; |
| 39 | $this->postSubject = $postSubject; |
| 40 | $this->commentToPost = $commentToPost; |
| 41 | $this->contextFactory = $contextFactory; |
| 42 | } |
| 43 | |
| 44 | public function register(Registry $registry): void { |
| 45 | $registry->addSubject($this->userSubject); |
| 46 | $registry->addSubject($this->commentSubject); |
| 47 | $registry->addSubject($this->postSubject); |
| 48 | $registry->addSubjectTransformer($this->commentToPost); |
| 49 | $registry->addContextFactory('wordpress', [$this->contextFactory, 'getContextData']); |
| 50 | } |
| 51 | } |
| 52 |