Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace AppBundle\Controller;
- use AppBundle\Entity\Plachta;
- use AppBundle\Entity\Pracownik;
- use AppBundle\Entity\Przedmiot;
- use AppBundle\Entity\Przydzial;
- use AppBundle\Entity\Semestr;
- use AppBundle\Entity\StudiaTyp;
- use Symfony\Bundle\FrameworkBundle\Controller\Controller;
- use Symfony\Component\HttpFoundation\Request;
- use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
- /**
- * Plachtum controller.
- *
- */
- class PlachtaController extends Controller
- {
- /**
- * @Route("/all", name="pracownik_index")
- */
- public function indexAction()
- {
- $em = $this->getDoctrine()->getManager();
- $plachtas = $em->getRepository('AppBundle:Plachta')->findAll();
- return $this->render('plachta/index.html.twig', array(
- 'plachtas' => $plachtas,
- ));
- }
- /**
- * @Route("/new", name="pracownik_new")
- */
- public function newAction(Request $request)
- {
- $plachtum = new Plachta();
- $form = $this->createForm('AppBundle\Form\PlachtaType', $plachtum);
- $form->handleRequest($request);
- if ($form->isSubmitted() && $form->isValid()) {
- $em = $this->getDoctrine()->getManager();
- $em->persist($plachtum);
- $em->flush($plachtum);
- return $this->redirectToRoute('plachta_show', array('idPlachta' => $plachtum->getIdPlachta()));
- }
- return $this->render('plachta/new.html.twig', array(
- 'plachtum' => $plachtum,
- 'form' => $form->createView(),
- ));
- }
- /**
- * Finds and displays a plachtum entity.
- *
- */
- public function showAction(Plachta $plachtum)
- {
- $em = $this->getDoctrine()->getManager();
- $pracowniks = $em->getRepository('AppBundle:Pracownik')->findByIdPlachta($plachtum);
- $przedmiots = $em->getRepository('AppBundle:Przedmiot')->findByIdPlachta($plachtum);
- $przydzials = $em->getRepository('AppBundle:Przydzial')->findByIdPlachta($plachtum);
- $semestrs = $em->getRepository('AppBundle:Semestr')->findByIdPlachta($plachtum);
- $studiaTyps = $em->getRepository('AppBundle:StudiaTyp')->findByIdPlachta($plachtum);
- $deleteForm = $this->createDeleteForm($plachtum);
- return $this->render('plachta/show.html.twig', array(
- 'plachtum' => $plachtum,
- 'pracowniks'=>$pracowniks,
- 'przedmiots'=>$przedmiots,
- 'przydzials'=>$przydzials,
- 'semestrs'=>$semestrs,
- 'studiaTyps'=>$studiaTyps,
- 'delete_form' => $deleteForm->createView(),
- ));
- }
- /**
- * Displays a form to edit an existing plachtum entity.
- *
- */
- public function editAction(Request $request, Plachta $plachtum)
- {
- $deleteForm = $this->createDeleteForm($plachtum);
- $editForm = $this->createForm('AppBundle\Form\PlachtaType', $plachtum);
- $editForm->handleRequest($request);
- if ($editForm->isSubmitted() && $editForm->isValid()) {
- $this->getDoctrine()->getManager()->flush();
- return $this->redirectToRoute('plachta_edit', array('idPlachta' => $plachtum->getIdPlachta()));
- }
- return $this->render('plachta/edit.html.twig', array(
- 'plachtum' => $plachtum,
- 'edit_form' => $editForm->createView(),
- 'delete_form' => $deleteForm->createView(),
- ));
- }
- /**
- * Deletes a plachtum entity.
- *
- */
- public function deleteAction(Request $request, Plachta $plachtum)
- {
- $form = $this->createDeleteForm($plachtum);
- $form->handleRequest($request);
- if ($form->isSubmitted() && $form->isValid()) {
- $em = $this->getDoctrine()->getManager();
- $em->remove($plachtum);
- $em->flush($plachtum);
- }
- return $this->redirectToRoute('plachta_index');
- }
- /**
- * Creates a form to delete a plachtum entity.
- *
- * @param Plachta $plachtum The plachtum entity
- *
- * @return \Symfony\Component\Form\Form The form
- */
- private function createDeleteForm(Plachta $plachtum)
- {
- return $this->createFormBuilder()
- ->setAction($this->generateUrl('plachta_delete', array('idPlachta' => $plachtum->getIdPlachta())))
- ->setMethod('DELETE')
- ->getForm()
- ;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement