Пример #1
0
 public function index_get()
 {
     $status = 404;
     $return["result"] = "NOOK";
     $category = $this->get("categoryId");
     if ($category) {
         $subcategories = CI_Subcategory::getByCategory($category);
     } else {
         $subcategories = CI_Subcategory::getSubcategories();
     }
     if ($subcategories) {
         $status = 200;
         $return["result"] = "OK";
         $return["data"] = "";
         foreach ($subcategories as $key => $subcategory) {
             $mySubcategory = CI_Subcategory::getData($subcategory);
             $return["data"][$key] = $mySubcategory;
         }
     }
     $this->response($return, $status);
 }
Пример #2
0
 protected function getData($options)
 {
     $publication = new stdClass();
     if (isset($options->id)) {
         $publication->id = $options->id;
         $publication->image = CI_Image::getData($options->image);
     }
     $publication->title = $options->title;
     $publication->description = $options->description;
     $publication->category = CI_Category::getData($options->category);
     $publication->subcategory = CI_Subcategory::getData($options->subcategory);
     $publication->object = CI_Object::getData($options->object);
     $publication->quantity = $options->quantity;
     $publication->views = $options->views;
     $publication->processState = CI_ProcessState::getData($options->processState);
     $publication->creationDate = $options->creationDate;
     $publication->expirationDate = $options->expirationDate;
     if (isset($options->isFavorite)) {
         $publication->isFavorite = $options->isFavorite;
     }
     if (isset($options->isOwner)) {
         $publication->isOwner = $options->isOwner;
     }
     if (isset($options->userId)) {
         $publication->userId = $options->userId;
     }
     return $publication;
 }