class EntityOperations implements ContainerInjectionInterface (View source)

internal  
 

Defines a class for reacting to entity events.

Properties

protected ModerationInformationInterface $moderationInfo

The Moderation Information service.

protected EntityTypeManagerInterface $entityTypeManager

The Entity Type Manager service.

protected FormBuilderInterface $formBuilder

The Form Builder service.

protected EntityTypeBundleInfoInterface $bundleInfo

The entity bundle information service.

protected RouteBuilderInterface $routerBuilder

The router builder service.

Methods

__construct(ModerationInformationInterface $moderation_info, EntityTypeManagerInterface $entity_type_manager, FormBuilderInterface $form_builder, EntityTypeBundleInfoInterface $bundle_info, RouteBuilderInterface $router_builder)

Constructs a new EntityOperations object.

static 
create(ContainerInterface $container)

Instantiates a new instance of this class.

entityPresave(EntityInterface $entity)

Acts on an entity and set published status based on the moderation state.

entityInsert(EntityInterface $entity)

No description

entityUpdate(EntityInterface $entity)

No description

updateOrCreateFromEntity(EntityInterface $entity)

Creates or updates the moderation state of an entity.

entityDelete(EntityInterface $entity)

No description

entityRevisionDelete(EntityInterface $entity)

No description

entityTranslationDelete(EntityInterface $translation)

No description

entityView(array $build, EntityInterface $entity, EntityViewDisplayInterface $display, $view_mode)

Act on entities being assembled before rendering.

bool
isPublished(ContentEntityInterface $entity)

Checks if the entity is published.

Details

__construct(ModerationInformationInterface $moderation_info, EntityTypeManagerInterface $entity_type_manager, FormBuilderInterface $form_builder, EntityTypeBundleInfoInterface $bundle_info, RouteBuilderInterface $router_builder)

Constructs a new EntityOperations object.

Parameters

ModerationInformationInterface $moderation_info

Moderation information service.

EntityTypeManagerInterface $entity_type_manager

Entity type manager service.

FormBuilderInterface $form_builder

The form builder.

EntityTypeBundleInfoInterface $bundle_info

The entity bundle information service.

RouteBuilderInterface $router_builder

The router builder service.

static create(ContainerInterface $container)

Instantiates a new instance of this class.

This is a factory method that returns a new instance of this class. The factory should pass any needed dependencies into the constructor of this class, but not the container itself. Every call to this method must return a new instance of this class; that is, it may not implement a singleton.

Parameters

ContainerInterface $container

The service container this instance should use.

entityPresave(EntityInterface $entity)

Acts on an entity and set published status based on the moderation state.

Parameters

EntityInterface $entity

The entity being saved.

See also

hook_entity_presave()

entityInsert(EntityInterface $entity)

No description

Parameters

EntityInterface $entity

The entity that was just saved.

See also

hook_entity_insert()

entityUpdate(EntityInterface $entity)

No description

Parameters

EntityInterface $entity

The entity that was just saved.

See also

hook_entity_update()

protected updateOrCreateFromEntity(EntityInterface $entity)

Creates or updates the moderation state of an entity.

Parameters

EntityInterface $entity

The entity to update or create a moderation state for.

entityDelete(EntityInterface $entity)

No description

Parameters

EntityInterface $entity

The entity being deleted.

See also

hook_entity_delete()

entityRevisionDelete(EntityInterface $entity)

No description

Parameters

EntityInterface $entity

The entity revision being deleted.

See also

hook_entity_revision_delete()

entityTranslationDelete(EntityInterface $translation)

No description

Parameters

EntityInterface $translation

The entity translation being deleted.

See also

hook_entity_translation_delete()

entityView(array $build, EntityInterface $entity, EntityViewDisplayInterface $display, $view_mode)

Act on entities being assembled before rendering.

Parameters

array $build
EntityInterface $entity
EntityViewDisplayInterface $display
$view_mode

See also

hook_entity_view()
\Drupal\content_moderation\EntityFieldManagerInterface::getExtraFields()

protected bool isPublished(ContentEntityInterface $entity)

Checks if the entity is published.

This method is optimized to not have to unnecessarily load the moderation state and workflow if it is not required.

Parameters

ContentEntityInterface $entity

The entity to check.

Return Value

bool

TRUE if the entity is published, FALSE otherwise.