*/ 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( $import->getParentCategory(), $import->getPid(), $categoryTitle, $import->getHideByDefault() ? true : false ); $this->repository->add($category); } $categories->attach($category); } $this->persistenceManager->persistAll(); return $categories; } }