You are here

public function WorkflowsFieldItem::applyDefaultValue in Workflows Field 2.x

Same name and namespace in other branches
  1. 8 src/Plugin/Field/FieldType/WorkflowsFieldItem.php \Drupal\workflows_field\Plugin\Field\FieldType\WorkflowsFieldItem::applyDefaultValue()

Applies the default value.

Parameters

bool $notify: (optional) Whether to notify the parent object of the change. Defaults to TRUE. If a property is updated from a parent object, set it to FALSE to avoid being notified again.

Return value

$this Returns itself to allow for chaining.

Overrides Map::applyDefaultValue

File

src/Plugin/Field/FieldType/WorkflowsFieldItem.php, line 155

Class

WorkflowsFieldItem
Workflow state field item.

Namespace

Drupal\workflows_field\Plugin\Field\FieldType

Code

public function applyDefaultValue($notify = TRUE) {
  if ($workflow = $this
    ->getWorkflow()) {
    $initial_state = $workflow
      ->getTypePlugin()
      ->getInitialState();
    $this
      ->setValue([
      'value' => $initial_state
        ->id(),
    ], $notify);
  }
  return $this;
}