src/Dpavic/JobsBundle/Controller/JobController.php
/**
     * Edits an existing Job entity.
     *
     * @Route("/{token}/update", name="job_update")
     * @Method("POST")
     * @Template("DpavicJobsBundle:Job:edit.html.twig")
     */
Edits an existing Job entity.
Edits an existing Job entity .
public function updateAction(Request $request, $token)
    {
        $em = $this->getDoctrine()->getManager();
        $entity = $em->getRepository('DpavicJobsBundle:Job')->findOneByToken($token);
        if (!$entity) {
            throw $this->createNotFoundException('Unable to find Job entity.');
        }
        $deleteForm = $this->createDeleteForm($token);
        $editForm = $this->createForm(new JobType(), $entity);
        $editForm->bind($request);
        if ($editForm->isValid()) {
            $em->persist($entity);
            $em->flush();
            return $this->redirect($this->generateUrl('job_preview', array(
                                'company' => $entity->getCompanySlug(),
                                'location' => $entity->getLocationSlug(),
                                'token' => $entity->getToken(),
                                'position' => $entity->getPositionSlug()
            )));
        }
        return array(
            'entity' => $entity,
            'edit_form' => $editForm->createView(),
            'delete_form' => $deleteForm->createView(),
        );
    }
public function updateAction ( Request $ request , $ token ) { $ em = $ this -> getDoctrine ( ) -> getManager ( ) ; $ entity = $ em -> getRepository ( 'DpavicJobsBundle:Job' ) -> findOneByToken ( $ token ) ; if ( ! $ entity ) { throw $ this -> createNotFoundException ( 'Unable to find Job entity.' ) ; } $ deleteForm = $ this -> createDeleteForm ( $ token ) ; $ editForm = $ this -> createForm ( new JobType ( ) , $ entity ) ; $ editForm -> bind ( $ request ) ; if ( $ editForm -> isValid ( ) ) { $ em -> persist ( $ entity ) ; $ em -> flush ( ) ; return $ this -> redirect ( $ this -> generateUrl ( 'job_preview' , array ( 'company' => $ entity -> getCompanySlug ( ) , 'location' => $ entity -> getLocationSlug ( ) , 'token' => $ entity -> getToken ( ) , 'position' => $ entity -> getPositionSlug ( ) ) ) ) ; } return array ( 'entity' => $ entity , 'edit_form' => $ editForm -> createView ( ) , 'delete_form' => $ deleteForm -> createView ( ) , ) ; }
Edits an existing Job entity.
Edits an existing Job entity .