Sulu\Bundle\ContactBundle\Controller\ContactTitleController::putAction PHP Метод

putAction() публичный Метод

Edits the existing contact title for the given id.
public putAction ( Request $request, integer $id ) : Response
$request Symfony\Component\HttpFoundation\Request
$id integer The id of the title to update
Результат Symfony\Component\HttpFoundation\Response
    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);
    }