Move automation engine code under "Engine" namespace

This is to separate the engine itself from "integrations" that will be
built on top of the engine.

[MAILPOET-4136]
This commit is contained in:
Jan Jakes
2022-02-25 14:24:26 +01:00
committed by Veljko V
parent 4c4e5c7f60
commit da2621230d
22 changed files with 52 additions and 52 deletions

View File

@ -3,7 +3,7 @@
namespace MailPoet\AdminPages\Pages; namespace MailPoet\AdminPages\Pages;
use MailPoet\AdminPages\PageRenderer; use MailPoet\AdminPages\PageRenderer;
use MailPoet\Automation\Migrations\Migrator; use MailPoet\Automation\Engine\Migrations\Migrator;
use MailPoet\WP\Functions as WPFunctions; use MailPoet\WP\Functions as WPFunctions;
class Automation { class Automation {

View File

@ -1,11 +1,11 @@
<?php declare(strict_types = 1); <?php declare(strict_types = 1);
namespace MailPoet\Automation\API; namespace MailPoet\Automation\Engine\API;
use MailPoet\Automation\API\Endpoints\SystemDatabaseEndpoint; use MailPoet\Automation\Engine\API\Endpoints\SystemDatabaseEndpoint;
use MailPoet\Automation\API\Endpoints\WorkflowsEndpoint; use MailPoet\Automation\Engine\API\Endpoints\WorkflowsEndpoint;
use MailPoet\Automation\Exceptions\Exception; use MailPoet\Automation\Engine\Exceptions\Exception;
use MailPoet\Automation\WordPress; use MailPoet\Automation\Engine\WordPress;
use ReflectionClass; use ReflectionClass;
use Throwable; use Throwable;

View File

@ -1,8 +1,8 @@
<?php declare(strict_types = 1); <?php declare(strict_types = 1);
namespace MailPoet\Automation\API; namespace MailPoet\Automation\Engine\API;
use MailPoet\Automation\Exceptions; use MailPoet\Automation\Engine\Exceptions;
abstract class Endpoint { abstract class Endpoint {
public function get(Request $request): Response { public function get(Request $request): Response {

View File

@ -1,6 +1,6 @@
<?php declare(strict_types = 1); <?php declare(strict_types = 1);
namespace MailPoet\Automation\API; namespace MailPoet\Automation\Engine\API;
use MailPoet\InvalidStateException; use MailPoet\InvalidStateException;
use MailPoetVendor\Psr\Container\ContainerInterface; use MailPoetVendor\Psr\Container\ContainerInterface;

View File

@ -1,11 +1,11 @@
<?php declare(strict_types = 1); <?php declare(strict_types = 1);
namespace MailPoet\Automation\API\Endpoints; namespace MailPoet\Automation\Engine\API\Endpoints;
use MailPoet\Automation\API\Endpoint; use MailPoet\Automation\Engine\API\Endpoint;
use MailPoet\Automation\API\Request; use MailPoet\Automation\Engine\API\Request;
use MailPoet\Automation\API\Response; use MailPoet\Automation\Engine\API\Response;
use MailPoet\Automation\Migrations\Migrator; use MailPoet\Automation\Engine\Migrations\Migrator;
use MailPoet\Features\FeatureFlagsController; use MailPoet\Features\FeatureFlagsController;
use MailPoet\Features\FeaturesController; use MailPoet\Features\FeaturesController;

View File

@ -1,10 +1,10 @@
<?php declare(strict_types = 1); <?php declare(strict_types = 1);
namespace MailPoet\Automation\API\Endpoints; namespace MailPoet\Automation\Engine\API\Endpoints;
use MailPoet\Automation\API\Endpoint; use MailPoet\Automation\Engine\API\Endpoint;
use MailPoet\Automation\API\Request; use MailPoet\Automation\Engine\API\Request;
use MailPoet\Automation\API\Response; use MailPoet\Automation\Engine\API\Response;
class WorkflowsEndpoint extends Endpoint { class WorkflowsEndpoint extends Endpoint {
public function get(Request $request): Response { public function get(Request $request): Response {

View File

@ -1,6 +1,6 @@
<?php declare(strict_types = 1); <?php declare(strict_types = 1);
namespace MailPoet\Automation\API; namespace MailPoet\Automation\Engine\API;
class ErrorResponse extends Response { class ErrorResponse extends Response {
public function __construct( public function __construct(

View File

@ -1,8 +1,8 @@
<?php declare(strict_types = 1); <?php declare(strict_types = 1);
namespace MailPoet\Automation\API; namespace MailPoet\Automation\Engine\API;
use MailPoet\Automation\Exceptions; use MailPoet\Automation\Engine\Exceptions;
use WP_REST_Request; use WP_REST_Request;
class Request { class Request {

View File

@ -1,6 +1,6 @@
<?php declare(strict_types = 1); <?php declare(strict_types = 1);
namespace MailPoet\Automation\API; namespace MailPoet\Automation\Engine\API;
use WP_REST_Response; use WP_REST_Response;

View File

@ -1,10 +1,10 @@
<?php declare(strict_types = 1); <?php declare(strict_types = 1);
namespace MailPoet\Automation; namespace MailPoet\Automation\Engine;
use MailPoet\Automation\API\API; use MailPoet\Automation\Engine\API\API;
class Automation { class Engine {
/** @var API */ /** @var API */
private $api; private $api;
@ -16,7 +16,7 @@ class Automation {
public function initialize(): void { public function initialize(): void {
// register Action Scheduler (when behind feature flag, do it only on initialization) // register Action Scheduler (when behind feature flag, do it only on initialization)
require_once __DIR__ . '/../../vendor/woocommerce/action-scheduler/action-scheduler.php'; require_once __DIR__ . '/../../../vendor/woocommerce/action-scheduler/action-scheduler.php';
$this->api->initialize(); $this->api->initialize();
} }

View File

@ -1,9 +1,9 @@
<?php declare(strict_types = 1); <?php declare(strict_types = 1);
namespace MailPoet\Automation; namespace MailPoet\Automation\Engine;
use MailPoet\Automation\Exceptions\InvalidStateException; use MailPoet\Automation\Engine\Exceptions\InvalidStateException;
use MailPoet\Automation\Exceptions\UnexpectedValueException; use MailPoet\Automation\Engine\Exceptions\UnexpectedValueException;
class Exceptions { class Exceptions {
private const MIGRATION_FAILED = 'mailpoet_automation_migration_failed'; private const MIGRATION_FAILED = 'mailpoet_automation_migration_failed';

View File

@ -1,6 +1,6 @@
<?php declare(strict_types = 1); <?php declare(strict_types = 1);
namespace MailPoet\Automation\Exceptions; namespace MailPoet\Automation\Engine\Exceptions;
/** /**
* USE: When an action is forbidden for given actor (although generally valid). * USE: When an action is forbidden for given actor (although generally valid).

View File

@ -1,6 +1,6 @@
<?php declare(strict_types = 1); <?php declare(strict_types = 1);
namespace MailPoet\Automation\Exceptions; namespace MailPoet\Automation\Engine\Exceptions;
/** /**
* USE: When the main action produces conflict (i.e. duplicate key). * USE: When the main action produces conflict (i.e. duplicate key).

View File

@ -1,6 +1,6 @@
<?php declare(strict_types = 1); <?php declare(strict_types = 1);
namespace MailPoet\Automation\Exceptions; namespace MailPoet\Automation\Engine\Exceptions;
use Throwable; use Throwable;

View File

@ -1,6 +1,6 @@
<?php declare(strict_types = 1); <?php declare(strict_types = 1);
namespace MailPoet\Automation\Exceptions; namespace MailPoet\Automation\Engine\Exceptions;
/** /**
* USE: An application state that should not occur. Can be subclassed for feature-specific exceptions. * USE: An application state that should not occur. Can be subclassed for feature-specific exceptions.

View File

@ -1,6 +1,6 @@
<?php declare(strict_types = 1); <?php declare(strict_types = 1);
namespace MailPoet\Automation\Exceptions; namespace MailPoet\Automation\Engine\Exceptions;
/** /**
* USE: When the main resource we're interested in doesn't exist. * USE: When the main resource we're interested in doesn't exist.

View File

@ -1,6 +1,6 @@
<?php declare(strict_types = 1); <?php declare(strict_types = 1);
namespace MailPoet\Automation\Exceptions; namespace MailPoet\Automation\Engine\Exceptions;
/** /**
* USE: Generic runtime error. When possible, use a more specific exception instead. * USE: Generic runtime error. When possible, use a more specific exception instead.

View File

@ -1,6 +1,6 @@
<?php declare(strict_types = 1); <?php declare(strict_types = 1);
namespace MailPoet\Automation\Exceptions; namespace MailPoet\Automation\Engine\Exceptions;
/** /**
* USE: When wrong data VALUE is received. * USE: When wrong data VALUE is received.

View File

@ -1,8 +1,8 @@
<?php declare(strict_types = 1); <?php declare(strict_types = 1);
namespace MailPoet\Automation\Migrations; namespace MailPoet\Automation\Engine\Migrations;
use MailPoet\Automation\Exceptions; use MailPoet\Automation\Engine\Exceptions;
use wpdb; use wpdb;
class Migrator { class Migrator {

View File

@ -1,6 +1,6 @@
<?php declare(strict_types = 1); <?php declare(strict_types = 1);
namespace MailPoet\Automation; namespace MailPoet\Automation\Engine;
class WordPress { class WordPress {
public function addAction(string $hookName, callable $callback, int $priority = 10, int $acceptedArgs = 1): bool { public function addAction(string $hookName, callable $callback, int $priority = 10, int $acceptedArgs = 1): bool {

View File

@ -4,7 +4,7 @@ namespace MailPoet\Config;
use MailPoet\API\JSON\API; use MailPoet\API\JSON\API;
use MailPoet\AutomaticEmails\AutomaticEmails; use MailPoet\AutomaticEmails\AutomaticEmails;
use MailPoet\Automation\Automation; use MailPoet\Automation\Engine\Engine;
use MailPoet\Cron\CronTrigger; use MailPoet\Cron\CronTrigger;
use MailPoet\Features\FeaturesController; use MailPoet\Features\FeaturesController;
use MailPoet\InvalidStateException; use MailPoet\InvalidStateException;
@ -88,8 +88,8 @@ class Initializer {
/** @var SubscriberActivityTracker */ /** @var SubscriberActivityTracker */
private $subscriberActivityTracker; private $subscriberActivityTracker;
/** @var Automation */ /** @var Engine */
private $automation; private $automationEngine;
/** @var FeaturesController */ /** @var FeaturesController */
private $featuresController; private $featuresController;
@ -118,7 +118,7 @@ class Initializer {
AutomaticEmails $automaticEmails, AutomaticEmails $automaticEmails,
SubscriberActivityTracker $subscriberActivityTracker, SubscriberActivityTracker $subscriberActivityTracker,
AssetsLoader $assetsLoader, AssetsLoader $assetsLoader,
Automation $automation, Engine $automationEngine,
FeaturesController $featuresController FeaturesController $featuresController
) { ) {
$this->rendererFactory = $rendererFactory; $this->rendererFactory = $rendererFactory;
@ -142,7 +142,7 @@ class Initializer {
$this->automaticEmails = $automaticEmails; $this->automaticEmails = $automaticEmails;
$this->subscriberActivityTracker = $subscriberActivityTracker; $this->subscriberActivityTracker = $subscriberActivityTracker;
$this->assetsLoader = $assetsLoader; $this->assetsLoader = $assetsLoader;
$this->automation = $automation; $this->automationEngine = $automationEngine;
$this->featuresController = $featuresController; $this->featuresController = $featuresController;
} }
@ -164,7 +164,7 @@ class Initializer {
} }
if ($this->featuresController->isSupported(FeaturesController::AUTOMATION)) { if ($this->featuresController->isSupported(FeaturesController::AUTOMATION)) {
$this->automation->initialize(); $this->automationEngine->initialize();
} }
// activation function // activation function

View File

@ -101,15 +101,15 @@ class ContainerConfigurator implements IContainerConfigurator {
$container->autowire(\MailPoet\AutomaticEmails\WooCommerce\Events\PurchasedInCategory::class)->setPublic(true); $container->autowire(\MailPoet\AutomaticEmails\WooCommerce\Events\PurchasedInCategory::class)->setPublic(true);
$container->autowire(\MailPoet\AutomaticEmails\WooCommerce\Events\PurchasedProduct::class)->setPublic(true); $container->autowire(\MailPoet\AutomaticEmails\WooCommerce\Events\PurchasedProduct::class)->setPublic(true);
// Automation // Automation
$container->autowire(\MailPoet\Automation\API\API::class)->setPublic(true); $container->autowire(\MailPoet\Automation\Engine\API\API::class)->setPublic(true);
$container->autowire(\MailPoet\Automation\API\EndpointFactory::class) $container->autowire(\MailPoet\Automation\Engine\API\EndpointFactory::class)
->setPublic(true) ->setPublic(true)
->setArgument('$container', new Reference(ContainerWrapper::class)); ->setArgument('$container', new Reference(ContainerWrapper::class));
$container->autowire(\MailPoet\Automation\API\Endpoints\SystemDatabaseEndpoint::class)->setPublic(true); $container->autowire(\MailPoet\Automation\Engine\API\Endpoints\SystemDatabaseEndpoint::class)->setPublic(true);
$container->autowire(\MailPoet\Automation\API\Endpoints\WorkflowsEndpoint::class)->setPublic(true); $container->autowire(\MailPoet\Automation\Engine\API\Endpoints\WorkflowsEndpoint::class)->setPublic(true);
$container->autowire(\MailPoet\Automation\Automation::class)->setPublic(true); $container->autowire(\MailPoet\Automation\Engine\Engine::class)->setPublic(true);
$container->autowire(\MailPoet\Automation\Migrations\Migrator::class)->setPublic(true); $container->autowire(\MailPoet\Automation\Engine\Migrations\Migrator::class)->setPublic(true);
$container->autowire(\MailPoet\Automation\WordPress::class)->setPublic(true); $container->autowire(\MailPoet\Automation\Engine\WordPress::class)->setPublic(true);
// Config // Config
$container->autowire(\MailPoet\Config\AccessControl::class)->setPublic(true); $container->autowire(\MailPoet\Config\AccessControl::class)->setPublic(true);
$container->autowire(\MailPoet\Config\Activator::class)->setPublic(true); $container->autowire(\MailPoet\Config\Activator::class)->setPublic(true);