AbstractAutomationEmbed.php
5 months ago
Automation.php
2 years ago
AutomationAnalytics.php
2 months ago
AutomationEditor.php
2 months ago
AutomationFlowEmbed.php
6 months ago
AutomationPreviewEmbed.php
2 months ago
AutomationTemplates.php
2 years ago
CustomFields.php
2 months ago
DynamicSegments.php
2 months ago
ExperimentalFeatures.php
3 years ago
FormEditor.php
1 week ago
Forms.php
2 months ago
Help.php
2 months ago
Homepage.php
2 years ago
Landingpage.php
2 years ago
Logs.php
1 month ago
NewsletterEditor.php
2 months ago
Newsletters.php
2 months ago
Settings.php
5 months ago
StaticSegments.php
2 months ago
Subscribers.php
1 week ago
SubscribersExport.php
3 years ago
SubscribersImport.php
2 months ago
Tags.php
2 months ago
Upgrade.php
1 year ago
WelcomeWizard.php
2 months ago
WooCommerceSetup.php
2 months ago
index.php
3 years ago
AutomationFlowEmbed.php
88 lines
| 1 | <?php declare(strict_types = 1); |
| 2 | |
| 3 | namespace MailPoet\AdminPages\Pages; |
| 4 | |
| 5 | if (!defined('ABSPATH')) exit; |
| 6 | |
| 7 | |
| 8 | use MailPoet\AdminPages\AssetsController; |
| 9 | use MailPoet\Automation\Engine\Control\SubjectTransformerHandler; |
| 10 | use MailPoet\Automation\Engine\Mappers\AutomationMapper; |
| 11 | use MailPoet\Automation\Engine\Registry; |
| 12 | use MailPoet\Automation\Engine\Storage\AutomationStorage; |
| 13 | use MailPoet\Config\Renderer; |
| 14 | use MailPoet\Config\ServicesChecker; |
| 15 | use MailPoet\Settings\TrackingConfig; |
| 16 | use MailPoet\Util\License\Features\CapabilitiesManager; |
| 17 | use MailPoet\Util\License\Features\Subscribers as SubscribersFeature; |
| 18 | use MailPoet\WooCommerce\Helper as WooCommerceHelper; |
| 19 | use MailPoet\WooCommerce\WooCommerceBookings\Helper as WooCommerceBookingsHelper; |
| 20 | use MailPoet\WooCommerce\WooCommerceSubscriptions\Helper as WooCommerceSubscriptionsHelper; |
| 21 | use MailPoet\WP\Functions as WPFunctions; |
| 22 | |
| 23 | class AutomationFlowEmbed extends AbstractAutomationEmbed { |
| 24 | private AutomationStorage $automationStorage; |
| 25 | private AutomationMapper $automationMapper; |
| 26 | |
| 27 | public function __construct( |
| 28 | AssetsController $assetsController, |
| 29 | Registry $registry, |
| 30 | Renderer $renderer, |
| 31 | TrackingConfig $trackingConfig, |
| 32 | WPFunctions $wp, |
| 33 | SubscribersFeature $subscribersFeature, |
| 34 | CapabilitiesManager $capabilitiesManager, |
| 35 | ServicesChecker $servicesChecker, |
| 36 | WooCommerceHelper $wooCommerceHelper, |
| 37 | WooCommerceSubscriptionsHelper $wooCommerceSubscriptionsHelper, |
| 38 | WooCommerceBookingsHelper $wooCommerceBookingsHelper, |
| 39 | SubjectTransformerHandler $subjectTransformerHandler, |
| 40 | AutomationStorage $automationStorage, |
| 41 | AutomationMapper $automationMapper |
| 42 | ) { |
| 43 | parent::__construct( |
| 44 | $assetsController, |
| 45 | $registry, |
| 46 | $renderer, |
| 47 | $trackingConfig, |
| 48 | $wp, |
| 49 | $subscribersFeature, |
| 50 | $capabilitiesManager, |
| 51 | $servicesChecker, |
| 52 | $wooCommerceHelper, |
| 53 | $wooCommerceSubscriptionsHelper, |
| 54 | $wooCommerceBookingsHelper, |
| 55 | $subjectTransformerHandler |
| 56 | ); |
| 57 | $this->automationStorage = $automationStorage; |
| 58 | $this->automationMapper = $automationMapper; |
| 59 | } |
| 60 | |
| 61 | public function render(): void { |
| 62 | $this->renderEmbed(); |
| 63 | } |
| 64 | |
| 65 | protected function setupDependencies(): void { |
| 66 | $this->assetsController->setupAutomationFlowEmbedDependencies(); |
| 67 | } |
| 68 | |
| 69 | protected function getTemplateName(): string { |
| 70 | return 'automation/flow-embed.html'; |
| 71 | } |
| 72 | |
| 73 | protected function getCustomData(): array { |
| 74 | // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
| 75 | $id = isset($_GET['id']) && is_numeric($_GET['id']) && (int)$_GET['id'] > 0 |
| 76 | ? (int)$_GET['id'] |
| 77 | : null; |
| 78 | |
| 79 | $automation = $id ? $this->automationStorage->getAutomation($id) : null; |
| 80 | $automationData = $automation ? $this->automationMapper->buildAutomation($automation) : null; |
| 81 | |
| 82 | return [ |
| 83 | 'automation_id' => $id, |
| 84 | 'automation' => $automationData, |
| 85 | ]; |
| 86 | } |
| 87 | } |
| 88 |