ConfigSchemaDiscovery.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. namespace Drupal\Core\Config\Schema;
  3. use Drupal\Component\Plugin\Discovery\DiscoveryInterface;
  4. use Drupal\Component\Plugin\Discovery\DiscoveryTrait;
  5. use Drupal\Core\Config\StorageInterface;
  6. /**
  7. * Allows YAML files to define config schema types.
  8. */
  9. class ConfigSchemaDiscovery implements DiscoveryInterface {
  10. use DiscoveryTrait;
  11. /**
  12. * A storage instance for reading configuration schema data.
  13. *
  14. * @var \Drupal\Core\Config\StorageInterface
  15. */
  16. protected $schemaStorage;
  17. /**
  18. * Constructs a ConfigSchemaDiscovery object.
  19. *
  20. * @param $schema_storage
  21. * The storage object to use for reading schema data.
  22. */
  23. public function __construct(StorageInterface $schema_storage) {
  24. $this->schemaStorage = $schema_storage;
  25. }
  26. /**
  27. * {@inheritdoc}
  28. */
  29. public function getDefinitions() {
  30. $definitions = [];
  31. foreach ($this->schemaStorage->readMultiple($this->schemaStorage->listAll()) as $schema) {
  32. foreach ($schema as $type => $definition) {
  33. $definitions[$type] = $definition;
  34. }
  35. }
  36. return $definitions;
  37. }
  38. }