You are here

protected function SchedulerUiTrait::createEditorialWorkflow in Lightning Scheduler 8

Creates the editorial workflow.

Return value

\Drupal\workflows\WorkflowInterface The editorial workflow entity.

5 calls to SchedulerUiTrait::createEditorialWorkflow()
InlineEntityFormTest::setUp in tests/src/Functional/InlineEntityFormTest.php
ScheduledTransitionTest::setUp in tests/src/Functional/ScheduledTransitionTest.php
TimeStepTest::testTimeSteps in tests/src/FunctionalJavascript/TimeStepTest.php
Tests the time steps.
TransitionTest::setUp in tests/src/FunctionalJavascript/TransitionTest.php
UiTest::testUi in tests/src/FunctionalJavascript/UiTest.php

File

tests/src/Traits/SchedulerUiTrait.php, line 126

Class

SchedulerUiTrait
Contains methods for interacting with the scheduler UI.

Namespace

Drupal\Tests\lightning_scheduler\Traits

Code

protected function createEditorialWorkflow() {
  $workflow = Workflow::create([
    'type' => 'content_moderation',
    'id' => 'editorial',
    'label' => 'Editorial',
    'type_settings' => [
      'states' => [
        'archived' => [
          'label' => 'Archived',
          'weight' => 5,
          'published' => FALSE,
          'default_revision' => TRUE,
        ],
        'draft' => [
          'label' => 'Draft',
          'published' => FALSE,
          'default_revision' => FALSE,
          'weight' => -5,
        ],
        'published' => [
          'label' => 'Published',
          'published' => TRUE,
          'default_revision' => TRUE,
          'weight' => 0,
        ],
        'review' => [
          'label' => 'In review',
          'weight' => -1,
          'published' => FALSE,
          'default_revision' => FALSE,
        ],
      ],
      'transitions' => [
        'archive' => [
          'label' => 'Archive',
          'from' => [
            'published',
          ],
          'to' => 'archived',
          'weight' => 2,
        ],
        'archived_published' => [
          'label' => 'Restore from archive',
          'from' => [
            'archived',
          ],
          'to' => 'published',
          'weight' => 4,
        ],
        'create_new_draft' => [
          'label' => 'Create New Draft',
          'to' => 'draft',
          'weight' => 0,
          'from' => [
            'archived',
            'draft',
            'published',
            'review',
          ],
        ],
        'publish' => [
          'label' => 'Publish',
          'to' => 'published',
          'weight' => 1,
          'from' => [
            'draft',
            'published',
            'review',
          ],
        ],
        'review' => [
          'label' => 'Send to review',
          'to' => 'review',
          'weight' => 0,
          'from' => [
            'draft',
            'review',
          ],
        ],
      ],
    ],
  ]);
  $workflow
    ->save();
  return $workflow;
}