PHP 8.2.31
Preview: UpdateStepsController.php Size: 1.08 KB
/home/nshryvcy/himaltourism.com/wp-content/plugins/mailpoet/lib/Automation/Engine/Builder/UpdateStepsController.php

<?php declare(strict_types = 1);

namespace MailPoet\Automation\Engine\Builder;

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


use MailPoet\Automation\Engine\Data\Automation;
use MailPoet\Automation\Engine\Data\Step;
use MailPoet\Automation\Engine\Exceptions;
use MailPoet\Automation\Engine\Registry;

class UpdateStepsController {
  /** @var Registry */
  private $registry;

  public function __construct(
    Registry $registry
  ) {
    $this->registry = $registry;
  }

  public function updateSteps(Automation $automation, array $data): Automation {
    $steps = [];
    foreach ($data as $index => $stepData) {
      $step = $this->processStep($stepData, $automation->getStep($stepData['id']));
      $steps[$index] = $step;
    }
    $automation->setSteps($steps);
    return $automation;
  }

  private function processStep(array $data, ?Step $existingStep): Step {
    $key = $data['key'];
    $step = $this->registry->getStep($key);
    if (!$step && $existingStep && $data !== $existingStep->toArray()) {
      throw Exceptions::automationStepNotFound($key);
    }
    return Step::fromArray($data);
  }
}

Directory Contents

Dirs: 0 × Files: 6

Name Size Perms Modified Actions
1.55 KB lrw-r--r-- 2023-04-04 05:35:40
Edit Download
912 B lrw-r--r-- 2023-04-04 05:35:40
Edit Download
2.67 KB lrw-r--r-- 2023-04-04 05:35:40
Edit Download
0 B lrw-r--r-- 2023-04-04 05:35:40
Edit Download
4.36 KB lrw-r--r-- 2023-04-04 05:35:40
Edit Download
1.08 KB lrw-r--r-- 2023-04-04 05:35:40
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).