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

SectionTypesController

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

class

SectionTypesController

SectionTypesController.php:32

The section-type editor's api (SectionTypeStore does the work), under admin/section-types:

class MMO\editor\controllers\SectionTypesController extends MMO\core\classes\aDataController use MMO\editor\controllers\tAdminApi
Espace de noms
MMO\editor\controllers
Étend
aDataController
Utilise les traits
tAdminApi
| route | | |---|---| | `GET admin/section-types` | the editor's html page: `<mmo-section-editor>` (`templates/section-types.phtml`) | | `GET admin/section-types.json` | every type: `{name, label, icon, order, origin, editable, overrides}`, and `writable` | | `GET`, `PUT`, `DELETE admin/section-types/{name}.json` | a type's files `{schema, template, css}`; `PUT` writes them (201 a new type), `DELETE` removes them | | `POST admin/section-types/{name}/copy.json` `{as}` | another folder's type copied into the site's | | `POST admin/section-types/generate.json` `{name, schema}` | the template of a schema, to start from | | `POST admin/section-types/preview` `{name, schema, template, css, data}` | the html of a page holding one section of a type that is not saved | Someone logged in (401) holding `editor.sections#edit` (403): a type's template is PHP that the server runs, so this right is a developer's. A request changing something -- a preview runs the template it is sent, so it is one -- sends the session's CSRF token (`X-CSRF-Token`, the pages api's: `MMO.editor.config.token`). What is not valid is a 422 whose `errors` say why: `name`, `schema`, `template`, `css`.
curl -X PUT -H 'Content-Type: application/json' -H "X-CSRF-Token: $TOKEN" -d '{"schema": "{…}", "template": "<?php …"}' .../admin/section-types/faq.json

Index

body($route)
checkToken($route)Make sure a request changing something comes from a page of the site: it has the session's token, or is authenticated by an Authorization header (which a browser does not send on its own)
explainErrors($route)An error says why in the answer's body too (meta.error): http/2 has no status text to carry it
invalid($route, $e)
onRoute($route)
routeCopy($route)
routeDelete($route)
routeEditor($route)The editor's page: <mmo-section-editor>, which works from the api
routeGenerate($route)
routeGet($route)
routeList($route)
routePreview($route)The html of a page holding one section of a type that is not saved: its schema, its template, its css as the editor has them, and the section's data (its examples by default).
routeSave($route)
setStatus($route, $status)
store($route, $token)
user($route)

Méthodes16

body($route)

tAdminApi.php:52
protected function body(MMO\core\server\Route $route): array
$routeRoute
retournearraymixed> the body of the request, a json object

checkToken($route)

tAdminApi.php:42

Make sure a request changing something comes from a page of the site: it has the session's token, or is authenticated by an Authorization header (which a browser does not send on its own)

protected function checkToken(MMO\core\server\Route $route): void
$routeRoute
retournevoid
lève(403) if it has not

explainErrors($route)

tAdminApi.php:18

An error says why in the answer's body too (meta.error): http/2 has no status text to carry it

protected function explainErrors(MMO\core\server\Route $route): void
$routeRoute
retournevoid

invalid($route, $e)

tAdminApi.php:59
protected function invalid(MMO\core\server\Route $route, MMO\editor\exceptions\eInvalidPage $e): array
$routeRoute
$eeInvalidPage
retournearrayarray<string, string>} a 422 saying what is wrong

routeCopy($route)

SectionTypesController.php:100
#[MMO\core\attributes\APIRoute('POST|admin/section-types/{name}/copy.json', 'Copy a type of section into the site\'s: {as}', mediaTypes: ['json'])] function routeCopy(MMO\core\server\Route $route): array
$routeRoute
retournearraymixed> the copy (201), or errors (422)

routeDelete($route)

SectionTypesController.php:91
#[MMO\core\attributes\APIRoute('DELETE|admin/section-types/{name}.json', 'Remove a type of section of the site', mediaTypes: ['json'])] function routeDelete(MMO\core\server\Route $route): array
$routeRoute
retournearraystring, deleted: true}

routeEditor($route)

SectionTypesController.php:52

The editor's page: <mmo-section-editor>, which works from the api

#[MMO\core\attributes\APIRoute('GET|admin/section-types?type={?type}', 'The section-type editor', mediaTypes: ['html'])] function routeEditor(MMO\core\server\Route $route): MMO\core\server\Response
$routeRoute
retourneResponse

routeGenerate($route)

SectionTypesController.php:111
#[MMO\core\attributes\APIRoute('POST|admin/section-types/generate.json', 'Write the template of a schema: {name, schema}', mediaTypes: ['json'])] function routeGenerate(MMO\core\server\Route $route): array
$routeRoute
retournearraystring}|array{errors: array<string, string>} the template of a schema

routeGet($route)

SectionTypesController.php:71
#[MMO\core\attributes\APIRoute('GET|admin/section-types/{name}.json', 'A type of section: its schema, its template, its css', mediaTypes: ['json'])] function routeGet(MMO\core\server\Route $route): array
$routeRoute
retournearraymixed> a type's files, and its history

routeList($route)

SectionTypesController.php:64
#[MMO\core\attributes\APIRoute('GET|admin/section-types.json', 'The types of section, and where they come from', mediaTypes: ['json'])] function routeList(MMO\core\server\Route $route): array
$routeRoute
retournearraybool, folder: ?string, types: list<array<string, mixed>>}

routePreview($route)

SectionTypesController.php:125

The html of a page holding one section of a type that is not saved: its schema, its template, its css as the editor has them, and the section's data (its examples by default). The template runs -- it is PHP --, written in the temporary folder for the time of the request.

#[MMO\core\attributes\APIRoute('POST|admin/section-types/preview', 'The html of a section of a type that is not saved', mediaTypes: ['html'])] function routePreview(MMO\core\server\Route $route): MMO\core\server\Response
$routeRoute
retourneResponse

routeSave($route)

SectionTypesController.php:79
#[MMO\core\attributes\APIRoute('PUT|admin/section-types/{name}.json', 'Write a type of section of the site: {schema, template, css}', mediaTypes: ['json'])] function routeSave(MMO\core\server\Route $route): array
$routeRoute
retournearraymixed> the type as it was written (201 when new), or its errors (422)

setStatus($route, $status)

tAdminApi.php:64
protected function setStatus(MMO\core\server\Route $route, int $status): void
$routeRoute
$statusint
retournevoid

user($route)

tAdminApi.php:31
protected function user(MMO\core\server\Route $route): MMO\oauth\interfaces\iClient
$routeRoute
retourneiClientthe logged-in user
lève(401) if nobody is
Membres hérités (61)
ConstantesDéclaré parDescription
ALERTiLogLevelAlert: Action must be taken immediately.
ALLiLogLevelMask for all
ALL_PLUSiLogLeveldebug everything
BACKTRACEiLogLevel
COLORSaDataControllerNamed color palettes for chart/report endpoints, e.g.
CRITICALiLogLevelCritical: Critical conditions.
DEBUGiLogLevelDebug: Detailed debug information.
DEEPiLogLeveldebug everything with arguments
EMERGENCYiLogLevelEmergency: System is unusable.
ERRORiLogLevelError: Runtime errors that do not require immediate action but should typically be logged and monitored.
ERROR_PLUSiLogLevelMask for all error
FATALiLogLevelMask for all fatal error
INFOiLogLevelInfo: Interesting events.
INFO_PLUSiLogLevelMask for all errors/warning/notices/info
MEMORYiLogLevelinclude backtrace object
NOTICEiLogLevelNotice: Normal but significant events.
NOTICE_PLUSiLogLevelMask for all errors/warning/notices/info
TRACEiLogLevelinclude backtrace as origins
WARNINGiLogLevelWarning: Exceptional occurrences that are not errors.
WARNING_PLUSiLogLevelMask for all errors and warnings
PropriétésDéclaré parDescription
repositoriesaDataController
verbosityaModule
MéthodesDéclaré parDescription
alert($message, $context)aModuleAction must be taken immediately.
backtraces($message, $context)aModuleForce-log a message at INFO level together with a full stack trace/memory snapshot (iLogLevel::BACKTRACE), bypassing the verbosity mask entirely (any non-zero verbosity is enough to trigger it).
Configure($config)aModuleMerge $config into this module's configuration in the shared Configuration.
critical($message, $context)aModuleCritical conditions. No-op if CRITICAL is currently filtered out by the verbosity mask.
debug($message, $context)aModuleDetailed debug information.
debugName()aModuleHuman-readable identifier used as the default {origin} in this instance's log messages.
DefaultConfig()aModuleThe config a module starts from before anything loaded via Configuration is merged in.
emergency($message, $context)aModuleSystem is unusable. No-op if EMERGENCY is currently filtered out by the verbosity mask.
error($message, $context)aModuleRuntime errors that do not require immediate action but should typically be logged and monitored.
ExtractRoutes($config)aControllerExtract all the APIRoute from this class, regardless of the fact they are registered in the application
getMainRepository()aDataController
getRepositories()aDataController
getRepository($repo)aDataController
getVerbosity()aModule
HasRoutes()aControllerTells if any APIRoute are registered in the application
info($message, $context)aModuleInteresting events. No-op if INFO is currently filtered out by the verbosity mask.
Instantiate($config)aModule(Re)create the shared instance immediately, configured with $config merged into the class's existing config.
IsShared()aModule
Link($method, $data)aControllerBuild a Link (URL + label/icon/description/title, taken from the route's APIRoute metadata) for a registered route.
log($level, $message, $context)aModuleLogs with an arbitrary level.
notice($message, $context)aModuleNormal but significant events.
offsetExists($key)aModule\ArrayAccess::offsetExists -- tells whether $key is a declared property at all, regardless of whether it is currently readable/writable through array access.
offsetGet($key)aModule\ArrayAccess::offsetGet -- reads a property directly, unless it has a #[Serialize(serialize: 'methodName')] attribute, in which case that zero-argument method is called instead (e.g.
offsetSet($key, $value)aModule\ArrayAccess::offsetSet -- sets a property directly, unless it has a #[Serialize(unserialize: 'methodName')] attribute, in which case that method is called with $value instead (e.g.
offsetUnset($key)aModule\ArrayAccess::offsetUnset -- equivalent to $module[$key] = null.
Route($method)aControllerGet a registered APIRoute WARNING: if this class was not registered in the application, it will return null.
Routes()aControllerGet a list of registered APIRoutes (from this class) in the application WARNING: if this class was not registered in the application, it will return an empty array.
serialize($path, $serializer)aModule\MMO\core\interfaces\iSerializable::serialize -- exports every property (via
setRepositories($repositories)aDataControllerRegister the repositories this controller can query, keyed by name (e.g.
setVerbosity($verb)aModuleSet the current verbosity mask, replacing whatever it was before.
Shared()aModuleGet the shared instance, creating (and configuring) it on first call.
testVerbosity($level)aModuleTest whether a given level (or set of levels) is currently enabled by this instance's verbosity mask.
traitUnshare($serialize)aModuleRemove the shared instance, so the next Shared() call creates a fresh one.
unserialize($data, $path, $instances)aModule\MMO\core\interfaces\iSerializable::unserialize -- merges $data onto DefaultConfig, runs it through the (possibly overridden) constructor, then applies each resulting value to its property (via
Unshare($serialize)aModuleLike tSingleton::Unshare, but also disconnects this module's instance from every event it was listening to (via Event::DisconnectListeners) before dropping it.
Url($method, $data)aControllerBuild the URL for a registered route, filling in any {placeholder} from $data.
warning($message, $context)aModuleExceptional occurrences that are not errors.
__construct($config)aModuleprotected constructor, so it is not possible to do new Module(...) called by the serialization process just before being injected with data.
__wakeup()aControllerCalled automatically right after the controller's shared instance is built (aModule::unserialize): registers onRoute as a Route listener with a low priority (-10), so it…