Documentation

index.php

Components REST API Endpoint

Provides RESTful API for discovering and rendering DressAPI components. Components are discovered from the views/{view}/components/ directory.

Tags
subpackage

components

author

DressAPI Development Team

version
1.0.0
since
1.0.0

Table of Contents

Constants

CORE_PATH  = \CORE_SRC_PATH . '/modules/base'
CORE_SRC_PATH  = \dirname(__DIR__, 2)
Base path to the core modules directory Path: core/src/api/components -> core/src/api -> core/src
DEFAULT_VIEW  = 'bi5'
Default view folder for components

Functions

HandleList()  : void
Lists all available components with their metadata
HandleRender()  : void
Renders a component for preview purposes
ParseComponentParams()  : array<string|int, mixed>
Parses component parameters from HTML comment block.
ParseComponentExamples()  : array<string|int, mixed>
Parses component examples from HTML comment block
ParseComponentDescription()  : string
Parses component description from HTML comment block
RenderSimplePreview()  : string
Renders a simple preview of a component

Constants

CORE_PATH

public mixed CORE_PATH = \CORE_SRC_PATH . '/modules/base'

CORE_SRC_PATH

Base path to the core modules directory Path: core/src/api/components -> core/src/api -> core/src

public string CORE_SRC_PATH = \dirname(__DIR__, 2)

DEFAULT_VIEW

Default view folder for components

public string DEFAULT_VIEW = 'bi5'

Functions

HandleList()

Lists all available components with their metadata

HandleList() : void

GET /api-core/components/?action=list&view=bi5

Tags
throws
Exception

If the view folder is not found

Return values
void —

Outputs JSON response with components array

HandleRender()

Renders a component for preview purposes

HandleRender() : void

POST /api-core/components/?action=render Body: {"type": "card", "data": {"title": "Test"}}

Tags
throws
Exception

If component type is not specified or not found

Return values
void —

Outputs JSON response with rendered HTML

ParseComponentParams()

Parses component parameters from HTML comment block.

ParseComponentParams(string $html) : array<string|int, mixed>

Expected format in template (PHPDoc-style):

Parameters
$html : string

The template HTML content.

Tags
repeater

@param string title - Title of each item @param string body - Content of each item

Return values
array<string|int, mixed> —

['params' => array, 'is_repeater' => bool]

ParseComponentExamples()

Parses component examples from HTML comment block

ParseComponentExamples(string $html) : array<string|int, mixed>

Expected format: EXAMPLE 1: {"title":"Example"}

Parameters
$html : string

The template HTML content

Return values
array<string|int, mixed> —

Array of example objects with raw JSON data

ParseComponentDescription()

Parses component description from HTML comment block

ParseComponentDescription(string $html) : string

Extracts the component name from the first line of the comment

Parameters
$html : string

The template HTML content

Return values
string —

The component description or empty string

RenderSimplePreview()

Renders a simple preview of a component

RenderSimplePreview(string $template_file, array<string|int, mixed> $data) : string

This is a simplified renderer for editor preview. For full rendering, use CComponent class.

Parameters
$template_file : string

Path to the template file

$data : array<string|int, mixed>

Component data

Return values
string —

Rendered HTML preview


        
On this page

Search results