You are here

protected function ProcessHighPriorityEntities::processHighPriorityEntity in Acquia Content Hub 8.2

Creates entity if it doesn't exist or returns the existing one.

Parameters

\Acquia\ContentHubClient\CDF\CDFObject $cdf: The imported CDF object.

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

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

\Drupal\depcalc\DependencyStack $stack: The dependency stack from this event.

Throws

\Drupal\Core\Entity\EntityStorageException

\Drupal\Component\Plugin\Exception\PluginNotFoundException

\Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException

1 call to ProcessHighPriorityEntities::processHighPriorityEntity()
ProcessHighPriorityEntities::onImportFailure in src/EventSubscriber/ImportFailure/ProcessHighPriorityEntities.php
Process high priority entities.

File

src/EventSubscriber/ImportFailure/ProcessHighPriorityEntities.php, line 90

Class

ProcessHighPriorityEntities
Class ProcessHighPriorityEntities.

Namespace

Drupal\acquia_contenthub\EventSubscriber\ImportFailure

Code

protected function processHighPriorityEntity(CDFObject $cdf, FailedImportEvent $event, EventDispatcherInterface $dispatcher, DependencyStack $stack) {
  $entity_type = $cdf
    ->getAttribute('entity_type')
    ->getValue()['und'];
  $entity = $this
    ->getEntityRepository()
    ->loadEntityByUuid($entity_type, $cdf
    ->getUuid()) ?? $this
    ->createHighPriorityEntity($cdf, $dispatcher, $stack);
  $wrapper = new DependentEntityWrapper($entity, TRUE);
  $wrapper
    ->setRemoteUuid($cdf
    ->getUuid());
  $event
    ->getStack()
    ->addDependency($wrapper);
}