You are here

interface TransactorPluginInterface in Transaction 8

Defines the interface for transactor plugins.

Hierarchy

Expanded class hierarchy of TransactorPluginInterface

All classes that implement TransactorPluginInterface

File

src/TransactorPluginInterface.php, line 14

Namespace

Drupal\transaction
View source
interface TransactorPluginInterface extends PluginFormInterface, ConfigurableInterface, DependentPluginInterface, ContainerFactoryPluginInterface {

  /**
   * Generic result code for successful execution.
   */
  const RESULT_OK = 1;

  /**
   * Generic result code for failed execution.
   */
  const RESULT_ERROR = -1;

  /**
   * Executes a transaction.
   *
   * By calling this method, the transactor will set the result code in the
   * transaction.
   *
   * @param \Drupal\transaction\TransactionInterface $transaction
   *   The transaction to execute.
   * @param \Drupal\transaction\TransactionInterface $last_executed
   *   The last executed transaction with the same type and target. Empty if
   *   this is the first one.
   *
   * @return bool
   *   TRUE if transaction was executed, FALSE otherwise.
   *
   * @see \Drupal\transaction\TransactionInterface::getResultCode()
   */
  public function executeTransaction(TransactionInterface $transaction, TransactionInterface $last_executed = NULL);

  /**
   * Compose a message that describes the execution result of a transaction.
   *
   * @param \Drupal\transaction\TransactionInterface $transaction
   *   The executed transaction for which to compose the result message.
   * @param string $langcode
   *   (optional) The language to use in message composition. Defaults to the
   *   current content language.
   *
   * @return \Drupal\Core\StringTranslation\TranslatableMarkup
   *   Translatable markup with the execution result message, FALSE if
   *   transaction execution was never called.
   */
  public function getResultMessage(TransactionInterface $transaction, $langcode = NULL);

  /**
   * Compose a human readable description for the given transaction.
   *
   * @param \Drupal\transaction\TransactionInterface $transaction
   *   The transaction to describe.
   * @param string $langcode
   *   (optional) For which language the transaction description should be
   *   composed, defaults to the current content language.
   *
   * @return string|\Drupal\Core\StringTranslation\TranslatableMarkup
   *   A string or translatable markup with the generated description.
   */
  public function getTransactionDescription(TransactionInterface $transaction, $langcode = NULL);

  /**
   * Compose human readable details for the given transaction.
   *
   * @param \Drupal\transaction\TransactionInterface $transaction
   *   The transaction to detail.
   * @param string $langcode
   *   (optional) For which language the transaction details should be
   *   composed, defaults to the current content language.
   *
   * @return array
   *   An array of strings and/or translatable markup objects representing each
   *   one a line detailing the transaction. Empty array if no details
   *   generated.
   */
  public function getTransactionDetails(TransactionInterface $transaction, $langcode = NULL);

  /**
   * Compose a messsage with execution indications for the given transaction.
   *
   * This message is commonly shown to the users upon transaction execution.
   *
   * @param \Drupal\transaction\TransactionInterface $transaction
   *   The pending transaction to compose indications about.
   * @param string $langcode
   *   (optional) For which language the execution indications should be
   *   composed, defaults to the current content language.
   *
   * @return string|\Drupal\Core\StringTranslation\TranslatableMarkup
   *   A string or translatable markup with the generated message.
   */
  public function getExecutionIndications(TransactionInterface $transaction, $langcode = NULL);

  /**
   * Check if the transactor is applicable to a particular entity.
   *
   * @param \Drupal\Core\Entity\ContentEntityInterface $entity
   *   The content entity to check.
   * @param \Drupal\transaction\TransactionTypeInterface $transaction_type
   *   (optional) Restrict the checking to a particular transaction type.
   *
   * @return bool
   *   TRUE if transactor is applicable to the given entity.
   */
  public function isApplicable(ContentEntityInterface $entity, TransactionTypeInterface $transaction_type = NULL);

}

Members

Namesort descending Modifiers Type Description Overrides
ConfigurableInterface::defaultConfiguration public function Gets default configuration for this plugin. 11
ConfigurableInterface::getConfiguration public function Gets this plugin's configuration. 12
ConfigurableInterface::setConfiguration public function Sets the configuration for this plugin instance. 12
ContainerFactoryPluginInterface::create public static function Creates an instance of the plugin. 112
DependentPluginInterface::calculateDependencies public function Calculates dependencies for the configured plugin. 19
PluginFormInterface::buildConfigurationForm public function Form constructor. 36
PluginFormInterface::submitConfigurationForm public function Form submission handler. 32
PluginFormInterface::validateConfigurationForm public function Form validation handler. 18
TransactorPluginInterface::executeTransaction public function Executes a transaction. 1
TransactorPluginInterface::getExecutionIndications public function Compose a messsage with execution indications for the given transaction. 1
TransactorPluginInterface::getResultMessage public function Compose a message that describes the execution result of a transaction. 1
TransactorPluginInterface::getTransactionDescription public function Compose a human readable description for the given transaction. 1
TransactorPluginInterface::getTransactionDetails public function Compose human readable details for the given transaction. 1
TransactorPluginInterface::isApplicable public function Check if the transactor is applicable to a particular entity. 1
TransactorPluginInterface::RESULT_ERROR constant Generic result code for failed execution.
TransactorPluginInterface::RESULT_OK constant Generic result code for successful execution.