diff --git a/src/main/core/Messenger/CopyWorkspaceHandler.php b/src/main/core/Messenger/CopyWorkspaceHandler.php index 2d82a6f7de9..912faa6c099 100644 --- a/src/main/core/Messenger/CopyWorkspaceHandler.php +++ b/src/main/core/Messenger/CopyWorkspaceHandler.php @@ -12,6 +12,7 @@ namespace Claroline\CoreBundle\Messenger; use Claroline\AppBundle\API\Crud; +use Claroline\AppBundle\Persistence\ObjectManager; use Claroline\CoreBundle\Entity\Workspace\Workspace; use Claroline\CoreBundle\Messenger\Message\CopyWorkspace; use Symfony\Component\Messenger\Exception\UnrecoverableMessageHandlingException; @@ -19,13 +20,15 @@ class CopyWorkspaceHandler implements MessageHandlerInterface { - public function __construct(private readonly Crud $crud) - { + public function __construct( + private readonly ObjectManager $om, + private readonly Crud $crud + ) { } public function __invoke(CopyWorkspace $copyWorkspace): void { - $workspace = $this->crud->get(Workspace::class, $copyWorkspace->getWorkspaceId()); + $workspace = $this->om->getRepository(Workspace::class)->find($copyWorkspace->getWorkspaceId()); if (empty($workspace)) { return; } diff --git a/src/main/core/Resources/config/services/messenger.yml b/src/main/core/Resources/config/services/messenger.yml index 501e3379ec2..10d867ab5b9 100644 --- a/src/main/core/Resources/config/services/messenger.yml +++ b/src/main/core/Resources/config/services/messenger.yml @@ -8,6 +8,7 @@ services: Claroline\CoreBundle\Messenger\CopyWorkspaceHandler: arguments: + - '@Claroline\AppBundle\Persistence\ObjectManager' - '@Claroline\AppBundle\API\Crud' Claroline\CoreBundle\Messenger\SendMessageHandler: