mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-09-02 13:03:50 +00:00
First step of integration code generated
This commit is contained in:
@@ -1,5 +1,25 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* Copyright (C) 2014-2015, Champs Libres Cooperative SCRLFS,
|
||||
* <http://www.champs-libres.coop>, <info@champs-libres.coop>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
namespace Chill\ActivityBundle\Controller;
|
||||
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
@@ -19,24 +39,28 @@ class ActivityController extends Controller
|
||||
* Lists all Activity entities.
|
||||
*
|
||||
*/
|
||||
public function indexAction()
|
||||
public function listAction($person_id, Request $request)
|
||||
{
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
$person = $em->getRepository('ChillPersonBundle:Person')->find($person_id);
|
||||
$activities = $em->getRepository('ChillActivityBundle:Activity')->findAll();
|
||||
|
||||
$entities = $em->getRepository('ChillActivityBundle:Activity')->findAll();
|
||||
|
||||
return $this->render('ChillActivityBundle:Activity:index.html.twig', array(
|
||||
'entities' => $entities,
|
||||
return $this->render('ChillActivityBundle:Activity:list.html.twig', array(
|
||||
'activities' => $activities,
|
||||
'person' => $person
|
||||
));
|
||||
}
|
||||
/**
|
||||
* Creates a new Activity entity.
|
||||
*
|
||||
*/
|
||||
public function createAction(Request $request)
|
||||
public function createAction($person_id, Request $request)
|
||||
{
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
$person = $em->getRepository('ChillPersonBundle:Person')->find($person_id);
|
||||
|
||||
$entity = new Activity();
|
||||
$form = $this->createCreateForm($entity);
|
||||
$form = $this->createCreateForm($entity, $person);
|
||||
$form->handleRequest($request);
|
||||
|
||||
if ($form->isValid()) {
|
||||
@@ -44,12 +68,13 @@ class ActivityController extends Controller
|
||||
$em->persist($entity);
|
||||
$em->flush();
|
||||
|
||||
return $this->redirect($this->generateUrl('activity_show', array('id' => $entity->getId())));
|
||||
return $this->redirect($this->generateUrl('chill_activity_activity_show', array('id' => $entity->getId())));
|
||||
}
|
||||
|
||||
return $this->render('ChillActivityBundle:Activity:new.html.twig', array(
|
||||
'entity' => $entity,
|
||||
'form' => $form->createView(),
|
||||
'person' => $person
|
||||
));
|
||||
}
|
||||
|
||||
@@ -60,10 +85,10 @@ class ActivityController extends Controller
|
||||
*
|
||||
* @return \Symfony\Component\Form\Form The form
|
||||
*/
|
||||
private function createCreateForm(Activity $entity)
|
||||
private function createCreateForm(Activity $entity, $person)
|
||||
{
|
||||
$form = $this->createForm(new ActivityType(), $entity, array(
|
||||
'action' => $this->generateUrl('activity_create'),
|
||||
'action' => $this->generateUrl('chill_activity_activity_create', ['person_id' => $person->getId()]),
|
||||
'method' => 'POST',
|
||||
));
|
||||
|
||||
@@ -76,12 +101,16 @@ class ActivityController extends Controller
|
||||
* Displays a form to create a new Activity entity.
|
||||
*
|
||||
*/
|
||||
public function newAction()
|
||||
public function newAction($person_id)
|
||||
{
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
$person = $em->getRepository('ChillPersonBundle:Person')->find($person_id);
|
||||
|
||||
$entity = new Activity();
|
||||
$form = $this->createCreateForm($entity);
|
||||
$form = $this->createCreateForm($entity, $person);
|
||||
|
||||
return $this->render('ChillActivityBundle:Activity:new.html.twig', array(
|
||||
'person' => $person,
|
||||
'entity' => $entity,
|
||||
'form' => $form->createView(),
|
||||
));
|
||||
@@ -113,9 +142,10 @@ class ActivityController extends Controller
|
||||
* Displays a form to edit an existing Activity entity.
|
||||
*
|
||||
*/
|
||||
public function editAction($id)
|
||||
public function editAction($person_id, $id)
|
||||
{
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
$person = $em->getRepository('ChillPersonBundle:Person')->find($person_id);
|
||||
|
||||
$entity = $em->getRepository('ChillActivityBundle:Activity')->find($id);
|
||||
|
||||
@@ -130,6 +160,7 @@ class ActivityController extends Controller
|
||||
'entity' => $entity,
|
||||
'edit_form' => $editForm->createView(),
|
||||
'delete_form' => $deleteForm->createView(),
|
||||
'person' => $$person
|
||||
));
|
||||
}
|
||||
|
||||
@@ -143,7 +174,7 @@ class ActivityController extends Controller
|
||||
private function createEditForm(Activity $entity)
|
||||
{
|
||||
$form = $this->createForm(new ActivityType(), $entity, array(
|
||||
'action' => $this->generateUrl('activity_update', array('id' => $entity->getId())),
|
||||
'action' => $this->generateUrl('chill_activity_activity_update', array('id' => $entity->getId())),
|
||||
'method' => 'PUT',
|
||||
));
|
||||
|
||||
@@ -172,7 +203,7 @@ class ActivityController extends Controller
|
||||
if ($editForm->isValid()) {
|
||||
$em->flush();
|
||||
|
||||
return $this->redirect($this->generateUrl('activity_edit', array('id' => $id)));
|
||||
return $this->redirect($this->generateUrl('chill_activity_activity_edit', array('id' => $id)));
|
||||
}
|
||||
|
||||
return $this->render('ChillActivityBundle:Activity:edit.html.twig', array(
|
||||
@@ -215,7 +246,7 @@ class ActivityController extends Controller
|
||||
private function createDeleteForm($id)
|
||||
{
|
||||
return $this->createFormBuilder()
|
||||
->setAction($this->generateUrl('activity_delete', array('id' => $id)))
|
||||
->setAction($this->generateUrl('chill_activity_activity_delete', array('id' => $id)))
|
||||
->setMethod('DELETE')
|
||||
->add('submit', 'submit', array('label' => 'Delete'))
|
||||
->getForm()
|
||||
|
Reference in New Issue
Block a user