RequiredStateMissingException example


  protected $pluginCollection;

  /** * {@inheritdoc} */
  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);
  }

  /** * {@inheritdoc} */
  public function getTypePlugin() {
    return $this->getPluginCollection()->get($this->type);
  }

  
Home | Imprint | This part of the site doesn't use cookies.