ConfigEntityInterface.php 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. <?php
  2. namespace Drupal\Core\Config\Entity;
  3. use Drupal\Core\Entity\EntityInterface;
  4. use Drupal\Core\Entity\SynchronizableInterface;
  5. /**
  6. * Defines a common interface for configuration entities.
  7. *
  8. * @ingroup config_api
  9. * @ingroup entity_api
  10. */
  11. interface ConfigEntityInterface extends EntityInterface, ThirdPartySettingsInterface, SynchronizableInterface {
  12. /**
  13. * Enables the configuration entity.
  14. *
  15. * @return $this
  16. */
  17. public function enable();
  18. /**
  19. * Disables the configuration entity.
  20. *
  21. * @return $this
  22. */
  23. public function disable();
  24. /**
  25. * Sets the status of the configuration entity.
  26. *
  27. * @param bool $status
  28. * The status of the configuration entity.
  29. *
  30. * @return $this
  31. */
  32. public function setStatus($status);
  33. /**
  34. * Returns whether the configuration entity is enabled.
  35. *
  36. * Status implementations for configuration entities should follow these
  37. * general rules:
  38. * - Status does not affect the loading of entities. I.e. Disabling
  39. * configuration entities should only have UI/access implications.
  40. * - It should only take effect when a 'status' key is explicitly declared
  41. * in the entity_keys info of a configuration entity's annotation data.
  42. * - Each entity implementation (entity/controller) is responsible for
  43. * checking and managing the status.
  44. *
  45. * @return bool
  46. * Whether the entity is enabled or not.
  47. */
  48. public function status();
  49. /**
  50. * Returns whether this entity is being changed during the uninstall process.
  51. *
  52. * If you are writing code that responds to a change in this entity (insert,
  53. * update, delete, presave, etc.), and your code would result in a
  54. * configuration change (whether related to this configuration entity, another
  55. * configuration entity, or non-entity configuration) or your code would
  56. * result in a change to this entity itself, you need to check and see if this
  57. * entity change is part of an uninstall process, and skip executing your code
  58. * if that is the case.
  59. *
  60. * For example, \Drupal\language\Entity\ConfigurableLanguage::preDelete()
  61. * prevents the API from deleting the default language. However during an
  62. * uninstall of the language module it is expected that the default language
  63. * should be deleted.
  64. *
  65. * @return bool
  66. */
  67. public function isUninstalling();
  68. /**
  69. * Returns the value of a property.
  70. *
  71. * @param string $property_name
  72. * The name of the property that should be returned.
  73. *
  74. * @return mixed
  75. * The property if it exists, or NULL otherwise.
  76. */
  77. public function get($property_name);
  78. /**
  79. * Sets the value of a property.
  80. *
  81. * @param string $property_name
  82. * The name of the property that should be set.
  83. * @param mixed $value
  84. * The value the property should be set to.
  85. *
  86. * @return $this
  87. */
  88. public function set($property_name, $value);
  89. /**
  90. * Calculates dependencies and stores them in the dependency property.
  91. *
  92. * @return $this
  93. *
  94. * @see \Drupal\Core\Config\Entity\ConfigDependencyManager
  95. */
  96. public function calculateDependencies();
  97. /**
  98. * Informs the entity that entities it depends on will be deleted.
  99. *
  100. * This method allows configuration entities to remove dependencies instead
  101. * of being deleted themselves. Configuration entities can use this method to
  102. * avoid being unnecessarily deleted during an extension uninstallation.
  103. * For example, entity displays remove references to widgets and formatters if
  104. * the plugin that supplies them depends on a module that is being
  105. * uninstalled.
  106. *
  107. * If this method returns TRUE then the entity needs to be re-saved by the
  108. * caller for the changes to take effect. Implementations should not save the
  109. * entity.
  110. *
  111. * @param array $dependencies
  112. * An array of dependencies that will be deleted keyed by dependency type.
  113. * Dependency types are, for example, entity, module and theme.
  114. *
  115. * @return bool
  116. * TRUE if the entity has been changed as a result, FALSE if not.
  117. *
  118. * @see \Drupal\Core\Config\Entity\ConfigDependencyManager
  119. * @see \Drupal\Core\Config\ConfigEntityBase::preDelete()
  120. * @see \Drupal\Core\Config\ConfigManager::uninstall()
  121. * @see \Drupal\Core\Entity\EntityDisplayBase::onDependencyRemoval()
  122. */
  123. public function onDependencyRemoval(array $dependencies);
  124. /**
  125. * Gets the configuration dependencies.
  126. *
  127. * @return array
  128. * An array of dependencies, keyed by $type.
  129. *
  130. * @see \Drupal\Core\Config\Entity\ConfigDependencyManager
  131. */
  132. public function getDependencies();
  133. /**
  134. * Checks whether this entity is installable.
  135. *
  136. * For example, a default view might not be installable if the base table
  137. * doesn't exist.
  138. *
  139. * @return bool
  140. * TRUE if the entity is installable, FALSE otherwise.
  141. */
  142. public function isInstallable();
  143. /**
  144. * Sets that the data should be trusted.
  145. *
  146. * If the data is trusted then dependencies will not be calculated on save and
  147. * schema will not be used to cast the values. Generally this is only used
  148. * during module and theme installation. Once the config entity has been saved
  149. * the data will no longer be marked as trusted. This is an optimization for
  150. * creation of configuration during installation.
  151. *
  152. * @return $this
  153. *
  154. * @see \Drupal\Core\Config\ConfigInstaller::createConfiguration()
  155. */
  156. public function trustData();
  157. /**
  158. * Gets whether on not the data is trusted.
  159. *
  160. * @return bool
  161. * TRUE if the configuration data is trusted, FALSE if not.
  162. */
  163. public function hasTrustedData();
  164. }