function Workflow::preSave

Same name in other branches
  1. 8.9.x core/modules/workflows/src/Entity/Workflow.php \Drupal\workflows\Entity\Workflow::preSave()
  2. 10 core/modules/workflows/src/Entity/Workflow.php \Drupal\workflows\Entity\Workflow::preSave()
  3. 11.x core/modules/workflows/src/Entity/Workflow.php \Drupal\workflows\Entity\Workflow::preSave()

Overrides ConfigEntityBase::preSave

File

core/modules/workflows/src/Entity/Workflow.php, line 108

Class

Workflow
Defines the workflow entity.

Namespace

Drupal\workflows\Entity

Code

public function preSave(EntityStorageInterface $storage) {
    $workflow_type = $this->getTypePlugin();
    $missing_states = array_diff($workflow_type->getRequiredStates(), array_keys($this->getTypePlugin()
        ->getStates()));
    if (!empty($missing_states)) {
        throw new RequiredStateMissingException(sprintf("Workflow type '{$workflow_type->label()}' requires states with the ID '%s' in workflow '{$this->id()}'", implode("', '", $missing_states)));
    }
    parent::preSave($storage);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.