diff --git a/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php b/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php index 1efa344..ef36dde 100644 --- a/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php +++ b/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php @@ -9,6 +9,7 @@ use Drupal\Core\Entity\EntityStorageInterface; use Drupal\Core\Entity\EntityTypeInterface; use Drupal\Core\Entity\EntityWithPluginCollectionInterface; +use Drupal\Core\Entity\SynchronizableEntityTrait; use Drupal\Core\Plugin\PluginDependencyTrait; /** @@ -21,6 +22,7 @@ use PluginDependencyTrait { addDependency as addDependencyTrait; } + use SynchronizableEntityTrait; /** * The original ID of the configuration entity. @@ -48,14 +50,6 @@ protected $uuid; /** - * Whether the config is being created, updated or deleted through the - * import process. - * - * @var bool - */ - private $isSyncing = FALSE; - - /** * Whether the config is being deleted by the uninstall process. * * @var bool @@ -206,22 +200,6 @@ public function status() { /** * {@inheritdoc} */ - public function setSyncing($syncing) { - $this->isSyncing = $syncing; - - return $this; - } - - /** - * {@inheritdoc} - */ - public function isSyncing() { - return $this->isSyncing; - } - - /** - * {@inheritdoc} - */ public function setUninstalling($uninstalling) { $this->isUninstalling = $uninstalling; } diff --git a/core/lib/Drupal/Core/Entity/ContentEntityBase.php b/core/lib/Drupal/Core/Entity/ContentEntityBase.php index b4d73c0..efbf916 100644 --- a/core/lib/Drupal/Core/Entity/ContentEntityBase.php +++ b/core/lib/Drupal/Core/Entity/ContentEntityBase.php @@ -23,6 +23,7 @@ use EntityChangesDetectionTrait { getFieldsToSkipFromTranslationChangesCheck as traitGetFieldsToSkipFromTranslationChangesCheck; } + use SynchronizableEntityTrait; /** * The plain data values of the contained fields. @@ -177,14 +178,6 @@ protected $enforceRevisionTranslationAffected = []; /** - * Whether this entity is being created, updated or deleted through a - * synchronization process. - * - * @var bool - */ - private $isSyncing = FALSE; - - /** * {@inheritdoc} */ public function __construct(array $values, $entity_type, $bundle = FALSE, $translations = []) { @@ -923,6 +916,7 @@ protected function initializeTranslation($langcode) { $translation->loadedRevisionId = &$this->loadedRevisionId; $translation->isDefaultRevision = &$this->isDefaultRevision; $translation->enforceRevisionTranslationAffected = &$this->enforceRevisionTranslationAffected; + $translation->isSyncing = &$this->isSyncing; return $translation; } @@ -1221,6 +1215,9 @@ public function __clone() { $is_revision_translation_affected_enforced = $this->enforceRevisionTranslationAffected; $this->enforceRevisionTranslationAffected = &$is_revision_translation_affected_enforced; + $is_syncing = $this->isSyncing; + $this->isSyncing = &$is_syncing; + foreach ($this->fields as $name => $fields_by_langcode) { $this->fields[$name] = []; // Untranslatable fields may have multiple references for the same field @@ -1464,20 +1461,4 @@ public function isDefaultTranslationAffectedOnly() { return !empty($bundle_info[$bundle_name]['untranslatable_fields.default_translation_affected']); } - /** - * {@inheritdoc} - */ - public function setSyncing($syncing) { - $this->isSyncing = $syncing; - - return $this; - } - - /** - * {@inheritdoc} - */ - public function isSyncing() { - return $this->isSyncing; - } - } diff --git a/core/lib/Drupal/Core/Entity/SynchronizableEntityTrait.php b/core/lib/Drupal/Core/Entity/SynchronizableEntityTrait.php new file mode 100644 index 0000000..4b7f793 --- /dev/null +++ b/core/lib/Drupal/Core/Entity/SynchronizableEntityTrait.php @@ -0,0 +1,36 @@ +isSyncing = $syncing; + + return $this; + } + + /** + * {@inheritdoc} + */ + public function isSyncing() { + return $this->isSyncing; + } + +}