Ojs\ApiBundle\Controller\Admin\ContactTypesRestController::patchContacttypeAction PHP Method

patchContacttypeAction() public method

Update existing contact type from the submitted data or create a new contact type at a specific location.
public patchContacttypeAction ( Request $request, integer $id ) : Symfony\Component\Form\FormTypeInterface | FOS\RestBundle\View\View
$request Symfony\Component\HttpFoundation\Request the request object
$id integer the contact type id
return Symfony\Component\Form\FormTypeInterface | FOS\RestBundle\View\View
    public function patchContacttypeAction(Request $request, $id)
    {
        try {
            $entity = $this->container->get('ojs_api.contact_type.handler')->patch($this->getOr404($id), $request->request->all());
            if (!$this->isGranted('EDIT', $entity)) {
                throw new AccessDeniedException();
            }
            $routeOptions = array('id' => $entity->getId(), '_format' => $request->get('_format'));
            return $this->routeRedirectView('api_1_get_contacttype', $routeOptions, Codes::HTTP_NO_CONTENT);
        } catch (InvalidFormException $exception) {
            return $exception->getForm();
        }
    }