private function createAndPersistCategory($label, $parentCategory = null) { $this->categoriesCount++; $category = new Category(); $category->setLabel($label)->setParentCategory($parentCategory); $this->manager->persist($category); $this->setReference(sprintf('category_%s', $this->categoriesCount), $category); return $category; }