/**
  * Displays completeness for a product
  *
  * @param int $id
  *
  * @return Response
  */
 public function completenessAction($id)
 {
     $product = $this->productManager->getProductRepository()->getFullProduct($id);
     $channels = $this->channelManager->getFullChannels();
     $locales = $this->userContext->getUserLocales();
     $completenesses = $this->completenessManager->getProductCompleteness($product, $channels, $locales, $this->userContext->getCurrentLocale()->getCode());
     return $this->templating->renderResponse('PimEnrichBundle:Completeness:_completeness.html.twig', array('product' => $product, 'channels' => $channels, 'locales' => $locales, 'completenesses' => $completenesses));
 }
 /**
  * {@inheritdoc}
  */
 public function finishView(FormView $view, FormInterface $form, array $options)
 {
     $values = null !== $view->vars['value'] ? $view->vars['value']->getValues() : [];
     $view->vars['groups'] = $this->productFormView->getView();
     $view->vars['orderedGroups'] = $this->getOrderedGroups($values);
     $view->vars['locales'] = $this->userContext->getUserLocales();
     $view->vars['channels'] = $this->channelManager->getChannels();
     $view->vars['currentLocale'] = $options['currentLocale'];
 }
 /**
  * Get completeness for a product
  *
  * @param int $id
  *
  * @return JSONResponse
  */
 public function getAction($id)
 {
     $product = $this->productRepository->getFullProduct($id);
     $this->completenessManager->generateMissingForProduct($product);
     $channels = $this->channelRepository->getFullChannels();
     $locales = $this->userContext->getUserLocales();
     $filteredLocales = $this->collectionFilter->filterCollection($locales, 'pim.internal_api.locale.view');
     $completenesses = $this->completenessManager->getProductCompleteness($product, $channels, $filteredLocales, $this->userContext->getCurrentLocale()->getCode());
     return new JsonResponse($this->completenessNormalizer->normalize($completenesses, 'internal_api'));
 }
 /**
  * Get completeness for a product
  *
  * @param int|string $id
  *
  * @return JSONResponse
  */
 public function getAction($id)
 {
     $product = $this->productRepository->getFullProduct($id);
     if (null === $product->getFamily()) {
         return new JsonResponse();
     }
     $this->completenessManager->generateMissingForProduct($product);
     // Product have to be refreshed to have the completeness values generated by generateMissingForProduct()
     // (on ORM, completeness is not calculated the same way and product doesn't need to be refreshed)
     if (AkeneoStorageUtilsExtension::DOCTRINE_MONGODB_ODM === $this->storageDriver) {
         $this->productManager->refresh($product);
     }
     $channels = $this->channelRepository->getFullChannels();
     $locales = $this->userContext->getUserLocales();
     $filteredLocales = $this->collectionFilter->filterCollection($locales, 'pim.internal_api.locale.view');
     $completenesses = $this->completenessManager->getProductCompleteness($product, $channels, $filteredLocales);
     return new JsonResponse($this->compNormalizer->normalize($completenesses, 'internal_api'));
 }
 function let(ProductBuilder $productBuilder, ProductUpdaterInterface $productUpdater, UserContext $userContext, LocaleInterface $en, LocaleInterface $de, ProductValueInterface $productValue, CatalogContext $catalogContext, ProductMassActionManager $massActionManager, NormalizerInterface $normalizer, BulkSaverInterface $productSaver)
 {
     $en->getCode()->willReturn('en_US');
     $de->getCode()->willReturn('de_DE');
     $userContext->getCurrentLocale()->willReturn($en);
     $userContext->getUserLocales()->willReturn([$en, $de]);
     $catalogContext->setLocaleCode(Argument::any())->willReturn($catalogContext);
     $productValue->setAttribute(Argument::any())->willReturn($productValue);
     $productValue->setLocale(Argument::any())->willReturn($productValue);
     $productValue->setScope(Argument::any())->willReturn($productValue);
     $productValue->addPrice(Argument::any())->willReturn($productValue);
     $this->beConstructedWith($productBuilder, $productUpdater, $userContext, $catalogContext, $massActionManager, $normalizer, $productSaver, ['product_price' => 'Pim\\Bundle\\CatalogBundle\\Model\\ProductPrice', 'product_media' => 'Pim\\Bundle\\CatalogBundle\\Model\\ProductMedia']);
 }
 function let(ProductManager $productManager, UserContext $userContext, CurrencyManager $currencyManager, Locale $en, Locale $de, AttributeRepository $attributeRepository, AbstractProductValue $productValue, CatalogContext $catalogContext, ProductBuilder $productBuilder, ProductMassActionManager $massActionManager, MetricFactory $metricFactory)
 {
     $en->getCode()->willReturn('en_US');
     $de->getCode()->willReturn('de_DE');
     $userContext->getCurrentLocale()->willReturn($en);
     $userContext->getUserLocales()->willReturn([$en, $de]);
     $catalogContext->setLocaleCode(Argument::any())->willReturn($catalogContext);
     $productManager->createProductValue()->willReturn($productValue);
     $productValue->setAttribute(Argument::any())->willReturn($productValue);
     $productValue->setLocale(Argument::any())->willReturn($productValue);
     $productValue->setScope(Argument::any())->willReturn($productValue);
     $productValue->addPrice(Argument::any())->willReturn($productValue);
     $productManager->getAttributeRepository()->willReturn($attributeRepository);
     $this->beConstructedWith($productManager, $userContext, $currencyManager, $catalogContext, $productBuilder, $massActionManager, $metricFactory, ['product_price' => 'Pim\\Bundle\\CatalogBundle\\Model\\ProductPrice', 'product_media' => 'Pim\\Bundle\\CatalogBundle\\Model\\ProductMedia']);
 }
 /**
  * {@inheritdoc}
  */
 public function getFormOptions()
 {
     return ['locales' => $this->userContext->getUserLocales(), 'all_attributes' => $this->getAllAttributes(), 'current_locale' => $this->getLocale()->getCode()];
 }
 /**
  * Get form options
  *
  * @return array
  */
 public function getFormOptions()
 {
     return array('locales' => $this->userContext->getUserLocales(), 'common_attributes' => $this->getCommonAttributes(), 'current_locale' => $this->getLocale()->getCode());
 }
 /**
  * @return LocaleInterface[]
  */
 protected function getUserLocales()
 {
     return $this->userContext->getUserLocales();
 }
 /**
  * Get form options
  *
  * @return array
  */
 public function getFormOptions()
 {
     return array('locales' => $this->userContext->getUserLocales(), 'common_attributes' => $this->commonAttributes);
 }