Newer
Older
<?php
namespace Drupal\trash;
use Drupal\Core\Entity\EntityTypeInterface;
/**
* Provides an interface for the Trash manager.
*/
interface TrashManagerInterface {
/**
* Determines whether an entity type is supported by Trash.
*
* @param \Drupal\Core\Entity\EntityTypeInterface $entity_type
* An entity type object.
*
* @return bool
*/
public function isEntityTypeSupported(EntityTypeInterface $entity_type) : bool;
/**
* Determines whether Trash integration is enabled for an entity type.
*
* @param \Drupal\Core\Entity\EntityTypeInterface $entity_type
* An entity type object.
*
* @return bool
*/
public function isEntityTypeEnabled(EntityTypeInterface $entity_type) : bool;
/**
* Gets the IDs of all entity types which can use the Trash.
*
* @return array
*/
public function getEnabledEntityTypes() : array;
/**
* Enables Trash integration for an entity type.
*
* @param \Drupal\Core\Entity\EntityTypeInterface $entity_type
* An entity type object.
*
* @throws \InvalidArgumentException
* Thrown when Trash integration can not be enabled or is already enabled
* for an entity type.
*/
public function enableEntityType(EntityTypeInterface $entity_type);
/**
* Disables Trash integration for an entity type.
*
* @param \Drupal\Core\Entity\EntityTypeInterface $entity_type
* An entity type object.
*/
public function disableEntityType(EntityTypeInterface $entity_type);
/**
* Determines whether entity and views queries should be altered.
*
* @return bool
* TRUE whether Trash should alter entity and views queries.
*/

Andrei Mateescu
committed
public function shouldAlterQueries(): bool;
/**
* Determines the current trash context.
*
* @return string
* One of 'active', 'inactive' or 'ignore'.
*/

Andrei Mateescu
committed
public function getTrashContext(): string;
/**
* Sets the current trash context.
*
* @param string $context
* One of 'active', 'inactive' or 'ignore'.
*
* @return $this
*/
public function setTrashContext(string $context): static;
/**
* Executes the given callback function in a specific trash context.
*
* @param string $context
* One of 'active', 'inactive' or 'ignore'.
* @param callable $function
* The callback to be executed.
*
* @return mixed
* The callable's return value.
*/
public function executeInTrashContext($context, callable $function);