repository = $repository; } /** * @return ObjectStorage */ public function getCategories( Import $import ): ObjectStorage { $categories = new ObjectStorage(); if ($import->getParentCategory() === null || $import->getPid() === null) { return $categories; } foreach ($import->getCategoryTitles() as $categoryTitle) { $category = $this->repository->findOneForImport( $import->getParentCategory(), $import->getPid(), $categoryTitle ); if (!$category instanceof Category) { $category = new Category(); $category->setParent($import->getParentCategory()); $category->setPid($import->getPid()); $category->setTitle($categoryTitle); if ($import->getHideByDefault()) { $category->hide(); } $this->repository->add($category); } $categories->attach($category); } return $categories; } }