PluginSettingsInterface.php 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. <?php
  2. namespace Drupal\Core\Field;
  3. use Drupal\Component\Plugin\PluginInspectionInterface;
  4. use Drupal\Core\Config\Entity\ThirdPartySettingsInterface;
  5. /**
  6. * Interface definition for plugin with settings.
  7. *
  8. * @deprecated in Drupal 8.1.0 and will be removed before Drupal 9.0.0. Use
  9. * \Drupal\Component\Plugin\ConfigurablePluginInterface instead.
  10. */
  11. interface PluginSettingsInterface extends PluginInspectionInterface, ThirdPartySettingsInterface {
  12. /**
  13. * Defines the default settings for this plugin.
  14. *
  15. * @return array
  16. * A list of default settings, keyed by the setting name.
  17. */
  18. public static function defaultSettings();
  19. /**
  20. * Returns the array of settings, including defaults for missing settings.
  21. *
  22. * @return array
  23. * The array of settings.
  24. */
  25. public function getSettings();
  26. /**
  27. * Returns the value of a setting, or its default value if absent.
  28. *
  29. * @param string $key
  30. * The setting name.
  31. *
  32. * @return mixed
  33. * The setting value.
  34. */
  35. public function getSetting($key);
  36. /**
  37. * Sets the settings for the plugin.
  38. *
  39. * @param array $settings
  40. * The array of settings, keyed by setting names. Missing settings will be
  41. * assigned their default values.
  42. *
  43. * @return $this
  44. */
  45. public function setSettings(array $settings);
  46. /**
  47. * Sets the value of a setting for the plugin.
  48. *
  49. * @param string $key
  50. * The setting name.
  51. * @param mixed $value
  52. * The setting value.
  53. *
  54. * @return $this
  55. */
  56. public function setSetting($key, $value);
  57. /**
  58. * Informs the plugin that some configuration it depends on will be deleted.
  59. *
  60. * This method allows plugins to keep their configuration up-to-date when a
  61. * dependency calculated with ::calculateDependencies() is removed. For
  62. * example, an entity view display contains a formatter having a setting
  63. * pointing to an arbitrary config entity. When that config entity is deleted,
  64. * this method is called by the view display to react to the dependency
  65. * removal by updating its configuration.
  66. *
  67. * This method must return TRUE if the removal event updated the plugin
  68. * configuration or FALSE otherwise.
  69. *
  70. * @param array $dependencies
  71. * An array of dependencies that will be deleted keyed by dependency type.
  72. * Dependency types are 'config', 'content', 'module' and 'theme'.
  73. *
  74. * @return bool
  75. * TRUE if the plugin configuration has changed, FALSE if not.
  76. *
  77. * @see \Drupal\Core\Entity\EntityDisplayBase
  78. */
  79. public function onDependencyRemoval(array $dependencies);
  80. }