Exemple #1
0
 protected function createCategory($category)
 {
     if (is_string($category)) {
         return new Category($category);
     }
     if (is_array($category)) {
         return Category::fromArray($category);
     }
 }
 protected function addCategory(CategoryInterface $category)
 {
     $key = $category->getKey();
     if (isset($this->categories[$key])) {
         // combine categories
         $data = Category::toArray($this->categories[$key]);
         $data = array_merge($data, Category::toArray($category));
         $category = $this->createCategory($data);
     }
     $this->categories[$key] = $category;
 }