diff --git a/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php b/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php index 0a11098..a988135 100644 --- a/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php +++ b/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php @@ -35,6 +35,14 @@ public $status = TRUE; /** + * Whether the config is being created, updated or deleted through the + * import process. + * + * @var bool + */ + private $isSyncing = FALSE; + + /** * Overrides Entity::__construct(). */ public function __construct(array $values, $entity_type) { @@ -90,21 +98,21 @@ public function set($property_name, $value) { } /** - * Implements \Drupal\Core\Config\Entity\ConfigEntityInterface::enable(). + * {@inheritdoc} */ public function enable() { return $this->setStatus(TRUE); } /** - * Implements \Drupal\Core\Config\Entity\ConfigEntityInterface::disable(). + * {@inheritdoc} */ public function disable() { return $this->setStatus(FALSE); } /** - * Implements \Drupal\Core\Config\Entity\ConfigEntityInterface::setStatus(). + * {@inheritdoc} */ public function setStatus($status) { $this->status = (bool) $status; @@ -112,14 +120,28 @@ public function setStatus($status) { } /** - * Implements \Drupal\Core\Config\Entity\ConfigEntityInterface::status(). + * {@inheritdoc} */ public function status() { return !empty($this->status); } /** - * Overrides Entity::createDuplicate(). + * {@inheritdoc} + */ + public function setSyncing($syncing) { + $this->isSyncing = $syncing; + } + + /** + * {@inheritdoc} + */ + public function isSyncing() { + return $this->isSyncing; + } + + /** + * {@inheritdoc} */ public function createDuplicate() { $duplicate = parent::createDuplicate(); diff --git a/core/lib/Drupal/Core/Config/Entity/ConfigEntityInterface.php b/core/lib/Drupal/Core/Config/Entity/ConfigEntityInterface.php index 78ba566..5aa737d 100644 --- a/core/lib/Drupal/Core/Config/Entity/ConfigEntityInterface.php +++ b/core/lib/Drupal/Core/Config/Entity/ConfigEntityInterface.php @@ -60,6 +60,14 @@ public function disable(); public function setStatus($status); /** + * Sets the status of the isSyncing flag. + * + * @param bool $status + * The status of the sync flag. + */ + public function setSyncing($status); + + /** * Returns whether the configuration entity is enabled. * * Status implementations for configuration entities should follow these @@ -76,6 +84,14 @@ public function setStatus($status); public function status(); /** + * Returns whether the configuration entity is created, updated or deleted + * through the import process. + * + * @return bool + */ + public function isSyncing(); + + /** * Returns the value of a property. * * @param string $property_name diff --git a/core/lib/Drupal/Core/Config/Entity/ConfigStorageController.php b/core/lib/Drupal/Core/Config/Entity/ConfigStorageController.php index 2fd44c4..dfa8198 100644 --- a/core/lib/Drupal/Core/Config/Entity/ConfigStorageController.php +++ b/core/lib/Drupal/Core/Config/Entity/ConfigStorageController.php @@ -484,6 +484,7 @@ public function getQueryServicename() { */ public function importCreate($name, Config $new_config, Config $old_config) { $entity = $this->create($new_config->get()); + $entity->setSyncing(TRUE); $entity->save(); return TRUE; } @@ -504,6 +505,7 @@ public function importCreate($name, Config $new_config, Config $old_config) { public function importUpdate($name, Config $new_config, Config $old_config) { $id = static::getIDFromConfigName($name, $this->entityInfo['config_prefix']); $entity = $this->load($id); + $entity->setSyncing(TRUE); $entity->original = clone $entity; foreach ($old_config->get() as $property => $value) { @@ -534,6 +536,7 @@ public function importUpdate($name, Config $new_config, Config $old_config) { public function importDelete($name, Config $new_config, Config $old_config) { $id = static::getIDFromConfigName($name, $this->entityInfo['config_prefix']); $entity = $this->load($id); + $entity->setSyncing(TRUE); $entity->delete(); return TRUE; } diff --git a/core/modules/node/lib/Drupal/node/Entity/NodeType.php b/core/modules/node/lib/Drupal/node/Entity/NodeType.php index 5bc423e..289dec8 100644 --- a/core/modules/node/lib/Drupal/node/Entity/NodeType.php +++ b/core/modules/node/lib/Drupal/node/Entity/NodeType.php @@ -170,8 +170,9 @@ public function postSave(EntityStorageControllerInterface $storage_controller, $ entity_invoke_bundle_hook('create', 'node', $this->id()); - // Unless disabled, automatically create a Body field for new node types. - if ($this->get('create_body')) { + // Automatically create a Body field for new node types if + // we're not in the syncing process. + if (!$this->isSyncing()) { $label = $this->get('create_body_label'); node_add_body_field($this, $label); }