====== CategoriesApiController ======
**Layer:** ''Controller'' · **Source:** ''lib/controller/api/CategoriesApiController.php:30'' (lines 30–375)
----
class CategoriesApiController extends ApiController
Categories API Controller
Handles API requests for categories (topics)
======= Docblock Metadata =======
^ Tag ^ Value ^
| ''@category'' | Controller Class |
| ''@author'' | Blogware Team |
| ''@license'' | MIT |
| ''@version'' | 1.0 |
| ''@since'' | Since Release 1.0 |
======= Inheritance =======
^ Relation ^ Type ^ Meaning ^
| extends | [[scriptlog:lib:controller:apicontroller|''ApiController'']] | parent class/interface |
======= Constants (0) =======
//None.//
======= Properties (4) =======
^ Visibility ^ Type ^ Name ^ Default ^ Line ^
| ''private'' | ''(untyped)'' | ''$topicDao'' | | 35 |
| ''private'' | ''(untyped)'' | ''$topicService'' | | 40 |
| ''private'' | ''(untyped)'' | ''$sanitizer'' | | 45 |
| ''private'' | ''(untyped)'' | ''$hateoas'' | | 50 |
======= Methods (8) =======
^ Visibility ^ Method ^ Summary ^ Line ^
| public | ''__construct()'' | Constructor | 55 |
| public | ''index()'' | Get all categories (public endpoint) | 76 |
| public | ''show()'' | Get a single category by ID (public endpoint) | 118 |
| public | ''posts()'' | Get posts in a category (public endpoint) | 150 |
| public | ''store()'' | Create a new category (requires authentication) | 218 |
| public | ''update()'' | Update an existing category (requires authentication) | 268 |
| public | ''destroy()'' | Delete a category (requires authentication) | 328 |
| private | ''generateSlug()'' | Generate URL-friendly slug | 370 |
======== __construct() ========
public function __construct()
//lines 55–66 (12)//
Constructor
//Takes no parameters.//
======== index() ========
public function index($params = [])
//lines 76–108 (33)//
Get all categories (public endpoint)
GET /api/v1/categories
^ Parameter ^ Type ^ Default ^ Description ^
| ''$params'' | ''(untyped)'' | ''[]'' | Query parameters |
**Returns:** ''(none declared)'' — void
======== show() ========
public function show($params = [])
//lines 118–140 (23)//
Get a single category by ID (public endpoint)
GET /api/v1/categories/{id}
^ Parameter ^ Type ^ Default ^ Description ^
| ''$params'' | ''(untyped)'' | ''[]'' | Route parameters including 'id' |
**Returns:** ''(none declared)'' — void
======== posts() ========
public function posts($params = [])
//lines 150–208 (59)//
Get posts in a category (public endpoint)
GET /api/v1/categories/{id}/posts
^ Parameter ^ Type ^ Default ^ Description ^
| ''$params'' | ''(untyped)'' | ''[]'' | Route parameters including 'id' |
**Returns:** ''(none declared)'' — void
======== store() ========
public function store($_params = [])
//lines 218–258 (41)//
Create a new category (requires authentication)
POST /api/v1/categories
^ Parameter ^ Type ^ Default ^ Description ^
| ''$_params'' | ''(untyped)'' | ''[]'' | //none// |
**Returns:** ''(none declared)'' — void
======== update() ========
public function update($params = [])
//lines 268–318 (51)//
Update an existing category (requires authentication)
PUT /api/v1/categories/{id}
^ Parameter ^ Type ^ Default ^ Description ^
| ''$params'' | ''(untyped)'' | ''[]'' | Route parameters including 'id' |
**Returns:** ''(none declared)'' — void
======== destroy() ========
public function destroy($params = [])
//lines 328–360 (33)//
Delete a category (requires authentication)
DELETE /api/v1/categories/{id}
^ Parameter ^ Type ^ Default ^ Description ^
| ''$params'' | ''(untyped)'' | ''[]'' | Route parameters including 'id' |
**Returns:** ''(none declared)'' — void
======== generateSlug() ========
private function generateSlug($title)
//lines 370–374 (5)//
Generate URL-friendly slug
^ Parameter ^ Type ^ Default ^ Description ^
| ''$title'' | ''(untyped)'' | //required// | //none// |
**Returns:** ''(none declared)'' — string
======= Imports =======
^ Alias ^ Fully-qualified name ^
| ''ApiController'' | [[scriptlog:lib:controller:apicontroller|''Scriptlog\Controller\ApiController'']] |
| ''ApiHateoas'' | [[scriptlog:lib:core:apihateoas|''Scriptlog\Core\ApiHateoas'']] |
| ''ApiResponse'' | [[scriptlog:lib:core:apiresponse|''Scriptlog\Core\ApiResponse'']] |
| ''FormValidator'' | [[scriptlog:lib:core:formvalidator|''Scriptlog\Core\FormValidator'']] |
| ''Sanitize'' | [[scriptlog:lib:core:sanitize|''Scriptlog\Core\Sanitize'']] |
| ''TopicDao'' | [[scriptlog:lib:dao:topicdao|''Scriptlog\Dao\TopicDao'']] |
| ''PostApiDto'' | [[scriptlog:lib:dto:postapidto|''Scriptlog\Dto\Api\PostApiDto'']] |
| ''TopicApiDto'' | [[scriptlog:lib:dto:topicapidto|''Scriptlog\Dto\Api\TopicApiDto'']] |
| ''TopicService'' | [[scriptlog:lib:service:topicservice|''Scriptlog\Service\TopicService'']] |
----
//This page is generated from source by 'tools/gendoc'. Edits will be overwritten.//