403Webshell
Server IP : 104.21.14.103  /  Your IP : 3.149.243.131
Web Server : LiteSpeed
System : Linux business53.web-hosting.com 4.18.0-553.lve.el8.x86_64 #1 SMP Mon May 27 15:27:34 UTC 2024 x86_64
User : giankuin ( 1871)
PHP Version : 7.4.33
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /proc/self/root/proc/thread-self/root/proc/self/root/proc/self/root/proc/thread-self/root/home/giankuin/thietke365.net/wp-content/plugins/mailpoet/lib/Automation/Engine/Validation/AutomationGraph/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /proc/self/root/proc/thread-self/root/proc/self/root/proc/self/root/proc/thread-self/root/home/giankuin/thietke365.net/wp-content/plugins/mailpoet/lib/Automation/Engine/Validation/AutomationGraph/AutomationWalker.php
<?php declare(strict_types = 1);

namespace MailPoet\Automation\Engine\Validation\AutomationGraph;

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


use Generator;
use MailPoet\Automation\Engine\Data\Automation;
use MailPoet\Automation\Engine\Data\Step;
use MailPoet\Automation\Engine\Exceptions;
use MailPoet\Automation\Engine\Exceptions\InvalidStateException;
use MailPoet\Automation\Engine\Exceptions\UnexpectedValueException;

class AutomationWalker {
  /** @param AutomationNodeVisitor[] $visitors */
  public function walk(Automation $automation, array $visitors = []): void {
    $steps = $automation->getSteps();
    $root = $steps['root'] ?? null;
    if (!$root) {
      throw Exceptions::automationStructureNotValid(__("Automation must contain a 'root' step", 'mailpoet'), 'no-root');
    }

    foreach ($visitors as $visitor) {
      $visitor->initialize($automation);
    }

    foreach ($this->walkStepsDepthFirstPreOrder($steps, $root) as $record) {
      [$step, $parents] = $record;
      foreach ($visitors as $visitor) {
        $visitor->visitNode($automation, new AutomationNode($step, array_values($parents)));
      }
    }

    foreach ($visitors as $visitor) {
      $visitor->complete($automation);
    }
  }

  /**
   * @param array<string|int, Step> $steps
   * @return Generator<array{0: Step, 1: array<string|int, Step>}>
   */
  private function walkStepsDepthFirstPreOrder(array $steps, Step $root): Generator {
    /** @var array{0: Step, 1: array<string|int, Step>}[] $stack */
    $stack = [
      [$root, []],
    ];

    do {
      $record = array_pop($stack);
      if (!$record) {
        throw new InvalidStateException();
      }
      yield $record;
      [$step, $parents] = $record;

      foreach (array_reverse($step->getNextSteps()) as $nextStepData) {
        $nextStepId = $nextStepData->getId();
        $nextStep = $steps[$nextStepId] ?? null;
        if (!$nextStep) {
          throw $this->createStepNotFoundException($nextStepId, $step->getId());
        }

        $nextStepParents = array_merge($parents, [$step->getId() => $step]);
        if (isset($nextStepParents[$nextStepId])) {
          continue; // cycle detected, do not enter the path again
        }
        array_push($stack, [$nextStep, $nextStepParents]);
      }
    } while (count($stack) > 0);
  }

  private function createStepNotFoundException(string $stepId, string $parentStepId): UnexpectedValueException {
    return Exceptions::automationStructureNotValid(
      // translators: %1$s is ID of the step not found, %2$s is ID of the step that references it
      sprintf(
        __("Step with ID '%1\$s' not found (referenced from '%2\$s')", 'mailpoet'),
        $stepId,
        $parentStepId
      ),
      'step-not-found'
    );
  }
}

Youez - 2016 - github.com/yon3zu
LinuXploit