You are here

public static function ScheduledTransition::createFrom in Scheduled Transitions 2.x

Creates a new Scheduled Transition from known common metadata.

Language code and revision ID are set with $revision context.

Parameters

\Drupal\workflows\WorkflowInterface $workflow: The workflow.

string $state: The state ID.

\Drupal\Core\Entity\RevisionableInterface $revision: Set the revision this scheduled transition is for.

\DateTimeInterface $dateTime: The transition date.

\Drupal\Core\Session\AccountInterface $author: The scheduled transition author.

Return value

static A new unsaved Scheduled Transition.

Overrides ScheduledTransitionInterface::createFrom

2 calls to ScheduledTransition::createFrom()
ScheduledTransitionTest::testChangedTimeUpdated in tests/src/Kernel/ScheduledTransitionTest.php
Test the changed timestamp is updated when a transition is executed.
ScheduledTransitionTest::testTransitionNoFieldChanges in tests/src/Kernel/ScheduledTransitionTest.php
Tests no pending revisions after transition on revision w/no field changes.

File

src/Entity/ScheduledTransition.php, line 136

Class

ScheduledTransition
Scheduled Transition entity.

Namespace

Drupal\scheduled_transitions\Entity

Code

public static function createFrom(WorkflowInterface $workflow, string $state, RevisionableInterface $revision, \DateTimeInterface $dateTime, AccountInterface $author) {

  /** @var static $scheduledTransition */
  $scheduledTransition = static::create();
  $scheduledTransition
    ->setState($workflow, $state)
    ->setEntity($revision)
    ->setTransitionDate($dateTime)
    ->setAuthor($author);
  return $scheduledTransition;
}