You are here

public function CreateStubs::onImportFailure in Acquia Content Hub 8.2

Generate stub entities for all remaining content entities and reimports.

Parameters

\Drupal\acquia_contenthub\Event\FailedImportEvent $event: The failure event.

string $event_name: The event name.

\Symfony\Component\EventDispatcher\EventDispatcherInterface $dispatcher: The event dispatcher.

File

src/EventSubscriber/ImportFailure/CreateStubs.php, line 61

Class

CreateStubs
Class CreateStubs.

Namespace

Drupal\acquia_contenthub\EventSubscriber\ImportFailure

Code

public function onImportFailure(FailedImportEvent $event, string $event_name, EventDispatcherInterface $dispatcher) {
  if (static::$count === $event
    ->getCount()) {
    $exception = new \Exception("Potential infinite recursion call interrupted in CreateStubs event subscriber.");
    $event
      ->setException($exception);
    return;
  }
  static::$count = $event
    ->getCount();
  $unprocessed = array_diff(array_keys($event
    ->getCdf()
    ->getEntities()), array_keys($event
    ->getStack()
    ->getDependencies()));
  if (!$unprocessed) {
    $event
      ->stopPropagation();
    return;
  }
  if (!$event
    ->getSerializer()
    ->getTracker()
    ->isTracking()) {
    $event
      ->getSerializer()
      ->getTracker()
      ->setStack($event
      ->getStack());
  }
  $this
    ->handleEntityProcessing($unprocessed, $event, $dispatcher);
  static::$count = 0;
}