This is an old revision of the document!
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 | [[scriptlog:lib:controller:apicontroller|''ApiController'']] | parent class/interface |
Constants (0)
None.
Properties (0)
None declared.
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: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'']] | | ''CommentDao'' | [[scriptlog:lib:dao:commentdao|''Scriptlog\Dao\CommentDao'']] | | ''CommentApiDto'' | [[scriptlog:lib:dto:commentapidto|''Scriptlog\Dto\Api\CommentApiDto'']] | | ''CommentService'' | [[scriptlog:lib:service:commentservice|''Scriptlog\Service\CommentService'']] |
This page is generated from source by 'tools/gendoc'. Edits will be overwritten.
