/**
  * @return ChannelInterface[]
  */
 protected function getChannels()
 {
     if (null === $this->channels) {
         $this->channels = $this->channelRepository->findAll();
     }
     return $this->channels;
 }
 function let(DocumentManager $manager, ChannelInterface $ecommerce, ChannelInterface $mobile, LocaleInterface $enUs, LocaleInterface $frFr, CategoryInterface $category, ChannelRepositoryInterface $channelRepository, CategoryRepositoryInterface $categoryRepository, ProductRepository $productRepository, QueryBuilder $ormQb, Builder $odmQb, Query $odmQuery, OrmQuery $ormQuery, Cursor $cursor)
 {
     $enUs->getCode()->willReturn('en_US');
     $frFr->getCode()->willReturn('fr_FR');
     $ecommerce->getCode()->willReturn('ecommerce');
     $ecommerce->getLabel()->willReturn('ECommerce');
     $ecommerce->getLocales()->willReturn([$enUs, $frFr]);
     $ecommerce->getCategory()->willReturn($category);
     $mobile->getCode()->willReturn('mobile');
     $mobile->getLabel()->willReturn('Mobile');
     $mobile->getLocales()->willReturn([$enUs]);
     $mobile->getCategory()->willReturn($category);
     $odmQuery->execute()->willReturn($cursor);
     $productRepository->createQueryBuilder()->willReturn($odmQb);
     $odmQb->hydrate(Argument::any())->willReturn($odmQb);
     $odmQb->field(Argument::any())->willReturn($odmQb);
     $odmQb->in(Argument::any())->willReturn($odmQb);
     $odmQb->equals(Argument::any())->willReturn($odmQb);
     $odmQb->select('_id')->willReturn($odmQb);
     $odmQb->getQuery()->willReturn($odmQuery);
     $categoryRepository->getAllChildrenIds($category, true)->willReturn([1, 2, 3]);
     $channelRepository->findAll()->willReturn([$ecommerce, $mobile]);
     $manager->getRepository('pim_product_class')->willReturn($productRepository);
     $this->beConstructedWith($manager, $channelRepository, $categoryRepository, 'pim_product_class');
 }
 /**
  * {@inheritdoc}
  */
 public function initialize()
 {
     $this->channels = $this->channelRepository->findAll();
     foreach ($this->attributeRepository->getNonIdentifierAttributes() as $attribute) {
         $this->attributes[(string) $attribute->getGroup()][] = $attribute;
         foreach ($this->channels as $channel) {
             $this->addAttributeRequirement($this->factory->createAttributeRequirement($attribute, $channel, false));
         }
     }
 }
 /**
  * Get channel choices with user channel code first
  *
  * @return string[]
  */
 public function getChannelChoicesWithUserChannel()
 {
     $channels = $this->channelRepository->findAll();
     $channelChoices = $this->choicesBuilder->buildChoices($channels);
     $userChannelCode = $this->getUserChannelCode();
     if (array_key_exists($userChannelCode, $channelChoices)) {
         return [$userChannelCode => $channelChoices[$userChannelCode]] + $channelChoices;
     }
     return $channelChoices;
 }
 /**
  * {@inheritdoc}
  */
 public function getCompleteProductsCountPerChannels()
 {
     $channels = $this->channelRepository->findAll();
     $productRepo = $this->documentManager->getRepository($this->productClass);
     $productsCount = [];
     foreach ($channels as $channel) {
         $category = $channel->getCategory();
         $categoryIds = $this->categoryRepository->getAllChildrenIds($category, true);
         foreach ($channel->getLocales() as $locale) {
             $data = [];
             $compSuffix = $channel->getCode() . '-' . $locale->getCode();
             $localeCount = $productRepo->createQueryBuilder()->hydrate(false)->field('categoryIds')->in($categoryIds)->field('enabled')->equals(true)->field('normalizedData.completenesses.' . $compSuffix)->equals(100)->select('_id')->getQuery()->execute()->count();
             $data['locale'] = $locale->getCode();
             $data['label'] = $channel->getLabel();
             $data['total'] = $localeCount;
             $productsCount[] = $data;
         }
     }
     return $productsCount;
 }
 /**
  * Edit a family
  *
  * @param int $id
  *
  * @Template
  * @AclAncestor("pim_enrich_family_index")
  *
  * @return array
  */
 public function editAction($id)
 {
     $family = $this->familyRepository->find($id);
     if (null === $family) {
         throw new NotFoundHttpException(sprintf('%s entity not found', $this->familyClass));
     }
     if ($this->familyHandler->process($family)) {
         $this->request->getSession()->getFlashBag()->add('success', new Message('flash.family.updated'));
     }
     return ['form' => $this->familyForm->createView(), 'attributesForm' => $this->getAvailableAttributesForm($family->getAttributes()->toArray())->createView(), 'channels' => $this->channelRepository->findAll()];
 }
 function it_initializes_attribute_requirements_with_all_channels_and_attributes_in_the_PIM(ChannelRepositoryInterface $channelRepository, ChannelInterface $ecommerceChannel, ChannelInterface $mobileChannel, AttributeRepositoryInterface $attributeRepository, AttributeInterface $nameAttribute, AttributeInterface $descriptionAttribute, AttributeRequirementFactory $factory, AttributeRequirementInterface $nameECommerceRequirement, AttributeRequirementInterface $nameMobileRequirement, AttributeRequirementInterface $descriptionECommerceRequirement, AttributeRequirementInterface $descriptionMobileRequirement)
 {
     $channelRepository->findAll()->willReturn([$ecommerceChannel, $mobileChannel]);
     $attributeRepository->getNonIdentifierAttributes()->willReturn([$nameAttribute, $descriptionAttribute]);
     $factory->createAttributeRequirement($nameAttribute, $ecommerceChannel, false)->willReturn($nameECommerceRequirement);
     $nameECommerceRequirement->getAttributeCode()->willReturn('name');
     $nameECommerceRequirement->getChannelCode()->willReturn('ecommerce');
     $factory->createAttributeRequirement($nameAttribute, $mobileChannel, false)->willReturn($nameMobileRequirement);
     $nameMobileRequirement->getAttributeCode()->willReturn('name');
     $nameMobileRequirement->getChannelCode()->willReturn('mobile');
     $factory->createAttributeRequirement($descriptionAttribute, $ecommerceChannel, false)->willReturn($descriptionECommerceRequirement);
     $descriptionECommerceRequirement->getAttributeCode()->willReturn('description');
     $descriptionECommerceRequirement->getChannelCode()->willReturn('ecommerce');
     $factory->createAttributeRequirement($descriptionAttribute, $mobileChannel, false)->willReturn($descriptionMobileRequirement);
     $descriptionMobileRequirement->getAttributeCode()->willReturn('description');
     $descriptionMobileRequirement->getChannelCode()->willReturn('mobile');
     $this->initialize();
     $this->getAttributeRequirements()->toArray()->shouldReturn(['name_ecommerce' => $nameECommerceRequirement, 'name_mobile' => $nameMobileRequirement, 'description_ecommerce' => $descriptionECommerceRequirement, 'description_mobile' => $descriptionMobileRequirement]);
 }
 /**
  * @return JsonResponse
  */
 public function indexAction()
 {
     $channels = $this->channelRepository->findAll();
     $normalizedChannels = $this->normalizer->normalize($channels, 'json');
     return new JsonResponse($normalizedChannels);
 }
 /**
  * @return array
  */
 protected function getChannels()
 {
     return $this->channelRepository->findAll();
 }
 /**
  * @param ChannelRepositoryInterface $channelRepository
  */
 public function __construct(ChannelRepositoryInterface $channelRepository)
 {
     $this->channels = $channelRepository->findAll();
 }