ptut-vhost/build/api/module/categoryController.php

39 lines
693 B
PHP
Raw Normal View History

<?php
/**
* Created by PhpStorm.
* User: lucas
* Date: 01/03/18
* Time: 16:43
*/
namespace api\module;
use database\core\Repo;
2018-03-06 15:15:19 +00:00
use database\repo\category;
2018-03-06 15:15:19 +00:00
class categoryController{
2018-03-06 15:15:19 +00:00
/* (1) Returns 1 or all categories
*
* @cat_id<int> [OPT] The category id
*
* @return categories<array> The categorie(s) data
*
---------------------------------------------------------*/
public function get($args){
2018-03-06 15:15:19 +00:00
$cat_id = null;
extract($args);
2018-03-06 15:15:19 +00:00
/** @var category $cat_repo */
$cat_repo = Repo::getRepo('category');
/* (1) Get All categories or 1 by its id (if set) */
$fetched = $cat_repo->get($cat_id);
/* (2) Return data */
return ['categories' => $fetched];
}
}