src/Sulu/Bundle/ContactBundle/Controller/ContactTitleController.php
public function putAction(Request $request, $id)
    {
        try {
            /** @var ContactTitle $title */
            $title = $this->getDoctrine()
                ->getRepository(self::$entityName)
                ->find($id);

            if (!$title) {
                throw new EntityNotFoundException(self::$entityName, $id);
            } else {
                $name = $request->get('title');

                if (empty($name)) {
                    throw new RestException('There is no title-name for the given title');
                } else {
                    $em = $this->getDoctrine()->getManager();
                    $title->setTitle($name);

                    $em->flush();
                    $view = $this->view($title, 200);
                }
            }
        } catch (EntityNotFoundException $enfe) {
            $view = $this->view($enfe->toArray(), 404);
        } catch (RestException $exc) {
            $view = $this->view($exc->toArray(), 400);
        }

        return $this->handleView($view);
    }
public function putAction(Request $request, $id)
    {
        try {
            /** @var ContactTitle $title */
            $title = $this->getDoctrine()
                ->getRepository(self::$entityName)
                ->find($id);

            if (!$title) {
                throw new EntityNotFoundException(self::$entityName, $id);
            } else {
                $name = $request->get('title');

                if (empty($name)) {
                    throw new RestException('There is no title-name for the given title');
                } else {
                    $em = $this->getDoctrine()->getManager();
                    $title->setTitle($name);

                    $em->flush();
                    $view = $this->view($title, 200);
                }
            }
        } catch (EntityNotFoundException $enfe) {
            $view = $this->view($enfe->toArray(), 404);
        } catch (RestException $exc) {
            $view = $this->view($exc->toArray(), 400);
        }

        return $this->handleView($view);
    }
public function putAction ( Request $ request , $ id ) { try { /** @var ContactTitle $title */ $ title = $ this -> getDoctrine ( ) -> getRepository ( self :: $ entityName ) -> find ( $ id ) ; if ( ! $ title ) { throw new EntityNotFoundException ( self :: $ entityName , $ id ) ; } else { $ name = $ request -> get ( 'title' ) ; if ( empty ( $ name ) ) { throw new RestException ( 'There is no title-name for the given title' ) ; } else { $ em = $ this -> getDoctrine ( ) -> getManager ( ) ; $ title -> setTitle ( $ name ) ; $ em -> flush ( ) ; $ view = $ this -> view ( $ title , 200 ) ; } } } catch ( EntityNotFoundException $ enfe ) { $ view = $ this -> view ( $ enfe -> toArray ( ) , 404 ) ; } catch ( RestException $ exc ) { $ view = $ this -> view ( $ exc -> toArray ( ) , 400 ) ; } return $ this -> handleView ( $ view ) ; }
Edits the existing contact title for the given id.

@param \Symfony\Component\HttpFoundation\Request $request
@param int $id The id of the title to update

@return \Symfony\Component\HttpFoundation\Response
Edits the existing contact title for the given id .