From ed5dc002ba060e95aa3406f553a37411ad9c549e Mon Sep 17 00:00:00 2001
From: Camille Simiand <camille.simiand@tetras-libre.fr>
Date: Fri, 28 Jan 2022 16:41:05 +0100
Subject: [PATCH] Fix warning error on duplicate

---
 src/Controller/CapsuleController.php             | 7 ++++---
 templates/capsule/editors/list_editors.html.twig | 2 +-
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/src/Controller/CapsuleController.php b/src/Controller/CapsuleController.php
index a9bec19..7089903 100644
--- a/src/Controller/CapsuleController.php
+++ b/src/Controller/CapsuleController.php
@@ -205,8 +205,7 @@ class CapsuleController extends AbstractController
         int $id,
         Request $request,
         Filesystem $file_system,
-        TranslatorInterface $translator,
-        CapsuleRepository $capsule_repository
+        TranslatorInterface $translator
     ): Response {
         $form = $this->createForm(DuplicateCapsuleFormType::class);
         $form->handleRequest($request);
@@ -223,7 +222,9 @@ class CapsuleController extends AbstractController
             throw new \Exception('The retrieved capsule is not an instance of Capsule.');
         }
 
-        if (! $capsule_repository->doCapsuleBelongsToUser($parent_capsule, $current_user)) {
+        $capsule_editors = $parent_capsule->getEditors();
+
+        if (! in_array($current_user, $capsule_editors->toArray())) {
             $this->addFlash(
                 'warning',
                 $translator->trans(
diff --git a/templates/capsule/editors/list_editors.html.twig b/templates/capsule/editors/list_editors.html.twig
index 0dab1a4..bae2a9b 100644
--- a/templates/capsule/editors/list_editors.html.twig
+++ b/templates/capsule/editors/list_editors.html.twig
@@ -61,7 +61,7 @@
                     </ul>
                 </div>
             </div>
-            
+
         </div>
     </div>
 
-- 
GitLab