Beispiel #1
0
 public function updateAction($productId)
 {
     $this->checkAuth(AdminResources::PRODUCT, [], AccessManager::UPDATE);
     $this->checkProductExists($productId);
     $request = $this->getRequest();
     $form = new ProductModificationForm($request, 'form', ['id' => $productId], ['csrf_protection' => false, 'method' => 'PUT']);
     $data = $request->request->all();
     $data['id'] = $productId;
     $request->request->add($data);
     try {
         $updateForm = $this->validateForm($form);
         $event = new ProductUpdateEvent($productId);
         $event->bindForm($updateForm);
         $this->dispatch(TheliaEvents::PRODUCT_UPDATE, $event);
         return JsonResponse::create(null, 204);
     } catch (\Exception $e) {
         return JsonResponse::create(['error' => $e->getMessage()], 500);
     }
 }