MMOframework
Why AI Playground Libraries Documentation Search Agency
FR EN
Index

SectionType

MMO\editor\cms · 1 symbol · generated 27 Oct 2026

class

SectionType

SectionType.php:29

A type of section: the pair of files sections/{name}.phtml (how it is rendered, PageRenderer) and sections/{name}.schema.json (what its data holds), found in Pages::$templates.

class MMO\editor\cms\SectionType implements JsonSerializable
Namespace
MMO\editor\cms
Implements
JsonSerializable
The schema is a JSON Schema object with a few keys of the page editor's own: - at the top: `label`, `icon`, `description` (what the "add a section" menu shows), `level` (the display level from which it is offered: [`Modes`](https://mmoframework.fr/en/documentation/mmo.client/php/Modes.md#modes)); - on a field: `label`, `help`, `level` (from which level its input is shown: none is every level, `standard`, `expert`), and `format`: - `text` (the default for a string): plain text, escaped when it is printed; - `html`: rich text from `<mmo-editor>`, sanitized when it is saved ([`Sanitizer`](https://mmoframework.fr/en/documentation/mmo.editor/php/cms/Sanitizer.md#sanitizer)) -- `"editor": "inline"` keeps text formatting only, `"tools"` is the editor's toolbar; - `url`: a link, only `http(s)`, `mailto`, `tel` or relative; - `image`: `{src, alt}`, an address and its description; - an `array` of objects is a list of items (the cards of a features section), each with its own fields. - `default`: what a new section starts with.
{"label": "Hero", "icon": "star", "properties": { "title": {"type": "string", "format": "html", "editor": "inline", "label": "Title"}, "image": {"type": "object", "format": "image", "properties": {"src": {"type": "string"}, "alt": {"type": "string"}}}}}

Index

name readonly
schema readonly
template readonly
clean($data)Make what a client sent what the type says: html sanitized, urls checked, text trimmed of nothing, numbers and booleans as such.
CleanObject($schema, $data, $sanitizer) static
CleanValue($field, $value, $sanitizer) static
Closed($schema) static
Defaults($schema) static
getDefaults()
getLabel()
jsonSerialize()
TranslateExample($value, $field) static
validate($data, $errors)
__construct($name, $template, $schema)

Properties3

name

readonly
readonly string $name
Type
string

schema

readonly
readonly array $schema
Type
array

template

readonly
readonly string $template
Type
string

Methods11

clean($data)

SectionType.php:75

Make what a client sent what the type says: html sanitized, urls checked, text trimmed of nothing, numbers and booleans as such. A field the schema does not know is left as it is, for validate to refuse.

function clean(array $data): array
$dataarray
returnsarraymixed>

CleanObject($schema, $data, $sanitizer)

staticSectionType.php:128
protected static function CleanObject(array $schema, array $data, MMO\editor\cms\Sanitizer $sanitizer): array
$schemaarray
$dataarray
$sanitizerSanitizer
returnsarraymixed>

CleanValue($field, $value, $sanitizer)

staticSectionType.php:136
protected static function CleanValue(array $field, mixed $value, MMO\editor\cms\Sanitizer $sanitizer): mixed
$fieldarray
$valuemixed
$sanitizerSanitizer
returnsmixed

Closed($schema)

staticSectionType.php:49
protected static function Closed(array $schema): array
$schemaarray
returnsarraymixed> $schema, its objects (its own, its fields', its lists' items) refusing a field nobody declared: it would be saved, and never shown

Defaults($schema)

staticSectionType.php:98
protected static function Defaults(array $schema): array
$schemaarray
returnsarraymixed> the defaults of an object's fields

getDefaults()

SectionType.php:65
function getDefaults(): array
returnsarraymixed> the data a new section of this type starts with

jsonSerialize()

SectionType.php:93
function jsonSerialize(): array
returnsarraymixed> what the page editor needs: the name and the schema

TranslateExample($value, $field)

staticSectionType.php:113
protected static function TranslateExample(mixed $value, array $field): mixed
$valuemixedan example of a field (its default), in English
$fieldarray
returnsmixedthe example in the user's language (I18n): its texts, but a choice (enum) and an address, which the page needs as they are

__construct($name, $template, $schema)

SectionType.php:38
function __construct(string $name, string $template, array $schema)
$namestringwhat a section's type says
$templatestringthe template rendering it (sections/{name}.phtml)
$schemaarray