1- package org.zikula.modulestudio.generator.cartridges.symfony.controller.action
1+ package org.zikula.modulestudio.generator.cartridges.symfony.controller
22
33import de.guite.modulestudio.metamodel.Action
44import de.guite.modulestudio.metamodel.Application
@@ -13,7 +13,7 @@ import org.zikula.modulestudio.generator.extensions.FormattingExtensions
1313import org.zikula.modulestudio.generator.extensions.ModelBehaviourExtensions
1414import org.zikula.modulestudio.generator.extensions.Utils
1515
16- class Actions {
16+ class ControllerActionOLD {
1717
1818 extension ControllerExtensions = new ControllerExtensions
1919 extension FormattingExtensions = new FormattingExtensions
@@ -26,6 +26,161 @@ class Actions {
2626 this . app = app
2727 }
2828
29+ def generate (Entity it , Action action , Boolean isBase ) '''
30+ «action.actionDoc (it , isBase )»
31+ public function «action.methodName»(
32+ «methodArguments (it , action )»
33+ ): Response {
34+ «IF isBase»
35+ «actionImpl(it , action)»
36+ «ELSE »
37+ return $this - > «action. methodName»(
38+ «methodArgsCall(it , action)»
39+ );
40+ «ENDIF »
41+ }
42+ ' ' '
43+
44+ def private actionDoc(Action it, Entity entity, Boolean isBase) ' ' '
45+ «IF isBase»
46+ /**
47+ * «actionDocMethodDescription»
48+ «actionDocMethodDocumentation»
49+ *
50+ * @throws AccessDeniedException Thrown if the user doesn't have required permissions
51+ «IF it instanceof DetailAction»
52+ * @throws NotFoundHttpException Thrown if «entity.name.formatForDisplay» to be displayed isn't found
53+ «ELSEIF it instanceof EditAction»
54+ * @throws RuntimeException Thrown if another critical error occurs (e.g. workflow actions not available)
55+ «ELSEIF it instanceof DeleteAction»
56+ * @throws NotFoundHttpException Thrown if «entity.name.formatForDisplay» to be deleted isn't found
57+ * @throws RuntimeException Thrown if another critical error occurs (e.g. workflow actions not available)
58+ «ENDIF»
59+ «IF it instanceof IndexAction || it instanceof EditAction»
60+ * @throws Exception
61+ «ENDIF»
62+ */
63+ «ENDIF »
64+ ' ' '
65+
66+ def private actionDocMethodDescription(Action it) {
67+ switch it {
68+ IndexAction: ' This action provides an item list overview. '
69+ DetailAction: ' This action provides a item detail view. '
70+ EditAction: ' This action provides a handling of edit requests. '
71+ DeleteAction: ' This action provides a handling of simple delete requests. '
72+ CustomAction: ' This is a custom action. '
73+ default: ' '
74+ }
75+ }
76+
77+ def private actionDocMethodDocumentation(Action it) {
78+ if (null !== documentation && !documentation.empty) {
79+ ' * ' + documentation.replace(' */ ' , ' * ' ) + (if (!documentation.endsWith(' . ' )) ' . ' )
80+ } else {
81+ ' '
82+ }
83+ }
84+
85+ def private methodName(Action it) ' ' ' «name. formatForCode. toFirstLower»OLD ' ' '
86+
87+ def private dispatch methodArguments(Entity it, Action action) ' ' '
88+ Request $request
89+ ' ' '
90+ def private dispatch methodArgsCall(Entity it, Action action) {
91+ ' ' '
92+ $request
93+ ' ' '
94+ }
95+
96+ def private dispatch methodArguments(Entity it, IndexAction action) ' ' '
97+ Request $request,
98+ RouterInterface $router,
99+ ControllerHelper $controllerHelper,
100+ ViewHelper $viewHelper,
101+ «IF loggable»
102+ LoggableHelper $loggableHelper,
103+ «ENDIF »
104+ string $sort,
105+ string $sortdir,
106+ int $page,
107+ int $num
108+ ' ' '
109+ def private dispatch methodArgsCall(Entity it, IndexAction action) {
110+ ' ' '
111+ $request,
112+ $router,
113+ $controllerHelper,
114+ $viewHelper,«IF loggable»
115+ $loggableHelper,«ENDIF »
116+ $sort,
117+ $sortdir,
118+ $page,
119+ $num
120+ ' ' '
121+ }
122+
123+ def private dispatch methodArguments(Entity it, DetailAction action) ' ' '
124+ Request $request,
125+ ControllerHelper $controllerHelper,
126+ ViewHelper $viewHelper,
127+ «name. formatForCodeCapital»RepositoryInterface $repository,
128+ «IF loggable»
129+ LoggableHelper $loggableHelper,
130+ «ENDIF »
131+ ? «name. formatForCodeCapital» $«name. formatForCode» = null ,
132+ «IF hasSluggableFields»string $slug = ' ' «ELSE »int $id = 0 «ENDIF »
133+ ' ' '
134+ def private dispatch methodArgsCall(Entity it, DetailAction action) {
135+ ' ' '
136+ $request,
137+ $controllerHelper,
138+ $viewHelper,
139+ $repository,«IF loggable»
140+ $loggableHelper,«ENDIF »
141+ $«name. formatForCode»,
142+ $«IF hasSluggableFields»slug«ELSE »id«ENDIF »
143+ ' ' '
144+ }
145+
146+ def private dispatch methodArguments(Entity it, EditAction action) ' ' '
147+ Request $request,
148+ ControllerHelper $controllerHelper,
149+ ViewHelper $viewHelper,
150+ EditHandler $formHandler
151+ ' ' '
152+ def private dispatch methodArgsCall(Entity it, EditAction action) {
153+ ' ' '
154+ $request,
155+ $controllerHelper,
156+ $viewHelper,
157+ $formHandler
158+ ' ' '
159+ }
160+
161+ def private dispatch methodArguments(Entity it, DeleteAction action) ' ' '
162+ Request $request,
163+ LoggerInterface $logger,
164+ ControllerHelper $controllerHelper,
165+ ViewHelper $viewHelper,
166+ «name. formatForCodeCapital»RepositoryInterface $repository,
167+ WorkflowHelper $workflowHelper,
168+ #[CurrentUser ] ? UserInterface $currentUser,
169+ «IF hasSluggableFields»string $slug«ELSE »int $id«ENDIF »
170+ ' ' '
171+ def private dispatch methodArgsCall(Entity it, DeleteAction action) {
172+ ' ' '
173+ $request,
174+ $logger,
175+ $controllerHelper,
176+ $viewHelper,
177+ $repository,
178+ $workflowHelper,
179+ $currentUser,
180+ $«IF hasSluggableFields»slug«ELSE »id«ENDIF »
181+ ' ' '
182+ }
183+
29184 // TODO DeleteAction is not generated anymore
30185 // but kept here because of workflow usage that needs to be added to EAB
31186
@@ -174,8 +329,7 @@ class Actions {
174329 ' ' '
175330
176331 def private dispatch actionImplBody(Entity it, EditAction action) ' ' '
177- $templateParameters = [
178- ];
332+ $templateParameters = [];
179333
180334 // delegate form processing to the form handler
181335 $result = $formHandler- > processForm($templateParameters);
0 commit comments