File "Hooks.php"

Full Path: /home/warrior1/public_html/wp-content/plugins/mailpoet/lib/Automation/Engine/Hooks.php
File size: 1.77 KB
MIME-type: text/x-php
Charset: utf-8

<?php declare(strict_types = 1);

namespace MailPoet\Automation\Engine;

if (!defined('ABSPATH')) exit;


use MailPoet\Automation\Engine\Data\Step;
use MailPoet\Automation\Engine\Data\Workflow;
use MailPoet\Automation\Engine\Data\WorkflowRunLog;

class Hooks {
  /** @var WordPress */
  private $wordPress;

  public function __construct(
    WordPress $wordPress
  ) {
    $this->wordPress = $wordPress;
  }

  public const INITIALIZE = 'mailpoet/automation/initialize';
  public const API_INITIALIZE = 'mailpoet/automation/api/initialize';
  public const STEP_RUNNER_INITIALIZE = 'mailpoet/automation/step_runner/initialize';
  public const TRIGGER = 'mailpoet/automation/trigger';
  public const WORKFLOW_STEP = 'mailpoet/automation/workflow/step';

  public const EDITOR_BEFORE_LOAD = 'mailpoet/automation/editor/before_load';

  public const WORKFLOW_BEFORE_SAVE = 'mailpoet/automation/workflow/before_save';
  public const WORKFLOW_STEP_BEFORE_SAVE = 'mailpoet/automation/workflow/step/before_save';

  public const WORKFLOW_RUN_LOG_AFTER_STEP_RUN = 'mailpoet/automation/workflow/step/after_run';

  public const WORKFLOW_TEMPLATES = 'mailpoet/automation/workflow/templates';

  public function doWorkflowBeforeSave(Workflow $workflow): void {
    $this->wordPress->doAction(self::WORKFLOW_BEFORE_SAVE, $workflow);
  }

  public function doWorkflowStepBeforeSave(Step $step): void {
    $this->wordPress->doAction(self::WORKFLOW_STEP_BEFORE_SAVE, $step);
  }

  public function doWorkflowStepByKeyBeforeSave(Step $step): void {
    $this->wordPress->doAction(self::WORKFLOW_STEP_BEFORE_SAVE . '/key=' . $step->getKey(), $step);
  }

  public function doWorkflowStepAfterRun(WorkflowRunLog $workflowRunLog): void {
    $this->wordPress->doAction(self::WORKFLOW_RUN_LOG_AFTER_STEP_RUN, $workflowRunLog);
  }
}