MissingContentEvent.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <?php
  2. namespace Drupal\Core\Config\Importer;
  3. use Symfony\Component\EventDispatcher\Event;
  4. /**
  5. * Wraps a configuration event for event listeners.
  6. *
  7. * @see \Drupal\Core\Config\Config\ConfigEvents::IMPORT_MISSING_CONTENT
  8. */
  9. class MissingContentEvent extends Event {
  10. /**
  11. * A list of missing content dependencies.
  12. *
  13. * @var array
  14. */
  15. protected $missingContent;
  16. /**
  17. * Constructs a configuration import missing content event object.
  18. *
  19. * @param array $missing_content
  20. * Missing content information.
  21. */
  22. public function __construct(array $missing_content) {
  23. $this->missingContent = $missing_content;
  24. }
  25. /**
  26. * Gets missing content information.
  27. *
  28. * @return array
  29. * A list of missing content dependencies. The array is keyed by UUID. Each
  30. * value is an array with the following keys: 'entity_type', 'bundle' and
  31. * 'uuid'.
  32. */
  33. public function getMissingContent() {
  34. return $this->missingContent;
  35. }
  36. /**
  37. * Resolves the missing content by removing it from the list.
  38. *
  39. * @param string $uuid
  40. * The UUID of the content entity to mark resolved.
  41. *
  42. * @return $this
  43. * The MissingContentEvent object.
  44. */
  45. public function resolveMissingContent($uuid) {
  46. if (isset($this->missingContent[$uuid])) {
  47. unset($this->missingContent[$uuid]);
  48. }
  49. return $this;
  50. }
  51. }