Example #1
0
 /**
  * Populate category object 
  *
  * @param array $category
  * @return object Category
  */
 protected function getCategory($category)
 {
     if (empty($category)) {
         throw new BuyatException('Malformed response from server');
     }
     $categoryObject = new Category();
     $categoryObject->setCategoryID($category['category_id']);
     $categoryObject->setLevel($category['level']);
     $categoryObject->setCategoryName($category['category_name']);
     if (isset($category['subcategories'])) {
         $vSubCategories = array();
         foreach ($category['subcategories'] as $vSubCategory) {
             $vSubCategories[] = $this->getCategory($vSubCategory['value']);
         }
         $categoryObject->setSubcategories($vSubCategories);
     }
     if (isset($category['parent_category_id'])) {
         $categoryObject->setParentCategoryID($category['parent_category_id']);
     }
     if (isset($category['parent_category_name'])) {
         $categoryObject->setParentCategoryName($category['parent_category_name']);
     }
     return $categoryObject;
 }