mirror of
				https://gitlab.com/Chill-Projet/chill-bundles.git
				synced 2025-11-03 18:58:24 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			187 lines
		
	
	
		
			5.5 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			187 lines
		
	
	
		
			5.5 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
<?php
 | 
						|
 | 
						|
/**
 | 
						|
 * Chill is a software for social workers
 | 
						|
 *
 | 
						|
 * For the full copyright and license information, please view
 | 
						|
 * the LICENSE file that was distributed with this source code.
 | 
						|
 */
 | 
						|
 | 
						|
declare(strict_types=1);
 | 
						|
 | 
						|
namespace Chill\ActivityBundle\Controller;
 | 
						|
 | 
						|
use Chill\ActivityBundle\Entity\ActivityReasonCategory;
 | 
						|
use Chill\ActivityBundle\Form\ActivityReasonCategoryType;
 | 
						|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
 | 
						|
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
 | 
						|
use Symfony\Component\HttpFoundation\Request;
 | 
						|
 | 
						|
/**
 | 
						|
 * ActivityReasonCategory controller.
 | 
						|
 */
 | 
						|
class ActivityReasonCategoryController extends AbstractController
 | 
						|
{
 | 
						|
    /**
 | 
						|
     * Creates a new ActivityReasonCategory entity.
 | 
						|
     */
 | 
						|
    public function createAction(Request $request)
 | 
						|
    {
 | 
						|
        $entity = new ActivityReasonCategory();
 | 
						|
        $form = $this->createCreateForm($entity);
 | 
						|
        $form->handleRequest($request);
 | 
						|
 | 
						|
        if ($form->isValid()) {
 | 
						|
            $em = $this->getDoctrine()->getManager();
 | 
						|
            $em->persist($entity);
 | 
						|
            $em->flush();
 | 
						|
 | 
						|
            return $this->redirect($this->generateUrl('chill_activity_activityreasoncategory_show', ['id' => $entity->getId()]));
 | 
						|
        }
 | 
						|
 | 
						|
        return $this->render('ChillActivityBundle:ActivityReasonCategory:new.html.twig', [
 | 
						|
            'entity' => $entity,
 | 
						|
            'form' => $form->createView(),
 | 
						|
        ]);
 | 
						|
    }
 | 
						|
 | 
						|
    /**
 | 
						|
     * Displays a form to edit an existing ActivityReasonCategory entity.
 | 
						|
     *
 | 
						|
     * @param mixed $id
 | 
						|
     */
 | 
						|
    public function editAction($id)
 | 
						|
    {
 | 
						|
        $em = $this->getDoctrine()->getManager();
 | 
						|
 | 
						|
        $entity = $em->getRepository('ChillActivityBundle:ActivityReasonCategory')->find($id);
 | 
						|
 | 
						|
        if (!$entity) {
 | 
						|
            throw $this->createNotFoundException('Unable to find ActivityReasonCategory entity.');
 | 
						|
        }
 | 
						|
 | 
						|
        $editForm = $this->createEditForm($entity);
 | 
						|
 | 
						|
        return $this->render('ChillActivityBundle:ActivityReasonCategory:edit.html.twig', [
 | 
						|
            'entity' => $entity,
 | 
						|
            'edit_form' => $editForm->createView(),
 | 
						|
        ]);
 | 
						|
    }
 | 
						|
 | 
						|
    /**
 | 
						|
     * Lists all ActivityReasonCategory entities.
 | 
						|
     */
 | 
						|
    public function indexAction()
 | 
						|
    {
 | 
						|
        $em = $this->getDoctrine()->getManager();
 | 
						|
 | 
						|
        $entities = $em->getRepository('ChillActivityBundle:ActivityReasonCategory')->findAll();
 | 
						|
 | 
						|
        return $this->render('ChillActivityBundle:ActivityReasonCategory:index.html.twig', [
 | 
						|
            'entities' => $entities,
 | 
						|
        ]);
 | 
						|
    }
 | 
						|
 | 
						|
    /**
 | 
						|
     * Displays a form to create a new ActivityReasonCategory entity.
 | 
						|
     */
 | 
						|
    public function newAction()
 | 
						|
    {
 | 
						|
        $entity = new ActivityReasonCategory();
 | 
						|
        $form = $this->createCreateForm($entity);
 | 
						|
 | 
						|
        return $this->render('ChillActivityBundle:ActivityReasonCategory:new.html.twig', [
 | 
						|
            'entity' => $entity,
 | 
						|
            'form' => $form->createView(),
 | 
						|
        ]);
 | 
						|
    }
 | 
						|
 | 
						|
    /**
 | 
						|
     * Finds and displays a ActivityReasonCategory entity.
 | 
						|
     *
 | 
						|
     * @param mixed $id
 | 
						|
     */
 | 
						|
    public function showAction($id)
 | 
						|
    {
 | 
						|
        $em = $this->getDoctrine()->getManager();
 | 
						|
 | 
						|
        $entity = $em->getRepository('ChillActivityBundle:ActivityReasonCategory')->find($id);
 | 
						|
 | 
						|
        if (!$entity) {
 | 
						|
            throw $this->createNotFoundException('Unable to find ActivityReasonCategory entity.');
 | 
						|
        }
 | 
						|
 | 
						|
        return $this->render('ChillActivityBundle:ActivityReasonCategory:show.html.twig', [
 | 
						|
            'entity' => $entity,
 | 
						|
        ]);
 | 
						|
    }
 | 
						|
 | 
						|
    /**
 | 
						|
     * Edits an existing ActivityReasonCategory entity.
 | 
						|
     *
 | 
						|
     * @param mixed $id
 | 
						|
     */
 | 
						|
    public function updateAction(Request $request, $id)
 | 
						|
    {
 | 
						|
        $em = $this->getDoctrine()->getManager();
 | 
						|
 | 
						|
        $entity = $em->getRepository('ChillActivityBundle:ActivityReasonCategory')->find($id);
 | 
						|
 | 
						|
        if (!$entity) {
 | 
						|
            throw $this->createNotFoundException('Unable to find ActivityReasonCategory entity.');
 | 
						|
        }
 | 
						|
 | 
						|
        $editForm = $this->createEditForm($entity);
 | 
						|
        $editForm->handleRequest($request);
 | 
						|
 | 
						|
        if ($editForm->isValid()) {
 | 
						|
            $em->flush();
 | 
						|
 | 
						|
            return $this->redirect($this->generateUrl('chill_activity_activityreasoncategory_edit', ['id' => $id]));
 | 
						|
        }
 | 
						|
 | 
						|
        return $this->render('ChillActivityBundle:ActivityReasonCategory:edit.html.twig', [
 | 
						|
            'entity' => $entity,
 | 
						|
            'edit_form' => $editForm->createView(),
 | 
						|
        ]);
 | 
						|
    }
 | 
						|
 | 
						|
    /**
 | 
						|
     * Creates a form to create a ActivityReasonCategory entity.
 | 
						|
     *
 | 
						|
     * @param ActivityReasonCategory $entity The entity
 | 
						|
     *
 | 
						|
     * @return \Symfony\Component\Form\Form The form
 | 
						|
     */
 | 
						|
    private function createCreateForm(ActivityReasonCategory $entity)
 | 
						|
    {
 | 
						|
        $form = $this->createForm(ActivityReasonCategoryType::class, $entity, [
 | 
						|
            'action' => $this->generateUrl('chill_activity_activityreasoncategory_create'),
 | 
						|
            'method' => 'POST',
 | 
						|
        ]);
 | 
						|
 | 
						|
        $form->add('submit', SubmitType::class, ['label' => 'Create']);
 | 
						|
 | 
						|
        return $form;
 | 
						|
    }
 | 
						|
 | 
						|
    /**
 | 
						|
     * Creates a form to edit a ActivityReasonCategory entity.
 | 
						|
     *
 | 
						|
     * @param ActivityReasonCategory $entity The entity
 | 
						|
     *
 | 
						|
     * @return \Symfony\Component\Form\Form The form
 | 
						|
     */
 | 
						|
    private function createEditForm(ActivityReasonCategory $entity)
 | 
						|
    {
 | 
						|
        $form = $this->createForm(ActivityReasonCategoryType::class, $entity, [
 | 
						|
            'action' => $this->generateUrl('chill_activity_activityreasoncategory_update', ['id' => $entity->getId()]),
 | 
						|
            'method' => 'PUT',
 | 
						|
        ]);
 | 
						|
 | 
						|
        $form->add('submit', SubmitType::class, ['label' => 'Update']);
 | 
						|
 | 
						|
        return $form;
 | 
						|
    }
 | 
						|
}
 |