/**
  * @EXT\Route(
  *     "/product/{product}/infos",
  *     name="product_infos",
  *     options={"expose"=true}
  * )
  *
  * @return Response
  */
 public function productInfosAction(Product $product)
 {
     $priceSolutions = $product->getPriceSolutions();
     $solutionsDatas = array();
     foreach ($priceSolutions as $solution) {
         $solutionsDatas[] = array('id' => $solution->getId(), 'duration' => $solution->getMonthDuration(), 'price' => $solution->getPrice());
     }
     $datas = array('details' => $product->getDetails(), 'priceSolutions' => $solutionsDatas);
     return new JsonResponse($datas, 200);
 }
 public function isProductAvailableFor(SharedWorkspace $sws, Product $product)
 {
     $workspace = $this->getWorkspaceData($sws);
     $ut = $this->container->get('claroline.utilities.misc');
     $productData = $product->getDetails();
     if ($workspace->user_amount > $productData['max_users']) {
         return false;
     }
     if ($ut->getRealFileSize($workspace->storage_used) > $ut->getRealFileSize($productData['max_storage'])) {
         return false;
     }
     if ($workspace->count_resources > $productData['max_resources']) {
         return false;
     }
     return true;
 }
 /**
  * @EXT\Route(
  *      "/product/{product}/edit",
  *      name="formalibre_product_edit",
  *      options = {"expose"=true}
  * )
  * @Security("has_role('ROLE_ADMIN')")
  * @EXT\Template
  *
  * @return Response
  */
 public function editProductAction(Product $product)
 {
     $type = $product->getType();
     $form = $this->createForm($this->productManager->getEditFormByType($type));
     $form->handleRequest($this->get('request'));
     if ($form->isValid()) {
         //do some stuff
         $details = $product->getDetails();
         foreach ($form->getIterator() as $el) {
             //var_dump($el);
             $details[$el->getName()] = $form->get($el->getName())->getData();
         }
         $product->setDetails($details);
         $this->productManager->persist($product);
         return new JsonResponse(array('id' => $product->getId(), 'code' => $product->getCode(), 'type' => $product->getType(), 'details' => $product->getDetails(), 'priceSolutions' => array()));
     }
     return $this->render('FormaLibreInvoiceBundle:Administration:editProductForm.html.twig', array('form' => $form->createView(), 'product' => $product));
 }