MMOframework
Pourquoi l'IA Playground Bibliothèques Documentation Rechercher Agence
FR EN
Index

SectionTypeStore

MMO\editor\cms · 1 symbole · générée le 27 Oct 2026

class

SectionTypeStore

SectionTypeStore.php:23

The site's types of section, as the section-type editor writes them (SectionTypesController): the files sections/{name}.schema.json, {name}.phtml and {name}.css of the folder Pages::getTypesFolder.

class MMO\editor\cms\SectionTypeStore
Espace de noms
MMO\editor\cms
The other folders' types -- mmo.editor's, an application's other folders' -- are read only: [`copy`](https://mmoframework.fr/fr/documentation/mmo.editor/php/cms/SectionTypeStore.md#sectiontypestore-copy) brings one into the site's folder, where it replaces the other. A template is PHP, which the server runs: whoever writes one runs code on the server. The right to do it is its own (`editor.sections#edit`, [`Pages::checkTypes`](https://mmoframework.fr/fr/documentation/mmo.editor/php/cms/Pages.md#pages-checktypes)), for developers only. What is saved is checked first -- a name of its own, a schema whose examples it accepts, a template PHP can parse -- and the files it replaces are kept in `sections/.history/{name}/` (the last [`HISTORY`](https://mmoframework.fr/fr/documentation/mmo.editor/php/cms/SectionTypeStore.md#sectiontypestore-history) saves).
$store = new SectionTypeStore(Pages::Shared()); $store->save('faq', $schemaJson, $store->generate('faq', json_decode($schemaJson, true)), '.cms-faq {}');

Index

HISTORYthe saves of a type kept in its history
MAX_SIZEthe biggest file the editor writes
NAMEwhat a type's name is made of
pages readonly
all()
check($name, $schema, $template, $css)Check a type before it is saved or previewed.
copy($name, $as)Copy a type of another folder (mmo.editor's...) into the site's, under $as (its own name by default): the copy replaces the other, and can be changed.
delete($name)Remove a type of the site (its files go to its history).
folder()
generate($name, $schema)Write the template of a schema: every field printed the way mmo.editor's types do, for a developer to start from -- a title as a heading, rich text as html, a link as a button, an image, a list of …
generateFields($properties, $var, $class, $indent, $prefix)
get($name)
hiddenNames()
history($name)
isWritable()
keep($name)Keep the files of $name in its history, the oldest saves going past HISTORY
originOf($template)
save($name, $schema, $template, $css)Write a type of the site: its schema, its template, its css (none removes its file).
writableFolder()
write($file, $content)
__construct($pages)

Constantes3

HISTORY

the saves of a type kept in its history

const HISTORY = 10

MAX_SIZE

the biggest file the editor writes

const MAX_SIZE = 200000

NAME

what a type's name is made of

const NAME = '/^[a-z0-9][a-z0-9_-]{0,39}$/'

Propriétés1

pages

readonly
protected readonly MMO\editor\cms\Pages $pages
Type
Pages

Méthodes17

all()

SectionTypeStore.php:53
function all(): array
retournearraystring, label: string, icon: ?string, order: int, origin: string, editable: bool, overrides: bool}> every type the page editor offers: origin is site (the editor's folder), library (mmo.editor's) or other (another folder of the application's); overrides when a site's type replaces one of another folder

check($name, $schema, $template, $css)

SectionTypeStore.php:96

Check a type before it is saved or previewed.

function check(string $name, string $schema, string $template, string $css = ''): array
$namestring
$schemastringthe schema, as json
$templatestring
$css = ''string
retournearray?SectionType, 1: array<string, string>} the type it makes, and what is wrong (name, schema, template, css); no type when the schema cannot make one

copy($name, $as)

SectionTypeStore.php:179

Copy a type of another folder (mmo.editor's...) into the site's, under $as (its own name by default): the copy replaces the other, and can be changed.

function copy(string $name, ?string $as = null): string
$namestring
$as = nullnull | string
retournestring
lèvewhen there is no such type
lèvewhen the site has a type of that name already

delete($name)

SectionTypeStore.php:163

Remove a type of the site (its files go to its history). The pages keep their sections of it, shown as « unknown section type » until a type of that name exists again -- or the one it replaced shows again.

function delete(string $name): void
$namestring
retournevoid
lèvewhen the site has no such type

generate($name, $schema)

SectionTypeStore.php:202

Write the template of a schema: every field printed the way mmo.editor's types do, for a developer to start from -- a title as a heading, rich text as html, a link as a button, an image, a list of items as cards.

function generate(string $name, array $schema): string
$namestring
$schemaarray
retournestring

generateFields($properties, $var, $class, $indent, $prefix)

SectionTypeStore.php:231
protected function generateFields( array $properties, string $var, string $class, string $indent, string $prefix = '' ): string
$propertiesarray
$varstringthe variable printing them ($f, $item)
$classstring
$indentstring
$prefix = ''stringthe path of an object's fields (cta.)
retournestring

get($name)

SectionTypeStore.php:76
function get(string $name): array
$namestring
retournearraystring, schema: string, template: string, css: string, origin: string, editable: bool} a type's files, as they are written
lèvewhen there is no such type

hiddenNames()

SectionTypeStore.php:295
protected function hiddenNames(): array
retournearraythe names of the types of the other folders: a site's type of one of these names replaces it

originOf($template)

SectionTypeStore.php:287
protected function originOf(string $template): string
$templatestring
retournestringsite, library or other: where the type of $template comes from

save($name, $schema, $template, $css)

SectionTypeStore.php:140

Write a type of the site: its schema, its template, its css (none removes its file). The files it replaces go to its history first.

function save(string $name, string $schema, string $template, string $css = ''): bool
$namestring
$schemastring
$templatestring
$css = ''string
retournebooltrue when the type is new
lève(422) with what is wrong, nothing written
lèvewhen the folder cannot be written

writableFolder()

SectionTypeStore.php:306
protected function writableFolder(): string
retournestringthe site's sections/ folder, made if missing @throws eRuntime when there is none, or it cannot be written