protected function addFootprintCategoryPath(array $path, FootprintCategory $parentNode)
{
if (count($path) == 0) {
return $parentNode;
}
$name = array_shift($path);
$category = null;
foreach ($parentNode->getChildren() as $child) {
if ($child->getName() == $name) {
$category = $child;
}
}
if ($category === null) {
$category = new FootprintCategory();
$category->setParent($parentNode);
$category->setName($name);
$parentNode->getChildren()->add($category);
$this->entityManager->persist($category);
}
return $this->addFootprintCategoryPath($path, $category);
}