Mercurial > hg > cmmr2012-drupal-site
comparison core/lib/Drupal/Core/Entity/SynchronizableInterface.php @ 5:12f9dff5fda9 tip
Update to Drupal core 8.7.1
author | Chris Cannam |
---|---|
date | Thu, 09 May 2019 15:34:47 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
4:a9cd425dd02b | 5:12f9dff5fda9 |
---|---|
1 <?php | |
2 | |
3 namespace Drupal\Core\Entity; | |
4 | |
5 /** | |
6 * Defines methods for an entity that supports synchronization. | |
7 */ | |
8 interface SynchronizableInterface extends EntityInterface { | |
9 | |
10 /** | |
11 * Sets the status of the synchronization flag. | |
12 * | |
13 * @param bool $status | |
14 * The status of the synchronization flag. | |
15 * | |
16 * @return $this | |
17 */ | |
18 public function setSyncing($status); | |
19 | |
20 /** | |
21 * Returns whether this entity is being changed as part of a synchronization. | |
22 * | |
23 * If you are writing code that responds to a change in this entity (insert, | |
24 * update, delete, presave, etc.), and your code would result in a change to | |
25 * this entity itself, a configuration change (whether related to this entity, | |
26 * another entity, or non-entity configuration), you need to check and see if | |
27 * this entity change is part of a synchronization process, and skip executing | |
28 * your code if that is the case. | |
29 * | |
30 * For example, \Drupal\node\Entity\NodeType::postSave() adds the default body | |
31 * field to newly created node type configuration entities, which is a | |
32 * configuration change. You would not want this code to run during an import, | |
33 * because imported entities were already given the body field when they were | |
34 * originally created, and the imported configuration includes all of their | |
35 * currently-configured fields. On the other hand, | |
36 * \Drupal\field\Entity\FieldStorageConfig::preSave() and the methods it calls | |
37 * make sure that the storage tables are created or updated for the field | |
38 * storage configuration entity, which is not a configuration change, and it | |
39 * must be done whether due to an import or not. So, the first method should | |
40 * check $entity->isSyncing() and skip executing if it returns TRUE, and the | |
41 * second should not perform this check. | |
42 * | |
43 * @return bool | |
44 * TRUE if the configuration entity is being created, updated, or deleted | |
45 * through a synchronization process. | |
46 */ | |
47 public function isSyncing(); | |
48 | |
49 } |