Example #1
0
 public function action_get()
 {
     try {
         if (is_numeric($id_category = $this->request->param('id'))) {
             $cat = array();
             $category = new Model_Category($id_category);
             if ($category->loaded()) {
                 $cat = $category->as_array();
                 $cat['price'] = i18n::money_format($category->price);
                 $cat['parents'] = $category->get_parents_ids();
                 $cat['siblings'] = $category->get_siblings_ids();
                 $cat['customfields'] = Model_Field::get_by_category($category->id_category);
                 $cat['icon'] = $category->get_icon();
                 $this->rest_output(array('category' => $cat));
             } else {
                 $this->_error(__('Category not found'), 404);
             }
         } else {
             $this->_error(__('Category not found'), 404);
         }
     } catch (Kohana_HTTP_Exception $khe) {
         $this->_error($khe);
         return;
     }
 }