FinalMissingContentSubscriber.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php
  2. namespace Drupal\Core\Config\Importer;
  3. use Drupal\Core\Config\ConfigEvents;
  4. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  5. /**
  6. * Final event subscriber to the missing content event.
  7. *
  8. * Ensure that all missing content dependencies are removed from the event so
  9. * the importer can complete.
  10. *
  11. * @see \Drupal\Core\Config\ConfigImporter::processMissingContent()
  12. */
  13. class FinalMissingContentSubscriber implements EventSubscriberInterface {
  14. /**
  15. * Handles the missing content event.
  16. *
  17. * @param \Drupal\Core\Config\Importer\MissingContentEvent $event
  18. * The missing content event.
  19. */
  20. public function onMissingContent(MissingContentEvent $event) {
  21. foreach (array_keys($event->getMissingContent()) as $uuid) {
  22. $event->resolveMissingContent($uuid);
  23. }
  24. }
  25. /**
  26. * {@inheritdoc}
  27. */
  28. public static function getSubscribedEvents() {
  29. // This should always be the final event as it will mark all content
  30. // dependencies as resolved.
  31. $events[ConfigEvents::IMPORT_MISSING_CONTENT][] = ['onMissingContent', -1024];
  32. return $events;
  33. }
  34. }