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);
}