public EntityOperations::entityPresave(EntityInterface $entity)
Acts on an entity and set published status based on the moderation state.
Parameters
\Drupal\Core\Entity\EntityInterface $entity: The entity being saved.
File
- core/modules/content_moderation/src/EntityOperations.php, line 85
Class
- EntityOperations
- Defines a class for reacting to entity events.
Namespace
Drupal\content_moderation
Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | public function entityPresave(EntityInterface $entity ) { if (! $this ->moderationInfo->isModeratedEntity( $entity )) { return ; } if ( $entity ->moderation_state->target_id) { $moderation_state = $this ->entityTypeManager ->getStorage( 'moderation_state' ) ->load( $entity ->moderation_state->target_id); $published_state = $moderation_state ->isPublishedState(); // This entity is default if it is new, the default revision, or the // default revision is not published. $update_default_revision = $entity ->isNew() || $moderation_state ->isDefaultRevisionState() || ! $this ->isDefaultRevisionPublished( $entity ); // Fire per-entity-type logic for handling the save process. $this ->entityTypeManager->getHandler( $entity ->getEntityTypeId(), 'moderation' )->onPresave( $entity , $update_default_revision , $published_state ); } } |
Please login to continue.