Commit b44b584d authored by alexpott's avatar alexpott

Issue #2054699 by pcambra: Ensure config entity id is set for computed composite ids.

parent e9035a51
......@@ -402,6 +402,11 @@ public function save(EntityInterface $entity) {
$this->configFactory->rename($prefix . $id, $prefix . $entity->id());
}
// Build an ID if none is set.
if (!isset($entity->{$this->idKey})) {
$entity->{$this->idKey} = $entity->id();
}
$entity->preSave($this);
$this->invokeHook('presave', $entity);
......
......@@ -118,17 +118,6 @@ public function id() {
return $this->targetEntityType . '.' . $this->bundle . '.' . $this->mode;
}
/**
* {@inheritdoc}
*/
public function save() {
// Build an ID if none is set.
if (empty($this->id)) {
$this->id = $this->id();
}
return parent::save();
}
/**
* {@inheritdoc}
*/
......
......@@ -359,11 +359,8 @@ protected function saveNew() {
throw new FieldException(format_string('Attempt to create an instance of field @field_id on forbidden entity type @entity_type.', array('@field_id' => $this->field->id, '@entity_type' => $this->entity_type)));
}
// Assign the ID.
$this->id = $this->id();
// Ensure the field instance is unique within the bundle.
if ($prior_instance = $instance_controller->load($this->id)) {
if ($prior_instance = $instance_controller->load($this->id())) {
throw new FieldException(format_string('Attempt to create an instance of field @field_id on bundle @bundle that already has an instance of that field.', array('@field_id' => $this->field->id, '@bundle' => $this->bundle)));
}
......
......@@ -146,17 +146,6 @@ public function id() {
return $this->targetEntityType . '.' . $this->bundle;
}
/**
* {@inheritdoc}
*/
public function save() {
// Build an ID if none is set.
if (empty($this->id)) {
$this->id = $this->id();
}
return parent::save();
}
/**
* {@inheritdoc}
*/
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment