You are here

public function WorkflowState::__construct in Workflow 8

Constructor.

Parameters

array $values:

string $entityType: The name of the new State. If '(creation)', a CreationState is generated.

Overrides ConfigEntityBase::__construct

File

src/Entity/WorkflowState.php, line 120

Class

WorkflowState
Workflow configuration entity to persistently store configuration.

Namespace

Drupal\workflow\Entity

Code

public function __construct(array $values = [], $entityType = 'workflow_state') {

  // Please be aware that $entity_type_id and $entityType are different things!
  $sid = isset($values['id']) ? $values['id'] : '';

  // Keep official name and external name equal. Both are required.
  // @todo Still needed? test import, manual creation, programmatic creation, etc.
  if (!isset($values['label']) && $sid) {
    $values['label'] = $sid;
  }

  // Set default values for '(creation)' state.
  if ($sid == WORKFLOW_CREATION_STATE_NAME) {
    $values['sysid'] = WORKFLOW_CREATION_STATE;
    $values['weight'] = WORKFLOW_CREATION_DEFAULT_WEIGHT;

    // Do not translate the machine_name.
    $values['label'] = $this
      ->t('Creation');
  }
  parent::__construct($values, $entityType);
}