You are here

interface StateItemInterface in State Machine 8

Defines the interface for state field items.

Hierarchy

Expanded class hierarchy of StateItemInterface

All classes that implement StateItemInterface

File

src/Plugin/Field/FieldType/StateItemInterface.php, line 11

Namespace

Drupal\state_machine\Plugin\Field\FieldType
View source
interface StateItemInterface extends FieldItemInterface {

  /**
   * Gets the workflow used by the field.
   *
   * @return \Drupal\state_machine\Plugin\Workflow\WorkflowInterface|false
   *   The workflow, or FALSE if unknown at this time.
   */
  public function getWorkflow();

  /**
   * Gets the original state ID.
   *
   * If the state ID has been changed after the entity was constructed/loaded,
   * the original ID will hold the previous value.
   *
   * Use this as an alternative to getting the state ID from $entity->original.
   *
   * @return string
   *   The original state ID.
   */
  public function getOriginalId();

  /**
   * Gets the current state ID.
   *
   * @return string
   *   The current state ID.
   */
  public function getId();

  /**
   * Gets the label of the current state.
   *
   * @return string
   *   The label of the current state.
   */
  public function getLabel();

  /**
   * Gets the label of the original state.
   *
   * @return string
   *   The label of the original state.
   */
  public function getOriginalLabel();

  /**
   * Gets the allowed transitions for the current state.
   *
   * @return \Drupal\state_machine\Plugin\Workflow\WorkflowTransition[]
   *   The allowed transitions, keyed by transition ID.
   */
  public function getTransitions();

  /**
   * Gets whether the given transition is allowed.
   *
   * @param string $transition_id
   *   The transition ID.
   *
   * @return bool
   *   TRUE if the given transition is allowed, FALSE otherwise.
   */
  public function isTransitionAllowed($transition_id);

  /**
   * Applies the given transition, changing the current state.
   *
   * @param \Drupal\state_machine\Plugin\Workflow\WorkflowTransition $transition
   *   The transition to apply.
   *
   * @throws \InvalidArgumentException
   *   Thrown when the transition is not allowed.
   */
  public function applyTransition(WorkflowTransition $transition);

  /**
   * Applies a transition with the given ID, changing the current state.
   *
   * @param string $transition_id
   *   The transition ID.
   *
   * @throws \InvalidArgumentException
   *   Thrown when no matching transition was found.
   */
  public function applyTransitionById($transition_id);

  /**
   * Gets whether the current state is valid.
   *
   * Drupal separates field validation into a separate step, allowing an
   * invalid state to be set before validation is invoked. At that point
   * validation has no access to the previous value, so it can't determine
   * if the transition is allowed. Thus, the field item must track the state
   * changes internally, and answer via this method if the current state is
   * valid.
   *
   * @see \Drupal\state_machine\Plugin\Validation\Constraint\StateConstraintValidator
   *
   * @return bool
   *   TRUE if the current state is valid, FALSE otherwise.
   */
  public function isValid();

}

Members

Namesort descending Modifiers Type Description Overrides
ComplexDataInterface::get public function Gets a property object. 2
ComplexDataInterface::getDataDefinition public function Gets the data definition. Overrides TypedDataInterface::getDataDefinition
ComplexDataInterface::getProperties public function Gets an array of property objects. 3
ComplexDataInterface::isEmpty public function Determines whether the data structure is empty. 2
ComplexDataInterface::set public function Sets a property value. 3
ComplexDataInterface::toArray public function Returns an array of all property values. 2
FieldItemInterface::calculateDependencies public static function Calculates dependencies for field items. 1
FieldItemInterface::calculateStorageDependencies public static function Calculates dependencies for field items on the storage level. 1
FieldItemInterface::defaultFieldSettings public static function Defines the field-level settings for this plugin. 1
FieldItemInterface::defaultStorageSettings public static function Defines the storage-level settings for this plugin. 1
FieldItemInterface::delete public function Defines custom delete behavior for field values. 1
FieldItemInterface::deleteRevision public function Defines custom revision delete behavior for field values. 1
FieldItemInterface::fieldSettingsForm public function Returns a form for the field-level settings. 1
FieldItemInterface::fieldSettingsFromConfigData public static function Returns a settings array in the field type's canonical representation. 1
FieldItemInterface::fieldSettingsToConfigData public static function Returns a settings array that can be stored as a configuration value. 1
FieldItemInterface::generateSampleValue public static function Generates placeholder field values. 1
FieldItemInterface::getEntity public function Gets the entity that field belongs to. 1
FieldItemInterface::getFieldDefinition public function Gets the field definition. 1
FieldItemInterface::getLangcode public function Gets the langcode of the field values held in the object. 1
FieldItemInterface::mainPropertyName public static function Returns the name of the main property, if any. 1
FieldItemInterface::onDependencyRemoval public static function Informs the plugin that a dependency of the field will be deleted. 1
FieldItemInterface::postSave public function Defines custom post-save behavior for field values. 1
FieldItemInterface::preSave public function Defines custom presave behavior for field values. 1
FieldItemInterface::propertyDefinitions public static function Defines field item properties. 28
FieldItemInterface::schema public static function Returns the schema for the field. 31
FieldItemInterface::storageSettingsForm public function Returns a form for the storage-level settings. 1
FieldItemInterface::storageSettingsFromConfigData public static function Returns a settings array in the field type's canonical representation. 1
FieldItemInterface::storageSettingsToConfigData public static function Returns a settings array that can be stored as a configuration value. 1
FieldItemInterface::view public function Returns a renderable array for a single field item. 1
FieldItemInterface::__get public function Magic method: Gets a property value. 1
FieldItemInterface::__isset public function Magic method: Determines whether a property is set. 1
FieldItemInterface::__set public function Magic method: Sets a property value. 1
FieldItemInterface::__unset public function Magic method: Unsets a property. 1
StateItemInterface::applyTransition public function Applies the given transition, changing the current state. 1
StateItemInterface::applyTransitionById public function Applies a transition with the given ID, changing the current state. 1
StateItemInterface::getId public function Gets the current state ID. 1
StateItemInterface::getLabel public function Gets the label of the current state. 1
StateItemInterface::getOriginalId public function Gets the original state ID. 1
StateItemInterface::getOriginalLabel public function Gets the label of the original state. 1
StateItemInterface::getTransitions public function Gets the allowed transitions for the current state. 1
StateItemInterface::getWorkflow public function Gets the workflow used by the field. 1
StateItemInterface::isTransitionAllowed public function Gets whether the given transition is allowed. 1
StateItemInterface::isValid public function Gets whether the current state is valid. 1
TraversableTypedDataInterface::onChange public function React to changes to a child property or item. 4
TypedDataInterface::applyDefaultValue public function Applies the default value. 1
TypedDataInterface::createInstance public static function Constructs a TypedData object given its definition and context. 1
TypedDataInterface::getConstraints public function Gets a list of validation constraints. 1
TypedDataInterface::getName public function Returns the name of a property or item. 1
TypedDataInterface::getParent public function Returns the parent data structure; i.e. either complex data or a list. 1
TypedDataInterface::getPropertyPath public function Returns the property path of the data. 1
TypedDataInterface::getRoot public function Returns the root of the typed data tree. 1
TypedDataInterface::getString public function Returns a string representation of the data. 1
TypedDataInterface::getValue public function Gets the data value. 1
TypedDataInterface::setContext public function Sets the context of a property or item via a context aware parent. 1
TypedDataInterface::setValue public function Sets the data value. 1
TypedDataInterface::validate public function Validates the currently set data value. 1