src/AppBundle/Controller/EmbarcacionMarcaController.php
/**
     * Creates a new embarcacionMarca entity.
     *
     * @Route("/new", name="embarcacion_marca_new")
     * @Method({"GET", "POST"})
     */
Creates a new embarcacionMarca entity.
Creates a new embarcacionMarca entity .
public function newAction(Request $request)
    {
        $em = $this->getDoctrine()->getManager();
        $marcasRepo = $em->getRepository('AppBundle:EmbarcacionMarca');
        $query = $request->query;
        $page = (int)$query->get('page') ?: 1;
        $marca = (int)$query->get('marca') ?: null;
        $marca = $marca ? $marcasRepo->find($marca) : new Embarcacionmarca();
        $newForm = $this->createForm('AppBundle\Form\EmbarcacionMarcaType', $marca);
        $newForm->handleRequest($request);
        $paginacion = $marcasRepo->paginacion($page);
        $marcas = $paginacion['marcas']->getQuery()->getResult();
        if ($page > $paginacion['pages'] && $paginacion['total'] > 0) {
            return $this->redirectToRoute('embarcacion_marca_new', ['page' => $paginacion['pages']]);
        }
        $deleteForms = [];
        foreach ($marcas as $formMarca) {
            $deleteForms[] = $this->createDeleteForm($formMarca['id'])->createView();
        }
        if ($newForm->isSubmitted() && $newForm->isValid()) {
            $em->persist($marca);
            $em->flush();
            return $this->redirectToRoute('embarcacion_marca_new');
        }
        return $this->render('embarcacion/marca/new.html.twig', [
            'marca' => $marca,
            'embarcacionMarcas' => $marcas,
            'newForm' => $newForm->createView(),
            'deleteForms' => $deleteForms,
            'page' => $page,
            'pages' => $paginacion['pages']
        ]);
    }
public function newAction ( Request $ request ) { $ em = $ this -> getDoctrine ( ) -> getManager ( ) ; $ marcasRepo = $ em -> getRepository ( 'AppBundle:EmbarcacionMarca' ) ; $ query = $ request -> query ; $ page = ( int ) $ query -> get ( 'page' ) ? : 1 ; $ marca = ( int ) $ query -> get ( 'marca' ) ? : null ; $ marca = $ marca ? $ marcasRepo -> find ( $ marca ) : new Embarcacionmarca ( ) ; $ newForm = $ this -> createForm ( 'AppBundle\Form\EmbarcacionMarcaType' , $ marca ) ; $ newForm -> handleRequest ( $ request ) ; $ paginacion = $ marcasRepo -> paginacion ( $ page ) ; $ marcas = $ paginacion [ 'marcas' ] -> getQuery ( ) -> getResult ( ) ; if ( $ page > $ paginacion [ 'pages' ] && $ paginacion [ 'total' ] > 0 ) { return $ this -> redirectToRoute ( 'embarcacion_marca_new' , [ 'page' => $ paginacion [ 'pages' ] ] ) ; } $ deleteForms = [ ] ; foreach ( $ marcas as $ formMarca ) { $ deleteForms [ ] = $ this -> createDeleteForm ( $ formMarca [ 'id' ] ) -> createView ( ) ; } if ( $ newForm -> isSubmitted ( ) && $ newForm -> isValid ( ) ) { $ em -> persist ( $ marca ) ; $ em -> flush ( ) ; return $ this -> redirectToRoute ( 'embarcacion_marca_new' ) ; } return $ this -> render ( 'embarcacion/marca/new.html.twig' , [ 'marca' => $ marca , 'embarcacionMarcas' => $ marcas , 'newForm' => $ newForm -> createView ( ) , 'deleteForms' => $ deleteForms , 'page' => $ page , 'pages' => $ paginacion [ 'pages' ] ] ) ; }
Creates a new embarcacionMarca entity.
Creates a new embarcacionMarca entity .