3 namespace Drupal\Core\Config\Entity;
5 use Drupal\Core\Entity\EntityInterface;
8 * Defines a common interface for configuration entities.
13 interface ConfigEntityInterface extends EntityInterface, ThirdPartySettingsInterface {
16 * Enables the configuration entity.
20 public function enable();
23 * Disables the configuration entity.
27 public function disable();
30 * Sets the status of the configuration entity.
33 * The status of the configuration entity.
37 public function setStatus($status);
40 * Sets the status of the isSyncing flag.
43 * The status of the sync flag.
47 public function setSyncing($status);
50 * Returns whether the configuration entity is enabled.
52 * Status implementations for configuration entities should follow these
54 * - Status does not affect the loading of entities. I.e. Disabling
55 * configuration entities should only have UI/access implications.
56 * - It should only take effect when a 'status' key is explicitly declared
57 * in the entity_keys info of a configuration entity's annotation data.
58 * - Each entity implementation (entity/controller) is responsible for
59 * checking and managing the status.
62 * Whether the entity is enabled or not.
64 public function status();
67 * Returns whether this entity is being changed as part of an import process.
69 * If you are writing code that responds to a change in this entity (insert,
70 * update, delete, presave, etc.), and your code would result in a
71 * configuration change (whether related to this configuration entity, another
72 * configuration entity, or non-entity configuration) or your code would
73 * result in a change to this entity itself, you need to check and see if this
74 * entity change is part of an import process, and skip executing your code if
77 * For example, \Drupal\node\Entity\NodeType::postSave() adds the default body
78 * field to newly created node type configuration entities, which is a
79 * configuration change. You would not want this code to run during an import,
80 * because imported entities were already given the body field when they were
81 * originally created, and the imported configuration includes all of their
82 * currently-configured fields. On the other hand,
83 * \Drupal\field\Entity\FieldStorageConfig::preSave() and the methods it calls
84 * make sure that the storage tables are created or updated for the field
85 * storage configuration entity, which is not a configuration change, and it
86 * must be done whether due to an import or not. So, the first method should
87 * check $entity->isSyncing() and skip executing if it returns TRUE, and the
88 * second should not perform this check.
91 * TRUE if the configuration entity is being created, updated, or deleted
92 * through the import process.
94 public function isSyncing();
97 * Returns whether this entity is being changed during the uninstall process.
99 * If you are writing code that responds to a change in this entity (insert,
100 * update, delete, presave, etc.), and your code would result in a
101 * configuration change (whether related to this configuration entity, another
102 * configuration entity, or non-entity configuration) or your code would
103 * result in a change to this entity itself, you need to check and see if this
104 * entity change is part of an uninstall process, and skip executing your code
105 * if that is the case.
107 * For example, \Drupal\language\Entity\ConfigurableLanguage::preDelete()
108 * prevents the API from deleting the default language. However during an
109 * uninstall of the language module it is expected that the default language
114 public function isUninstalling();
117 * Returns the value of a property.
119 * @param string $property_name
120 * The name of the property that should be returned.
123 * The property if it exists, or NULL otherwise.
125 public function get($property_name);
128 * Sets the value of a property.
130 * @param string $property_name
131 * The name of the property that should be set.
132 * @param mixed $value
133 * The value the property should be set to.
137 public function set($property_name, $value);
140 * Calculates dependencies and stores them in the dependency property.
144 * @see \Drupal\Core\Config\Entity\ConfigDependencyManager
146 public function calculateDependencies();
149 * Informs the entity that entities it depends on will be deleted.
151 * This method allows configuration entities to remove dependencies instead
152 * of being deleted themselves. Configuration entities can use this method to
153 * avoid being unnecessarily deleted during an extension uninstallation.
154 * For example, entity displays remove references to widgets and formatters if
155 * the plugin that supplies them depends on a module that is being
158 * If this method returns TRUE then the entity needs to be re-saved by the
159 * caller for the changes to take effect. Implementations should not save the
162 * @param array $dependencies
163 * An array of dependencies that will be deleted keyed by dependency type.
164 * Dependency types are, for example, entity, module and theme.
167 * TRUE if the entity has been changed as a result, FALSE if not.
169 * @see \Drupal\Core\Config\Entity\ConfigDependencyManager
170 * @see \Drupal\Core\Config\ConfigEntityBase::preDelete()
171 * @see \Drupal\Core\Config\ConfigManager::uninstall()
172 * @see \Drupal\Core\Entity\EntityDisplayBase::onDependencyRemoval()
174 public function onDependencyRemoval(array $dependencies);
177 * Gets the configuration dependencies.
180 * An array of dependencies, keyed by $type.
182 * @see \Drupal\Core\Config\Entity\ConfigDependencyManager
184 public function getDependencies();
187 * Checks whether this entity is installable.
189 * For example, a default view might not be installable if the base table
193 * TRUE if the entity is installable, FALSE otherwise.
195 public function isInstallable();
198 * Sets that the data should be trusted.
200 * If the data is trusted then dependencies will not be calculated on save and
201 * schema will not be used to cast the values. Generally this is only used
202 * during module and theme installation. Once the config entity has been saved
203 * the data will no longer be marked as trusted. This is an optimization for
204 * creation of configuration during installation.
208 * @see \Drupal\Core\Config\ConfigInstaller::createConfiguration()
210 public function trustData();
213 * Gets whether on not the data is trusted.
216 * TRUE if the configuration data is trusted, FALSE if not.
218 public function hasTrustedData();