ContentModeration
class ContentModeration extends WorkflowTypeBase implements ContentModerationInterface, ContainerFactoryPluginInterface (View source)
Attaches workflows to content entity types and their bundles.
Traits
Wrapper methods for \Drupal\Core\StringTranslation\TranslationInterface.
Provides a trait with typical behavior for plugins which have forms.
Constants
| DERIVATIVE_SEPARATOR |
A string which is used to separate base plugin IDs from the derivative ID. |
| VALID_ID_REGEX |
A regex for matching a valid state/transition machine name. |
Properties
| protected string | $pluginId | The plugin_id. |
from PluginBase |
| protected array | $pluginDefinition | The plugin implementation definition. |
from PluginBase |
| protected array | $configuration | Configuration information passed into the plugin. |
from PluginBase |
| protected TranslationInterface | $stringTranslation | The string translation service. |
from StringTranslationTrait |
| protected EntityTypeManagerInterface | $entityTypeManager | The entity type manager. |
|
| protected EntityTypeBundleInfoInterface | $entityTypeBundleInfo | The entity type bundle info service. |
|
| protected ModerationInformationInterface | $moderationInfo | The moderation information service. |
Methods
Constructs a ContentModeration object.
Determines if the workflow is being has data associated with it.
Determines if the workflow state has data associated with it.
Gets this plugin's configuration.
Sets the configuration for this plugin instance.
Gets default configuration for this plugin.
Calculates dependencies for the configured plugin.
Informs the plugin that a dependency of the workflow will be deleted.
Gets the initial state for the workflow.
Determines if the workflow has a state with the provided ID.
Gets state objects for the provided state IDs.
Gets a workflow state.
Sets a state's weight value.
Adds a transition to the workflow.
Gets transition objects for the provided transition IDs.
Sort states or transitions by weight, label, and key.
Gets a transition object for the provided transition ID.
Gets the transition IDs for a state for the provided direction.
Gets a transition from state to state.
Determines if a transition from state to state exists.
Gets the transition ID from state to state.
Sets a transition's label.
Sets a transition's weight.
Sets a transition's from states.
Gets the weight for a new state or transition.
Translates a string to the current language or to a given language.
Formats a string containing a count of items.
Returns the number of plurals supported by a given language.
Gets the string translation service.
Creates an instance of the plugin.
Gets the entity types the workflow is applied to.
Gets any bundles the workflow is applied to for the given entity type.
Checks if the workflow applies to the supplied entity type and bundle.
Removes an entity type ID / bundle ID from the workflow.
Add an entity type ID / bundle ID to the workflow.
Details
__construct(array $configuration, string $plugin_id, mixed $plugin_definition, EntityTypeManagerInterface $entity_type_manager, EntityTypeBundleInfoInterface $entity_type_bundle_info, ModerationInformationInterface $moderation_info)
Constructs a ContentModeration object.
string
getPluginId()
Gets the plugin_id of the plugin instance.
string
getBaseId()
Gets the base_plugin_id of the plugin instance.
string|null
getDerivativeId()
Gets the derivative_id of the plugin instance.
array
getPluginDefinition()
Gets the definition of the plugin implementation.
bool
isConfigurable()
Determines if the plugin is configurable.
getFormClass($operation)
{@inheritdoc}
hasFormClass($operation)
{@inheritdoc}
string
label()
Gets the label for the workflow type.
bool
workflowHasData(WorkflowInterface $workflow)
Determines if the workflow is being has data associated with it.
bool
workflowStateHasData(WorkflowInterface $workflow, StateInterface $state)
Determines if the workflow state has data associated with it.
array
getConfiguration()
Gets this plugin's configuration.
setConfiguration(array $configuration)
Sets the configuration for this plugin instance.
string[]
getRequiredStates()
Gets the required states of workflow type.
This is usually specified in the workflow type annotation.
array
defaultConfiguration()
Gets default configuration for this plugin.
array
calculateDependencies()
Calculates dependencies for the configured plugin.
Dependencies are saved in the plugin's configuration entity and are used to determine configuration synchronization order. For example, if the plugin integrates with specific user roles, this method should return an array of dependencies listing the specified roles.
bool
onDependencyRemoval(array $dependencies)
Informs the plugin that a dependency of the workflow will be deleted.
StateInterface
getInitialState($entity = NULL)
Gets the initial state for the workflow.
$this
addState(string $state_id, string $label)
Adds a state to the workflow.
bool
hasState(string $state_id)
Determines if the workflow has a state with the provided ID.
StateInterface[]
getStates(string[] $state_ids = NULL)
Gets state objects for the provided state IDs.
StateInterface
getState(string $state_id)
Gets a workflow state.
$this
setStateLabel(string $state_id, string $label)
Sets a state's label.
$this
setStateWeight(string $state_id, int $weight)
Sets a state's weight value.
$this
deleteState(string $state_id)
Deletes a state from the workflow.
$this
addTransition($transition_id, string $label, array $from_state_ids, string $to_state_id)
Adds a transition to the workflow.
TransitionInterface[]
getTransitions(array $transition_ids = NULL)
Gets transition objects for the provided transition IDs.
static protected StateInterface[]|TransitionInterface[]
labelWeightMultisort(StateInterface[]|TransitionInterface[] $objects)
Sort states or transitions by weight, label, and key.
TransitionInterface
getTransition(string $transition_id)
Gets a transition object for the provided transition ID.
bool
hasTransition(string $transition_id)
Determines if a transition exists.
array
getTransitionsForState($state_id, string $direction = TransitionInterface::DIRECTION_FROM)
Gets the transition IDs for a state for the provided direction.
TransitionInterface
getTransitionFromStateToState(string $from_state_id, string $to_state_id)
Gets a transition from state to state.
bool
hasTransitionFromStateToState(string $from_state_id, string $to_state_id)
Determines if a transition from state to state exists.
protected string|null
getTransitionIdFromStateToState(string $from_state_id, string $to_state_id)
Gets the transition ID from state to state.
$this
setTransitionLabel(string $transition_id, string $label)
Sets a transition's label.
$this
setTransitionWeight(string $transition_id, int $weight)
Sets a transition's weight.
$this
setTransitionFromStates(string $transition_id, array $from_state_ids)
Sets a transition's from states.
$this
deleteTransition(string $transition_id)
Deletes a transition.
protected int
getNextWeight(array $items)
Gets the weight for a new state or transition.
protected TranslatableMarkup
t(string $string, array $args = [], array $options = [])
Translates a string to the current language or to a given language.
See \Drupal\Core\StringTranslation\TranslatableMarkup::__construct() for important security information and usage guidelines.
In order for strings to be localized, make them available in one of the ways supported by the
protected
formatPlural($count, $singular, $plural, array $args = [], array $options = [])
Formats a string containing a count of items.
protected
getNumberOfPlurals($langcode = NULL)
Returns the number of plurals supported by a given language.
protected TranslationInterface
getStringTranslation()
Gets the string translation service.
$this
setStringTranslation(TranslationInterface $translation)
Sets the string translation service to use.
static ContainerFactoryPluginInterface
create(ContainerInterface $container, array $configuration, string $plugin_id, mixed $plugin_definition)
Creates an instance of the plugin.
string[]
getEntityTypes()
Gets the entity types the workflow is applied to.
string[]
getBundlesForEntityType(string $entity_type_id)
Gets any bundles the workflow is applied to for the given entity type.
bool
appliesToEntityTypeAndBundle(string $entity_type_id, string $bundle_id)
Checks if the workflow applies to the supplied entity type and bundle.
removeEntityTypeAndBundle(string $entity_type_id, string $bundle_id)
Removes an entity type ID / bundle ID from the workflow.
addEntityTypeAndBundle(string $entity_type_id, string $bundle_id)
Add an entity type ID / bundle ID to the workflow.