You are here

interface GuardInterface in State Machine 8

Defines the interface for guards.

Allows for custom logic controling the availability of specific transitions. Transitions could be restricted based on the current user's permissions, a parent entity field, etc.

By default, a transition is allowed unless at least one guard returns FALSE.

Hierarchy

Expanded class hierarchy of GuardInterface

All classes that implement GuardInterface

3 files declare their use of GuardInterface
FulfillmentGuard.php in tests/modules/state_machine_test/src/Guard/FulfillmentGuard.php
GenericGuard.php in tests/modules/state_machine_test/src/Guard/GenericGuard.php
WorkflowTest.php in tests/src/Unit/Plugin/Workflow/WorkflowTest.php

File

src/Guard/GuardInterface.php, line 18

Namespace

Drupal\state_machine\Guard
View source
interface GuardInterface {

  /**
   * Checks whether the given transition is allowed.
   *
   * @param \Drupal\state_machine\Plugin\Workflow\WorkflowTransition $transition
   *   The transition.
   * @param \Drupal\state_machine\Plugin\Workflow\WorkflowInterface $workflow
   *   The workflow.
   * @param \Drupal\Core\Entity\EntityInterface $entity
   *   The parent entity.
   *
   * @return bool
   *   TRUE if the transition is allowed, FALSE otherwise.
   */
  public function allowed(WorkflowTransition $transition, WorkflowInterface $workflow, EntityInterface $entity);

}

Members

Namesort descending Modifiers Type Description Overrides
GuardInterface::allowed public function Checks whether the given transition is allowed. 2