Table of Contents
CommentsApiController
Layer: Controller · Source: lib/controller/api/CommentsApiController.php:29 (lines 29–373)
class CommentsApiController extends ApiController
Comments API Controller
Handles API requests for comments
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 | ''ApiController'' | parent class/interface |
Constants (0)
None.
Properties (4)
| Visibility | Type | Name | Default | Line |
|---|---|---|---|---|
private | (untyped) | $commentDao | 34 | |
private | (untyped) | $commentService | 39 | |
private | (untyped) | $sanitizer | 44 | |
private | (untyped) | $hateoas | 49 |
Methods (7)
| Visibility | Method | Summary | Line |
|---|---|---|---|
| public | __construct() | Constructor | 54 |
| public | index() | Get all approved comments (public endpoint) | 75 |
| public | show() | Get a single comment by ID (public endpoint) | 130 |
| public | store() | Create a new comment (public endpoint - for visitors) | 172 |
| public | update() | Update a comment (requires authentication) | 247 |
| public | destroy() | Delete a comment (requires authentication) | 312 |
| private | getClientIp() | Get client IP address | 353 |
__construct()
public function __construct()
lines 54–65 (12)
Constructor
Takes no parameters.
index()
public function index($params = [])
lines 75–120 (46)
Get all approved comments (public endpoint)
GET /api/v1/comments
| Parameter | Type | Default | Description |
|---|---|---|---|
$params | (untyped) | [] | Query parameters |
Returns: (none declared) — void
show()
public function show($params = [])
lines 130–162 (33)
Get a single comment by ID (public endpoint)
GET /api/v1/comments/{id}
| Parameter | Type | Default | Description |
|---|---|---|---|
$params | (untyped) | [] | Route parameters including 'id' |
Returns: (none declared) — void
store()
public function store($_params = [])
lines 172–237 (66)
Create a new comment (public endpoint - for visitors)
POST /api/v1/comments
| Parameter | Type | Default | Description |
|---|---|---|---|
$_params | (untyped) | [] | none |
Returns: (none declared) — void
update()
public function update($params = [])
lines 247–302 (56)
Update a comment (requires authentication)
PUT /api/v1/comments/{id}
| Parameter | Type | Default | Description |
|---|---|---|---|
$params | (untyped) | [] | Route parameters including 'id' |
Returns: (none declared) — void
destroy()
public function destroy($params = [])
lines 312–344 (33)
Delete a comment (requires authentication)
DELETE /api/v1/comments/{id}
| Parameter | Type | Default | Description |
|---|---|---|---|
$params | (untyped) | [] | Route parameters including 'id' |
Returns: (none declared) — void
getClientIp()
private function getClientIp()
lines 353–372 (20)
Get client IP address
Takes no parameters.
Returns: (none declared) — string
Imports
| Alias | Fully-qualified name |
|---|---|
ApiController | ''Scriptlog\Controller\ApiController'' |
ApiHateoas | ''Scriptlog\Core\ApiHateoas'' |
ApiResponse | ''Scriptlog\Core\ApiResponse'' |
FormValidator | ''Scriptlog\Core\FormValidator'' |
Sanitize | ''Scriptlog\Core\Sanitize'' |
CommentDao | ''Scriptlog\Dao\CommentDao'' |
CommentApiDto | ''Scriptlog\Dto\Api\CommentApiDto'' |
CommentService | ''Scriptlog\Service\CommentService'' |
This page is generated from source by 'tools/gendoc'. Edits will be overwritten.
