GeniXCMS

PostsApi Class

categoryAPI edit_calendar04 Apr 2026

PostsApi Class Interface

The PostsApi class is a resource-specific controller within the GeniXCMS RESTful API framework. It handles standard CRUD (Create, Read, Update, Delete) operations for Post resources via HTTP endpoints.


Endpoint Mapping

The following HTTP methods are mapped to the class methods when accessing /api/v1/posts/:

Method Endpoint Action
GET / List all active posts.
GET /{id} Retrieve details of a specific post.
POST / Create a new post.
PUT /{id} Update an existing post.
DELETE /{id} Permanently remove a post.

Method Overview

index()

Handles retrieval of one or multiple post records.

Syntax:

public function index($id = null)
  • If $id is null: Returns a list of all posts with status 1, ordered by newest first.
  • If $id is provided: Returns the specific post record or a 404 error if not found.

submit()

Processes a POST request to create a new post. Expects a JSON payload in the request body.


update()

Processes a PUT request to update specific fields of a post identified by its ID.


delete()

Processes a DELETE request to remove a post from the database.


Usage in Modules

Modules can interact with this class internally if they need to bypass the standard Posts model logic or to extend the API behavior.

Example: Internal Execution

$api = new PostsApi();
$result = $api->index(10); // Fetch post ID 10 via the API controller logic

See Also