@@ 49-81 (lines=33) @@ | ||
46 | $form = $formBuilder->getForm(); |
|
47 | $form->handleRequest($request); |
|
48 | ||
49 | if ($form->isSubmitted() && $form->isValid()) { |
|
50 | $rootLocation = $locationService->loadLocation(2); |
|
51 | ||
52 | try { |
|
53 | $repository->beginTransaction(); |
|
54 | ||
55 | $contentDraft = $contentService->createContent( |
|
56 | $data->payload, |
|
57 | [ |
|
58 | $locationService->newLocationCreateStruct($rootLocation->id), |
|
59 | ] |
|
60 | ); |
|
61 | ||
62 | $content = $contentService->publishVersion($contentDraft->versionInfo); |
|
63 | ||
64 | $repository->commit(); |
|
65 | } catch (Exception $e) { |
|
66 | $repository->rollback(); |
|
67 | // @todo do something else if needed |
|
68 | throw $e; |
|
69 | } |
|
70 | ||
71 | return $this->redirect( |
|
72 | $this->generateUrl( |
|
73 | UrlAliasRouter::URL_ALIAS_ROUTE_NAME, |
|
74 | [ |
|
75 | 'location' => $locationService->loadLocation( |
|
76 | $content->contentInfo->mainLocationId |
|
77 | ), |
|
78 | ] |
|
79 | ) |
|
80 | ); |
|
81 | } |
|
82 | ||
83 | return $this->render( |
|
84 | '@NetgenEzForms/demo_form.html.twig', |
|
@@ 115-143 (lines=29) @@ | ||
112 | //$form = $this->createForm(UpdateContentType::class, $data); |
|
113 | $form->handleRequest($request); |
|
114 | ||
115 | if ($form->isSubmitted() && $form->isValid()) { |
|
116 | try { |
|
117 | $repository->beginTransaction(); |
|
118 | ||
119 | $contentDraft = $contentService->createContentDraft($content->contentInfo); |
|
120 | $contentDraft = $contentService->updateContent( |
|
121 | $contentDraft->versionInfo, |
|
122 | $data->payload |
|
123 | ); |
|
124 | $content = $contentService->publishVersion($contentDraft->versionInfo); |
|
125 | ||
126 | $repository->commit(); |
|
127 | } catch (Exception $e) { |
|
128 | $repository->rollback(); |
|
129 | // @todo do something else if needed |
|
130 | throw $e; |
|
131 | } |
|
132 | ||
133 | return $this->redirect( |
|
134 | $this->generateUrl( |
|
135 | UrlAliasRouter::URL_ALIAS_ROUTE_NAME, |
|
136 | [ |
|
137 | 'location' => $this->getRepository()->getLocationService()->loadLocation( |
|
138 | $content->contentInfo->mainLocationId |
|
139 | ), |
|
140 | ] |
|
141 | ) |
|
142 | ); |
|
143 | } |
|
144 | ||
145 | return $this->render( |
|
146 | '@NetgenEzForms/demo_form.html.twig', |