Ojs\ApiBundle\Controller\Admin\PublisherRestController::putPublisherAction PHP Метод

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

Update existing Publisher from the submitted data or create a new Publisher at a specific location.
public putPublisherAction ( Request $request, integer $id ) : Symfony\Component\Form\FormTypeInterface | FOS\RestBundle\Controller\Annotations\View
$request Symfony\Component\HttpFoundation\Request the request object
$id integer the Publisher id
Результат Symfony\Component\Form\FormTypeInterface | FOS\RestBundle\Controller\Annotations\View
    public function putPublisherAction(Request $request, $id)
    {
        if (!$this->isGranted('CREATE', new Publisher())) {
            throw new AccessDeniedException();
        }
        try {
            if (!($entity = $this->container->get('ojs_api.publisher.handler')->get($id))) {
                $statusCode = Codes::HTTP_CREATED;
                $entity = $this->container->get('ojs_api.publisher.handler')->post($request->request->all());
            } else {
                $statusCode = Codes::HTTP_NO_CONTENT;
                $entity = $this->container->get('ojs_api.publisher.handler')->put($entity, $request->request->all());
            }
            $routeOptions = array('id' => $entity->getId(), '_format' => $request->get('_format'));
            return $this->routeRedirectView('api_1_get_publisher', $routeOptions, $statusCode);
        } catch (InvalidFormException $exception) {
            return $exception->getForm();
        }
    }