diff --git a/modules/workflow_access/workflow_access.module b/modules/workflow_access/workflow_access.module index a2de08c5e64b6b08044bb5fbebf4a9d2d1a6df28..009621f491271b956b48febfe9f65e2e200b356d 100644 --- a/modules/workflow_access/workflow_access.module +++ b/modules/workflow_access/workflow_access.module @@ -124,9 +124,7 @@ function workflow_access_user_role_update(EntityInterface $entity) { // Attend user to Rebuild data, because the weight of a role // is the key for workflow_Access. /** @var \Drupal\user\RoleInterface $entity */ - $targetEntity = new WorkflowTargetEntity($entity); - $original_entity = $targetEntity->getOriginal(); - + $original_entity = WorkflowTargetEntity::getOriginal($entity); if ($entity->getWeight() != $original_entity->getWeight()) { // Role's weight has changed. node_access_needs_rebuild(TRUE); diff --git a/src/Entity/WorkflowTargetEntity.php b/src/Entity/WorkflowTargetEntity.php index 32a8e3b3b4158b048f7ba8a722a97f1084dbd0c8..367d756fe32532aac7caa1bf9733e81a43cc73e5 100644 --- a/src/Entity/WorkflowTargetEntity.php +++ b/src/Entity/WorkflowTargetEntity.php @@ -12,15 +12,6 @@ use Drupal\Core\Entity\EntityInterface; */ class WorkflowTargetEntity { - /** - * The wrapped entity, probably the transition->getTargetEntity(). - * - * This property will be set and used during the saving process. - * - * @var EntityInterface - */ - protected EntityInterface $targetEntity; - /** * {@inheritdoc} */ @@ -37,10 +28,10 @@ class WorkflowTargetEntity { * @see EntityInterface::getOriginal() * @see https://www.drupal.org/node/3295826 */ - public function getOriginal() { - return method_exists($this->targetEntity, 'getOriginal') - ? $this->targetEntity->getOriginal() - : $this->targetEntity->original ?? NULL; + public static function getOriginal(EntityInterface $entity) { + return method_exists($entity, 'getOriginal') + ? $entity->getOriginal() + : $enity->original ?? NULL; } /** diff --git a/src/Hook/WorkflowEntityHooks.php b/src/Hook/WorkflowEntityHooks.php index b67cf4cd7672e3b70c346ad0e2bd219e038fc1ef..0e210544a3fc266ab7528a34c8f3bd0615831005 100644 --- a/src/Hook/WorkflowEntityHooks.php +++ b/src/Hook/WorkflowEntityHooks.php @@ -359,8 +359,7 @@ class WorkflowEntityHooks { return; } - $targetEntity = new WorkflowTargetEntity($entity); - $original_entity = $targetEntity->getOriginal(); + $original_entity = WorkflowTargetEntity::getOriginal($entity); foreach ($field_names as $field_name => $label) { /** @var \Drupal\workflow\Entity\WorkflowTransitionInterface $transition */ // @todo Transition is created in widget or WorkflowTransitionForm.