function ConfigEntityStorage::save
Same name in other branches
- 8.9.x core/lib/Drupal/Core/Config/Entity/ConfigEntityStorage.php \Drupal\Core\Config\Entity\ConfigEntityStorage::save()
- 10 core/lib/Drupal/Core/Config/Entity/ConfigEntityStorage.php \Drupal\Core\Config\Entity\ConfigEntityStorage::save()
- 11.x core/lib/Drupal/Core/Config/Entity/ConfigEntityStorage.php \Drupal\Core\Config\Entity\ConfigEntityStorage::save()
Implements Drupal\Core\Entity\EntityStorageInterface::save().
Throws
\Drupal\Core\Entity\EntityMalformedException When attempting to save a configuration entity that has no ID.
Overrides EntityStorageBase::save
File
-
core/
lib/ Drupal/ Core/ Config/ Entity/ ConfigEntityStorage.php, line 238
Class
- ConfigEntityStorage
- Defines the storage class for configuration entities.
Namespace
Drupal\Core\Config\EntityCode
public function save(EntityInterface $entity) {
// Configuration entity IDs are strings, and '0' is a valid ID.
$id = $entity->id();
if ($id === NULL || $id === '') {
throw new EntityMalformedException('The entity does not have an ID.');
}
// Check the configuration entity ID length.
// @see \Drupal\Core\Config\Entity\ConfigEntityStorage::MAX_ID_LENGTH
// @todo Consider moving this to a protected method on the parent class, and
// abstracting it for all entity types.
if (strlen($id) > static::MAX_ID_LENGTH) {
throw new ConfigEntityIdLengthException("Configuration entity ID {$id} exceeds maximum allowed length of " . static::MAX_ID_LENGTH . " characters.");
}
return parent::save($entity);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.