|
15 | 15 | use RZ\Roadiz\CoreBundle\Entity\Document;
|
16 | 16 | use RZ\Roadiz\CoreBundle\Entity\Folder;
|
17 | 17 | use RZ\Roadiz\CoreBundle\Entity\TagTranslationDocuments;
|
18 |
| -use RZ\Roadiz\CoreBundle\Entity\Translation; |
19 | 18 | use RZ\Roadiz\CoreBundle\EntityHandler\DocumentHandler;
|
20 | 19 | use RZ\Roadiz\CoreBundle\Explorer\ExplorerItemFactoryInterface;
|
21 |
| -use RZ\Roadiz\CoreBundle\ListManager\SessionListFilters; |
22 | 20 | use RZ\Roadiz\Documents\Events\DocumentCreatedEvent;
|
23 | 21 | use RZ\Roadiz\Documents\Events\DocumentDeletedEvent;
|
24 | 22 | use RZ\Roadiz\Documents\Events\DocumentFileUpdatedEvent;
|
25 |
| -use RZ\Roadiz\Documents\Events\DocumentInFolderEvent; |
26 |
| -use RZ\Roadiz\Documents\Events\DocumentOutFolderEvent; |
27 | 23 | use RZ\Roadiz\Documents\Events\DocumentUpdatedEvent;
|
28 | 24 | use RZ\Roadiz\Documents\Exceptions\APINeedsAuthentificationException;
|
29 | 25 | use RZ\Roadiz\Documents\MediaFinders\EmbedFinderFactory;
|
30 | 26 | use RZ\Roadiz\Documents\MediaFinders\EmbedFinderInterface;
|
31 | 27 | use RZ\Roadiz\Documents\MediaFinders\RandomImageFinder;
|
32 | 28 | use RZ\Roadiz\Documents\Models\DocumentInterface;
|
33 |
| -use Symfony\Component\Form\ClickableInterface; |
34 | 29 | use Symfony\Component\Form\Extension\Core\Type\FileType;
|
35 | 30 | use Symfony\Component\Form\Extension\Core\Type\HiddenType;
|
36 |
| -use Symfony\Component\Form\Extension\Core\Type\SubmitType; |
37 |
| -use Symfony\Component\Form\Extension\Core\Type\TextType; |
38 | 31 | use Symfony\Component\Form\Form;
|
39 | 32 | use Symfony\Component\Form\FormError;
|
40 | 33 | use Symfony\Component\Form\FormInterface;
|
@@ -80,103 +73,6 @@ public function __construct(
|
80 | 73 | ) {
|
81 | 74 | }
|
82 | 75 |
|
83 |
| - /** |
84 |
| - * @throws RuntimeError |
85 |
| - */ |
86 |
| - public function indexAction(Request $request, ?int $folderId = null): Response |
87 |
| - { |
88 |
| - $this->denyAccessUnlessGranted('ROLE_ACCESS_DOCUMENTS'); |
89 |
| - |
90 |
| - /** @var Translation $translation */ |
91 |
| - $translation = $this->em() |
92 |
| - ->getRepository(Translation::class) |
93 |
| - ->findDefault(); |
94 |
| - |
95 |
| - $prefilters = [ |
96 |
| - 'raw' => false, |
97 |
| - ]; |
98 |
| - |
99 |
| - if ( |
100 |
| - null !== $folderId |
101 |
| - && $folderId > 0 |
102 |
| - ) { |
103 |
| - $folder = $this->em() |
104 |
| - ->find(Folder::class, $folderId); |
105 |
| - |
106 |
| - $prefilters['folders'] = [$folder]; |
107 |
| - $this->assignation['folder'] = $folder; |
108 |
| - } |
109 |
| - |
110 |
| - $type = $request->query->get('type', null); |
111 |
| - if (\is_string($type) && '' !== trim($type)) { |
112 |
| - $prefilters['mimeType'] = trim($type); |
113 |
| - $this->assignation['mimeType'] = trim($type); |
114 |
| - } |
115 |
| - |
116 |
| - $embedPlatform = $request->query->get('embedPlatform', null); |
117 |
| - if (\is_string($embedPlatform) && '' !== trim($embedPlatform)) { |
118 |
| - $prefilters['embedPlatform'] = trim($embedPlatform); |
119 |
| - $this->assignation['embedPlatform'] = trim($embedPlatform); |
120 |
| - } |
121 |
| - $this->assignation['availablePlatforms'] = $this->documentPlatforms; |
122 |
| - |
123 |
| - /* |
124 |
| - * Handle bulk folder form |
125 |
| - */ |
126 |
| - $joinFolderForm = $this->buildLinkFoldersForm(); |
127 |
| - $joinFolderForm->handleRequest($request); |
128 |
| - if ($joinFolderForm->isSubmitted() && $joinFolderForm->isValid()) { |
129 |
| - $data = $joinFolderForm->getData(); |
130 |
| - $submitFolder = $joinFolderForm->get('submitFolder'); |
131 |
| - $submitUnfolder = $joinFolderForm->get('submitUnfolder'); |
132 |
| - if ($submitFolder instanceof ClickableInterface && $submitFolder->isClicked()) { |
133 |
| - $msg = $this->joinFolder($data); |
134 |
| - } elseif ($submitUnfolder instanceof ClickableInterface && $submitUnfolder->isClicked()) { |
135 |
| - $msg = $this->leaveFolder($data); |
136 |
| - } else { |
137 |
| - $msg = $this->getTranslator()->trans('wrong.request'); |
138 |
| - } |
139 |
| - |
140 |
| - $this->publishConfirmMessage($request, $msg); |
141 |
| - |
142 |
| - return $this->redirectToRoute( |
143 |
| - 'documentsHomePage', |
144 |
| - ['folderId' => $folderId] |
145 |
| - ); |
146 |
| - } |
147 |
| - $this->assignation['joinFolderForm'] = $joinFolderForm->createView(); |
148 |
| - |
149 |
| - /* |
150 |
| - * Manage get request to filter list |
151 |
| - */ |
152 |
| - $listManager = $this->createEntityListManager( |
153 |
| - Document::class, |
154 |
| - $prefilters, |
155 |
| - ['createdAt' => 'DESC'] |
156 |
| - ); |
157 |
| - $listManager->setDisplayingNotPublishedNodes(true); |
158 |
| - $listManager->setItemPerPage(static::DEFAULT_ITEM_PER_PAGE); |
159 |
| - |
160 |
| - /* |
161 |
| - * Stored in session |
162 |
| - */ |
163 |
| - $sessionListFilter = new SessionListFilters('documents_item_per_page'); |
164 |
| - $sessionListFilter->handleItemPerPage($request, $listManager); |
165 |
| - |
166 |
| - $listManager->handle(); |
167 |
| - |
168 |
| - $this->assignation['filters'] = $listManager->getAssignation(); |
169 |
| - $this->assignation['documents'] = $listManager->getEntities(); |
170 |
| - $this->assignation['translation'] = $translation; |
171 |
| - $this->assignation['thumbnailFormat'] = $this->thumbnailFormat; |
172 |
| - |
173 |
| - return $this->render($this->getListingTemplate($request), $this->assignation); |
174 |
| - } |
175 |
| - |
176 |
| - /** |
177 |
| - * @throws RuntimeError |
178 |
| - * @throws FilesystemException |
179 |
| - */ |
180 | 76 | public function adjustAction(Request $request, int $documentId): Response
|
181 | 77 | {
|
182 | 78 | $this->denyAccessUnlessGranted('ROLE_ACCESS_DOCUMENTS');
|
@@ -258,10 +154,6 @@ public function adjustAction(Request $request, int $documentId): Response
|
258 | 154 | return $this->render('@RoadizRozier/documents/adjust.html.twig', $this->assignation);
|
259 | 155 | }
|
260 | 156 |
|
261 |
| - /** |
262 |
| - * @throws FilesystemException |
263 |
| - * @throws RuntimeError |
264 |
| - */ |
265 | 157 | public function editAction(Request $request, int $documentId): Response
|
266 | 158 | {
|
267 | 159 | $this->denyAccessUnlessGranted('ROLE_ACCESS_DOCUMENTS');
|
@@ -339,11 +231,6 @@ public function editAction(Request $request, int $documentId): Response
|
339 | 231 | return $this->render('@RoadizRozier/documents/edit.html.twig', $this->assignation);
|
340 | 232 | }
|
341 | 233 |
|
342 |
| - /** |
343 |
| - * Return an deletion form for requested document. |
344 |
| - * |
345 |
| - * @throws RuntimeError |
346 |
| - */ |
347 | 234 | public function deleteAction(Request $request, int $documentId): Response
|
348 | 235 | {
|
349 | 236 | $this->denyAccessUnlessGranted('ROLE_ACCESS_DOCUMENTS_DELETE');
|
@@ -393,11 +280,6 @@ public function deleteAction(Request $request, int $documentId): Response
|
393 | 280 | return $this->render('@RoadizRozier/documents/delete.html.twig', $this->assignation);
|
394 | 281 | }
|
395 | 282 |
|
396 |
| - /** |
397 |
| - * Return an deletion form for multiple docs. |
398 |
| - * |
399 |
| - * @throws RuntimeError |
400 |
| - */ |
401 | 283 | public function bulkDeleteAction(Request $request): Response
|
402 | 284 | {
|
403 | 285 | $this->denyAccessUnlessGranted('ROLE_ACCESS_DOCUMENTS_DELETE');
|
@@ -445,8 +327,6 @@ public function bulkDeleteAction(Request $request): Response
|
445 | 327 |
|
446 | 328 | /**
|
447 | 329 | * Embed external document page.
|
448 |
| - * |
449 |
| - * @throws RuntimeError |
450 | 330 | */
|
451 | 331 | public function embedAction(Request $request, ?int $folderId = null): Response
|
452 | 332 | {
|
@@ -782,152 +662,6 @@ private function buildUploadForm(?int $folderId = null): FormInterface
|
782 | 662 | return $builder->getForm();
|
783 | 663 | }
|
784 | 664 |
|
785 |
| - private function buildLinkFoldersForm(): FormInterface |
786 |
| - { |
787 |
| - $builder = $this->createNamedFormBuilder('folderForm') |
788 |
| - ->add('documentsId', HiddenType::class, [ |
789 |
| - 'attr' => ['class' => 'document-id-bulk-folder'], |
790 |
| - 'constraints' => [ |
791 |
| - new NotNull(), |
792 |
| - new NotBlank(), |
793 |
| - ], |
794 |
| - ]) |
795 |
| - ->add('folderPaths', TextType::class, [ |
796 |
| - 'label' => false, |
797 |
| - 'attr' => [ |
798 |
| - 'class' => 'rz-folder-autocomplete', |
799 |
| - 'placeholder' => 'list.folders.to_link', |
800 |
| - ], |
801 |
| - 'constraints' => [ |
802 |
| - new NotNull(), |
803 |
| - new NotBlank(), |
804 |
| - ], |
805 |
| - ]) |
806 |
| - ->add('submitFolder', SubmitType::class, [ |
807 |
| - 'label' => false, |
808 |
| - 'attr' => [ |
809 |
| - 'class' => 'uk-button uk-button-primary', |
810 |
| - 'title' => 'link.folders', |
811 |
| - 'data-uk-tooltip' => '{animation:true}', |
812 |
| - ], |
813 |
| - ]) |
814 |
| - ->add('submitUnfolder', SubmitType::class, [ |
815 |
| - 'label' => false, |
816 |
| - 'attr' => [ |
817 |
| - 'class' => 'uk-button', |
818 |
| - 'title' => 'unlink.folders', |
819 |
| - 'data-uk-tooltip' => '{animation:true}', |
820 |
| - ], |
821 |
| - ]); |
822 |
| - |
823 |
| - return $builder->getForm(); |
824 |
| - } |
825 |
| - |
826 |
| - /** |
827 |
| - * @return string Status message |
828 |
| - */ |
829 |
| - private function joinFolder(array $data): string |
830 |
| - { |
831 |
| - $msg = $this->getTranslator()->trans('no_documents.linked_to.folders'); |
832 |
| - |
833 |
| - if ( |
834 |
| - !empty($data['documentsId']) |
835 |
| - && !empty($data['folderPaths']) |
836 |
| - ) { |
837 |
| - $documentsIds = explode(',', $data['documentsId']); |
838 |
| - |
839 |
| - $documents = $this->em() |
840 |
| - ->getRepository(Document::class) |
841 |
| - ->findBy([ |
842 |
| - 'id' => $documentsIds, |
843 |
| - ]); |
844 |
| - |
845 |
| - $folderPaths = explode(',', $data['folderPaths']); |
846 |
| - $folderPaths = array_filter($folderPaths); |
847 |
| - |
848 |
| - foreach ($folderPaths as $path) { |
849 |
| - /** @var Folder $folder */ |
850 |
| - $folder = $this->em() |
851 |
| - ->getRepository(Folder::class) |
852 |
| - ->findOrCreateByPath($path); |
853 |
| - |
854 |
| - /* |
855 |
| - * Add each selected documents |
856 |
| - */ |
857 |
| - foreach ($documents as $document) { |
858 |
| - $folder->addDocument($document); |
859 |
| - } |
860 |
| - } |
861 |
| - |
862 |
| - $this->em()->flush(); |
863 |
| - $msg = $this->getTranslator()->trans('documents.linked_to.folders'); |
864 |
| - |
865 |
| - /* |
866 |
| - * Dispatch events |
867 |
| - */ |
868 |
| - foreach ($documents as $document) { |
869 |
| - $this->dispatchEvent( |
870 |
| - new DocumentInFolderEvent($document) |
871 |
| - ); |
872 |
| - } |
873 |
| - } |
874 |
| - |
875 |
| - return $msg; |
876 |
| - } |
877 |
| - |
878 |
| - /** |
879 |
| - * @return string Status message |
880 |
| - */ |
881 |
| - private function leaveFolder(array $data): string |
882 |
| - { |
883 |
| - $msg = $this->getTranslator()->trans('no_documents.removed_from.folders'); |
884 |
| - |
885 |
| - if ( |
886 |
| - !empty($data['documentsId']) |
887 |
| - && !empty($data['folderPaths']) |
888 |
| - ) { |
889 |
| - $documentsIds = explode(',', $data['documentsId']); |
890 |
| - |
891 |
| - $documents = $this->em() |
892 |
| - ->getRepository(Document::class) |
893 |
| - ->findBy([ |
894 |
| - 'id' => $documentsIds, |
895 |
| - ]); |
896 |
| - |
897 |
| - $folderPaths = explode(',', $data['folderPaths']); |
898 |
| - $folderPaths = array_filter($folderPaths); |
899 |
| - |
900 |
| - foreach ($folderPaths as $path) { |
901 |
| - /** @var Folder $folder */ |
902 |
| - $folder = $this->em() |
903 |
| - ->getRepository(Folder::class) |
904 |
| - ->findByPath($path); |
905 |
| - |
906 |
| - if (null !== $folder) { |
907 |
| - /* |
908 |
| - * Add each selected documents |
909 |
| - */ |
910 |
| - foreach ($documents as $document) { |
911 |
| - $folder->removeDocument($document); |
912 |
| - } |
913 |
| - } |
914 |
| - } |
915 |
| - $this->em()->flush(); |
916 |
| - $msg = $this->getTranslator()->trans('documents.removed_from.folders'); |
917 |
| - |
918 |
| - /* |
919 |
| - * Dispatch events |
920 |
| - */ |
921 |
| - foreach ($documents as $document) { |
922 |
| - $this->dispatchEvent( |
923 |
| - new DocumentOutFolderEvent($document) |
924 |
| - ); |
925 |
| - } |
926 |
| - } |
927 |
| - |
928 |
| - return $msg; |
929 |
| - } |
930 |
| - |
931 | 665 | /**
|
932 | 666 | * @return DocumentInterface|array<DocumentInterface>
|
933 | 667 | *
|
@@ -1037,13 +771,4 @@ private function uploadDocument(FormInterface $data, ?int $folderId = null): ?Do
|
1037 | 771 |
|
1038 | 772 | return null;
|
1039 | 773 | }
|
1040 |
| - |
1041 |
| - private function getListingTemplate(Request $request): string |
1042 |
| - { |
1043 |
| - if ('1' === $request->query->get('list')) { |
1044 |
| - return '@RoadizRozier/documents/list-table.html.twig'; |
1045 |
| - } |
1046 |
| - |
1047 |
| - return '@RoadizRozier/documents/list.html.twig'; |
1048 |
| - } |
1049 | 774 | }
|
0 commit comments