Exemplo n.º 1
0
 /**
  * Add category by path
  *
  * @param mixed $path Path
  *
  * @return \XLite\Model\Category
  */
 protected function addCategoryByPath($path)
 {
     if (!is_array($path)) {
         $path = array_map('trim', explode('>>>', $path));
     }
     $category = $this->getCategoryByPath($path);
     if (!$category) {
         $category = new \XLite\Model\Category();
         $this->categoriesCache[implode('/', $path)] = $category;
         $category->setName(array_pop($path));
         $category->setParent($this->addCategoryByPath($path));
         \XLite\Core\Database::getRepo('XLite\\Model\\Category')->insert($category);
     }
     return $category;
 }