public function Webform::preSave in Webform 8.5
Same name and namespace in other branches
- 6.x src/Entity/Webform.php \Drupal\webform\Entity\Webform::preSave()
Acts on an entity before the presave hook is invoked.
Used before the entity is saved and before invoking the presave hook.
Ensure that config entities which are bundles of other entities cannot have their ID changed.
Parameters
\Drupal\Core\Entity\EntityStorageInterface $storage: The entity storage object.
Throws
\Drupal\Core\Config\ConfigNameException Thrown when attempting to rename a bundle entity.
Overrides ConfigEntityBundleBase::preSave
File
- src/
Entity/ Webform.php, line 2291
Class
- Webform
- Defines the webform entity.
Namespace
Drupal\webform\EntityCode
public function preSave(EntityStorageInterface $storage) {
// Throw exception when saving overridden webform.
if ($this
->isOverridden()) {
throw new WebformException(sprintf('The %s webform [%s] has overridden settings and/or properties and can not be saved.', $this
->label(), $this
->id()));
}
// Always unpublish templates.
if ($this
->isTemplate()) {
$this
->setStatus(WebformInterface::STATUS_CLOSED);
}
// Serialize elements array to YAML.
if (is_array($this->elements)) {
$this->elements = Yaml::encode($this->elements);
}
parent::preSave($storage);
}