1 | <?php |
||
24 | class BusinessTemplateController extends Controller |
||
25 | { |
||
26 | use VictoireAlertifyControllerTrait; |
||
27 | |||
28 | /** |
||
29 | * List all business entity page pattern. |
||
30 | * |
||
31 | * @Route("/", name="victoire_business_template_index") |
||
32 | * |
||
33 | * @return JsonResponse |
||
34 | */ |
||
35 | public function indexAction() |
||
63 | |||
64 | /** |
||
65 | * Show BusinessTemplate. |
||
66 | * |
||
67 | * @param BusinessTemplate $view |
||
68 | * |
||
69 | * @Route("/show/{id}", name="victoire_business_template_show") |
||
70 | * @ParamConverter("template", class="VictoireBusinessPageBundle:BusinessTemplate") |
||
71 | * |
||
72 | * @return Response |
||
73 | */ |
||
74 | public function showAction(BusinessTemplate $view) |
||
82 | |||
83 | /** |
||
84 | * Creates a new BusinessTemplate entity. |
||
85 | * |
||
86 | * @param Request $request |
||
87 | * @param int $id |
||
88 | * |
||
89 | * @Route("{id}/create", name="victoire_business_template_create") |
||
90 | * @Method("POST") |
||
91 | * @Template("VictoireBusinessPageBundle:BusinessTemplate:new.html.twig") |
||
92 | * |
||
93 | * @return JsonResponse |
||
94 | */ |
||
95 | public function createAction(Request $request, $id) |
||
129 | |||
130 | /** |
||
131 | * Creates a form to create a BusinessTemplate entity. |
||
132 | * |
||
133 | * @param BusinessTemplate $view The entity |
||
134 | * |
||
135 | * @return \Symfony\Component\Form\Form The form |
||
136 | * @return Form |
||
137 | */ |
||
138 | private function createCreateForm(BusinessTemplate $view) |
||
155 | |||
156 | /** |
||
157 | * Displays a form to create a new BusinessTemplate entity. |
||
158 | * |
||
159 | * @param string $id The id of the businessEntity |
||
160 | * |
||
161 | * @Route("/{id}/new", name="victoire_business_template_new") |
||
162 | * @Method("GET") |
||
163 | * @Template() |
||
164 | * |
||
165 | * @return JsonResponse The entity and the form |
||
166 | */ |
||
167 | public function newAction($id) |
||
191 | |||
192 | /** |
||
193 | * Displays a form to edit an existing BusinessTemplate entity. |
||
194 | * |
||
195 | * @Route("/{id}/edit", name="victoire_business_template_edit") |
||
196 | * @Method("GET") |
||
197 | * @Template() |
||
198 | * @ParamConverter("id", class="VictoireCoreBundle:View") |
||
199 | * |
||
200 | * @throws \Exception |
||
201 | * |
||
202 | * @return JsonResponse The entity and the form |
||
203 | */ |
||
204 | public function editAction(View $view) |
||
223 | |||
224 | /** |
||
225 | * Creates a form to edit a BusinessTemplate entity. |
||
226 | * |
||
227 | * @param BusinessTemplate $view The entity |
||
228 | * |
||
229 | * @return \Symfony\Component\Form\Form The form |
||
230 | */ |
||
231 | private function createEditForm(BusinessTemplate $view) |
||
243 | |||
244 | /** |
||
245 | * Edits an existing BusinessTemplate entity. |
||
246 | * |
||
247 | * @param Request $request |
||
248 | * @param string $id |
||
249 | * |
||
250 | * @Route("/{id}", name="victoire_business_template_update") |
||
251 | * @Method("PUT") |
||
252 | * @Template("VictoireBusinessPageBundle:BusinessTemplate:edit.html.twig") |
||
253 | * |
||
254 | * @throws \Exception |
||
255 | * |
||
256 | * @return JsonResponse The parameter for the response |
||
257 | */ |
||
258 | public function updateAction(Request $request, $id) |
||
292 | |||
293 | /** |
||
294 | * Deletes a BusinessTemplate entity. |
||
295 | * |
||
296 | * @param Request $request |
||
297 | * @param string $id |
||
298 | * |
||
299 | * @Route("/{id}", name="victoire_business_template_delete") |
||
300 | * @Method("DELETE") |
||
301 | * |
||
302 | * @throws \Exception |
||
303 | * |
||
304 | * @return \Symfony\Component\HttpFoundation\RedirectResponse |
||
305 | */ |
||
306 | public function deleteAction(Request $request, $id) |
||
307 | { |
||
308 | $form = $this->createDeleteForm($id); |
||
309 | $form->handleRequest($request); |
||
310 | |||
311 | if ($form->isValid()) { |
||
312 | $em = $this->getDoctrine()->getManager(); |
||
313 | $view = $em->getRepository('VictoireBusinessPageBundle:BusinessTemplate')->find($id); |
||
314 | |||
315 | if (!$view) { |
||
316 | throw $this->createNotFoundException('Unable to find BusinessTemplate entity.'); |
||
317 | } |
||
318 | |||
319 | $em->remove($view); |
||
320 | $em->flush(); |
||
321 | } |
||
322 | |||
323 | return $this->redirect($this->generateUrl('victoire_business_template_index')); |
||
324 | } |
||
325 | |||
326 | /** |
||
327 | * Creates a form to delete a BusinessTemplate entity by id. |
||
328 | * |
||
329 | * @param string $id The entity id |
||
330 | * |
||
331 | * @return \Symfony\Component\Form\Form The form |
||
332 | */ |
||
333 | private function createDeleteForm($id) |
||
334 | { |
||
335 | return $this->createFormBuilder() |
||
336 | ->setAction($this->generateUrl('victoire_business_template_delete', ['id' => $id])) |
||
337 | ->setMethod('DELETE') |
||
338 | ->add('submit', 'submit', ['label' => 'Delete']) |
||
339 | ->getForm(); |
||
340 | } |
||
341 | |||
342 | /** |
||
343 | * List the entities that matches the query of the BusinessTemplate. |
||
344 | * |
||
345 | * @param BusinessTemplate $view |
||
346 | * |
||
347 | * @Route("/listEntities/{id}", name="victoire_business_template_listentities") |
||
348 | * @ParamConverter("id", class="VictoireBusinessPageBundle:BusinessTemplate") |
||
349 | * @Template |
||
350 | * |
||
351 | * @throws Exception |
||
352 | * |
||
353 | * @return array|Response The list of items for this template |
||
354 | */ |
||
355 | public function listEntitiesAction(BusinessTemplate $view) |
||
366 | |||
367 | /** |
||
368 | * Get an array of business properties by the business entity page pattern. |
||
369 | * |
||
370 | * @param BusinessTemplate $view |
||
371 | * |
||
372 | * @return array of business properties |
||
373 | */ |
||
374 | private function getBusinessProperties(BusinessTemplate $view) |
||
385 | |||
386 | /** |
||
387 | * @param string $id The id of the business entity |
||
388 | * |
||
389 | * @throws Exception If the business entity was not found |
||
390 | * |
||
391 | * @return \Victoire\Bundle\BusinessEntityBundle\Entity\BusinessEntity |
||
392 | */ |
||
393 | private function getBusinessEntity($id) |
||
408 | } |
||
409 |