TypedConfigManagerInterface.php 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. <?php
  2. namespace Drupal\Core\Config;
  3. use Drupal\Core\TypedData\TypedDataManagerInterface;
  4. /**
  5. * Defines an interface for managing config schema type plugins.
  6. *
  7. * @see \Drupal\Core\Config\TypedConfigManager
  8. * @see \Drupal\Core\Config\Schema\ConfigSchemaDiscovery
  9. * @see hook_config_schema_info_alter()
  10. * @see https://www.drupal.org/node/1905070
  11. */
  12. interface TypedConfigManagerInterface extends TypedDataManagerInterface {
  13. /**
  14. * Gets typed configuration data.
  15. *
  16. * @param string $name
  17. * Configuration object name.
  18. *
  19. * @return \Drupal\Core\TypedData\TraversableTypedDataInterface
  20. * Typed configuration element.
  21. */
  22. public function get($name);
  23. /**
  24. * Creates a new data definition object from a type definition array and
  25. * actual configuration data. Since type definitions may contain variables
  26. * to be replaced, we need the configuration value to create it.
  27. *
  28. * @param array $definition
  29. * The base type definition array, for which a data definition should be
  30. * created.
  31. * @param $value
  32. * Optional value of the configuration element.
  33. * @param string $name
  34. * Optional name of the configuration element.
  35. * @param object $parent
  36. * Optional parent element.
  37. *
  38. * @return \Drupal\Core\TypedData\DataDefinitionInterface
  39. * A data definition for the given data type.
  40. */
  41. public function buildDataDefinition(array $definition, $value, $name = NULL, $parent = NULL);
  42. /**
  43. * Checks if the configuration schema with the given config name exists.
  44. *
  45. * @param string $name
  46. * Configuration name.
  47. *
  48. * @return bool
  49. * TRUE if configuration schema exists, FALSE otherwise.
  50. */
  51. public function hasConfigSchema($name);
  52. /**
  53. * Gets a specific plugin definition.
  54. *
  55. * @param string $plugin_id
  56. * A plugin id.
  57. * @param bool $exception_on_invalid
  58. * Ignored with TypedConfigManagerInterface. Kept for compatibility with
  59. * DiscoveryInterface.
  60. *
  61. * @return array
  62. * A plugin definition array. If the given plugin id does not have typed
  63. * configuration definition assigned, the definition of an undefined
  64. * element type is returned.
  65. */
  66. public function getDefinition($plugin_id, $exception_on_invalid = TRUE);
  67. /**
  68. * Gets typed data for a given configuration name and its values.
  69. *
  70. * @param string $config_name
  71. * The machine name of the configuration.
  72. * @param array $config_data
  73. * The data associated with the configuration. Note: This configuration
  74. * doesn't yet have to be stored.
  75. *
  76. * @return \Drupal\Core\TypedData\TraversableTypedDataInterface
  77. * The typed configuration element.
  78. */
  79. public function createFromNameAndData($config_name, array $config_data);
  80. }