src/Sulu/Bundle/ContactBundle/Controller/ContactTitleController.php
public function postAction(Request $request)
    {
        $name = $request->get('title');

        try {
            if (null == $name) {
                throw new RestException(
                    'There is no title-name for the given title'
                );
            }

            $em = $this->getDoctrine()->getManager();
            $title = new ContactTitle();
            $title->setTitle($name);

            $em->persist($title);
            $em->flush();

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

        return $this->handleView($view);
    }
public function postAction(Request $request)
    {
        $name = $request->get('title');

        try {
            if (null == $name) {
                throw new RestException(
                    'There is no title-name for the given title'
                );
            }

            $em = $this->getDoctrine()->getManager();
            $title = new ContactTitle();
            $title->setTitle($name);

            $em->persist($title);
            $em->flush();

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

        return $this->handleView($view);
    }
public function postAction ( Request $ request ) { $ name = $ request -> get ( 'title' ) ; try { if ( null == $ name ) { throw new RestException ( 'There is no title-name for the given title' ) ; } $ em = $ this -> getDoctrine ( ) -> getManager ( ) ; $ title = new ContactTitle ( ) ; $ title -> setTitle ( $ name ) ; $ em -> persist ( $ title ) ; $ em -> flush ( ) ; $ view = $ this -> view ( $ title , 200 ) ; } catch ( EntityNotFoundException $ enfe ) { $ view = $ this -> view ( $ enfe -> toArray ( ) , 404 ) ; } catch ( RestException $ re ) { $ view = $ this -> view ( $ re -> toArray ( ) , 400 ) ; } return $ this -> handleView ( $ view ) ; }
Creates a new contact title.

@param \Symfony\Component\HttpFoundation\Request $request

@return \Symfony\Component\HttpFoundation\Response
Creates a new contact title .