/**
  * @param CategoryManager $categoryManager
  * @param string          $categoryClass
  * @param string          $dataClass
  */
 public function __construct(CategoryManager $categoryManager, $categoryClass, $dataClass)
 {
     $this->categoryManager = $categoryManager;
     $this->categoryClass = $categoryClass;
     $this->dataClass = $dataClass;
     $this->trees = $categoryManager->getEntityRepository()->findBy(['parent' => null]);
 }
 /**
  * @param CategoryManager    $categoryManager
  * @param BulkSaverInterface $productSaver
  */
 public function __construct(CategoryManager $categoryManager, BulkSaverInterface $productSaver)
 {
     parent::__construct($productSaver);
     $this->categoryManager = $categoryManager;
     $this->trees = $categoryManager->getEntityRepository()->findBy(array('parent' => null));
     $this->categories = array();
 }
 /**
  * Get all sources
  * @param CategoryInterface $category
  *
  * @return array
  */
 public function getAllSources(CategoryInterface $category = null)
 {
     $sources = [];
     if ($this->isValid()) {
         $categories = $category === null ? $this->categoryManager->getTrees() : $category->getChildren();
         foreach ($categories as $category) {
             $sources[] = ['id' => $category->getCode(), 'text' => sprintf('%s (%s)', $category->getLabel(), $category->getCode())];
             $sources = array_merge($sources, $this->getAllSources($category));
         }
     }
     return $sources;
 }
 function let(SecurityContextInterface $securityContext, LocaleManager $localeManager, ChannelManager $channelManager, CategoryManager $categoryManager, TokenInterface $token, User $user, LocaleInterface $en, LocaleInterface $fr, LocaleInterface $de, ChannelInterface $ecommerce, ChannelInterface $mobile, CategoryInterface $firstTree, CategoryInterface $secondTree)
 {
     $securityContext->getToken()->willReturn($token);
     $token->getUser()->willReturn($user);
     $en->getCode()->willReturn('en_US');
     $fr->getCode()->willReturn('fr_FR');
     $de->getCode()->willReturn('de_DE');
     $en->isActivated()->willReturn(true);
     $fr->isActivated()->willReturn(true);
     $de->isActivated()->willReturn(true);
     $localeManager->getLocaleByCode('en_US')->willReturn($en);
     $localeManager->getLocaleByCode('fr_FR')->willReturn($fr);
     $localeManager->getLocaleByCode('de_DE')->willReturn($de);
     $localeManager->getActiveLocales()->willReturn([$en, $fr, $de]);
     $channelManager->getChannels()->willReturn([$mobile, $ecommerce]);
     $categoryManager->getTrees()->willReturn([$firstTree, $secondTree]);
     $this->beConstructedWith($securityContext, $localeManager, $channelManager, $categoryManager, 'en_US');
 }
 /**
  * Get user category tree
  *
  * @return CategoryInterface
  */
 public function getUserTree()
 {
     $defaultTree = $this->getUserOption('defaultTree');
     return $defaultTree ?: current($this->categoryManager->getTrees());
 }
 /**
  * Fetch the filled tree
  *
  * @param CategoryInterface $parent
  * @param Collection        $categories
  *
  * @return CategoryInterface[]
  */
 protected function getFilledTree(CategoryInterface $parent, Collection $categories)
 {
     return $this->categoryManager->getFilledTree($parent, $categories);
 }
 /**
  * @param int   $parentId
  * @param mixed $selectNodeId
  *
  * @return CategoryInterface[]
  */
 protected function getChildren($parentId, $selectNodeId = false)
 {
     return $this->categoryManager->getChildren($parentId, $selectNodeId);
 }
 /**
  * @param CategoryManager $categoryManager
  */
 public function __construct(CategoryManager $categoryManager)
 {
     $this->categoryManager = $categoryManager;
     $this->trees = $categoryManager->getEntityRepository()->findBy(array('parent' => null));
     $this->categories = array();
 }
 function let(CategoryManager $categoryManager, CategoryRepositoryInterface $categoryRepository)
 {
     $categoryRepository->findBy(['parent' => null])->willReturn(['this', 'is', 'a', 'category', 'tree']);
     $categoryManager->getEntityRepository()->willReturn($categoryRepository);
     $this->beConstructedWith($categoryManager, 'Pim\\Bundle\\CatalogBundle\\Entity\\Category', 'Pim\\Bundle\\EnrichBundle\\MassEditAction\\Operation\\Classify');
 }