@@ -37,7 +37,40 @@ public function exportPage(Request $request): Response
3737 }
3838
3939 try {
40- $ yaml = $ this ->pageExporter ->toYaml ([$ page ]);
40+ $ yaml = $ this ->pageExporter ->exportToYaml ([$ page ]);
41+ } catch (\Exception $ e ) {
42+ return new JsonResponse ($ e ->getMessage (), Response::HTTP_INTERNAL_SERVER_ERROR );
43+ }
44+
45+ $ response = new Response ($ yaml );
46+ $ response ->headers ->set ('Content-type ' , 'application/yaml ' );
47+ $ response ->headers ->set (
48+ 'Content-Disposition ' ,
49+ HeaderUtils::makeDisposition (HeaderUtils::DISPOSITION_ATTACHMENT , $ this ->createFilename ($ page )),
50+ );
51+
52+ return $ response ;
53+ }
54+
55+ #[Route(
56+ '/admin/neusta/import-export/page/export/with-children ' ,
57+ name: 'neusta_pimcore_import_export_page_export_with_children ' ,
58+ methods: ['GET ' ]
59+ )]
60+ public function exportPageWithChildren (Request $ request ): Response
61+ {
62+ $ pageId = $ request ->query ->getInt ('page_id ' );
63+ $ page = $ this ->pageRepository ->getById ($ pageId );
64+
65+ if (!$ page instanceof Page) {
66+ return new JsonResponse (
67+ \sprintf ('Page with id "%s" was not found ' , $ pageId ),
68+ Response::HTTP_NOT_FOUND ,
69+ );
70+ }
71+
72+ try {
73+ $ yaml = $ this ->pageExporter ->exportToYaml ($ this ->pageRepository ->findAllPagesWithSubPages ($ page ));
4174 } catch (\Exception $ e ) {
4275 return new JsonResponse ($ e ->getMessage (), Response::HTTP_INTERNAL_SERVER_ERROR );
4376 }
0 commit comments