Index

Theme

MMO\client · 1 symbol · generated 30 Sep 2026

class

Theme

Theme.php:18
class MMO\client\Theme extends MMO\core\classes\aModule
Namespace
MMO\client
Extends
aModule

Index

assets
bin
enabled
errorTpl
fonts
imports
pages
rootAttributes
rootElement
stylesheet
addAsset($filename, $key)
BuildHook($manifest, $filename, $options) staticHook in mmo.json triggered when library is built into a phar package
compileCSS($opts, $dev)Compile the theme's stylesheet ($stylesheet) into getBin('css').
compileJHS($sassOpts, $dev)Compile every .jhs of getAssets('jhs') into getBin('jhs').
compileJS($opts, $dev)Bundle every .js of getAssets('js') into getBin('js').
compileOther()
compileSVG()
configureHtmlDocument($document)Configure the HTMLDocument to include the mmo-app custom element as root
createErrorResponse($e, $route)Import an error template when the route trigger an exception.
DefaultConfig() static
exportMenu($content, $document)
getAssets($key, $resolve)
getBin($key, $resolve)
getBinUrl($key)
getStylesheet($resolve)
hasAsset($filename, $key)
isUpToDate($key, $time)
loopAssets($key, $resolve)
onDocumentInit($event)Configure HTMLDocument after it has been created
onPageContents($contents)
onResponse($response)
onRoute($route)
removeAsset($filename, $key)Remove from the list $key every entry that resolves to $filename (the file, folder or glob as it was added).
unserialize($data, $path, $instances)The asset lists of the configuration are ADDED to the defaults, never merged onto them.
__wakeup()

Properties10

assets

protected array $assets
Type
array

bin

protected array $bin
Type
array

enabled

protected bool $enabled = true
Type
bool

errorTpl

protected string $errorTpl = 'error.phtml'
Type
string

fonts

protected array $fonts
Type
array

imports

protected array $imports = []
Type
array

pages

protected array $pages = []
Type
array

rootAttributes

protected array $rootAttributes
Type
array

rootElement

protected string $rootElement
Type
string

stylesheet

protected string $stylesheet
Type
string
See
getBin('css') and linked in every html document. It declares the design tokens at :root, from where they inherit into every shadow root, so a reskin is this one file.

Methods25

BuildHook($manifest, $filename, $options)

staticTheme.php:104

Hook in mmo.json triggered when library is built into a phar package

static function BuildHook( ?MMO\core\helpers\PackageManifest $manifest = null, ?string $filename = null, array $options = [] ): void
$manifest = nullnull | PackageManifest
$filename = nullnull | string
$options = []array
returnsvoid

compileCSS($opts, $dev)

Theme.php:493

Compile the theme's stylesheet ($stylesheet) into getBin('css').

function compileCSS(array $opts = [], bool $dev = true): voidThis is the document stylesheet: it declares the design tokens at `:root`, from where they inherit into every shadow root, so the custom elements never redeclare them. A theme is written in Simple CSS, and only in Simple CSS. The sass design system this package used to ship is archived in `.mmo/sass`; [`JHSCompiler`](https://mmoframework.fr/documentation/mmo.client/php/JHSCompiler.md#jhscompiler) still has a `lang="sass"` path for a package that carries sass of its own, but no part of a theme is sass any more.
$opts = []arrayper-compilation overrides for SCSCompiler
$dev = trueboolfalse to force a production build (compressed, no source map)
returnsvoid
throwswhen the stylesheet is not a .scs file

compileJHS($sassOpts, $dev)

Theme.php:516

Compile every .jhs of getAssets('jhs') into getBin('jhs').

function compileJHS(array $sassOpts = [], bool $dev = true): void
$sassOpts = []arrayoptions for the elements of other packages, which are still written in sass
$dev = truebool
returnsvoid

compileJS($opts, $dev)

Theme.php:473

Bundle every .js of getAssets('js') into getBin('js').

function compileJS(array $opts = [], bool $dev = true): void
$opts = []arrayper-compilation overrides for JSCompiler
$dev = trueboolfalse to force a production build (minified, no source map)
returnsvoid

configureHtmlDocument($document)

Theme.php:260

Configure the HTMLDocument to include the mmo-app custom element as root

function configureHtmlDocument(MMO\core\documents\HtmlDocument $document): void
$documentHtmlDocument
returnsvoid

createErrorResponse($e, $route)

Theme.php:173

Import an error template when the route trigger an exception.

function createErrorResponse(Throwable $e, MMO\core\server\Route $route): MMO\core\server\ResponseIt looks for a template in the folder `errors`
$eThrowable
$routeRoute
returnsResponse
for a 404, it will look for a template named `errors/404.phtml` or `errors/400.phtml`

exportMenu($content, $document)

Theme.php:184
protected function exportMenu( MMO\client\entities\Content $content, MMO\core\documents\HtmlDocument $document ): void
$contentContent
$documentHtmlDocument
returnsvoid

getAssets($key, $resolve)

Theme.php:431
function getAssets(string $key = '*', bool $resolve = true): array
$key = '*'string
$resolve = truebool
returnsarray

getStylesheet($resolve)

Theme.php:390
function getStylesheet(bool $resolve = true): string
$resolve = truebool
returnsstring

loopAssets($key, $resolve)

Theme.php:435
function loopAssets(string $key = '*', bool $resolve = true): Generator
$key = '*'string
$resolve = truebool
returnsGenerator

onDocumentInit($event)

Theme.php:199

Configure HTMLDocument after it has been created

#[MMO\core\attributes\Listen('MMO\\core\\events\\DocumentInit')] function onDocumentInit(MMO\core\events\DocumentInit $event): void
$eventDocumentInit
returnsvoid

onPageContents($contents)

Theme.php:235
#[MMO\core\attributes\Listen('MMO\\client\\events\\PageContents')] function onPageContents(MMO\client\events\PageContents $contents): void
$contentsPageContents
returnsvoid

onResponse($response)

Theme.php:211
#[MMO\core\attributes\Listen('MMO\\core\\server\\Response', order: 1000)] function onResponse(MMO\core\server\Response $response): void
$responseResponse
returnsvoid

onRoute($route)

Theme.php:204
#[MMO\core\attributes\Listen('MMO\\core\\server\\Route')] function onRoute(MMO\core\server\Route $route): void
$routeRoute
returnsvoid

removeAsset($filename, $key)

Theme.php:409

Remove from the list $key every entry that resolves to $filename (the file, folder or glob as it was added).

function removeAsset(string $filename, ?string $key = null): boolA file only matched through a folder or a glob stays: removing it would remove the others the entry matches, so the method returns false ([`hasAsset`](https://mmoframework.fr/documentation/mmo.client/php/Theme.md#theme-hasasset) still says true).
$filenamestring
$key = nullnull | string
returnsboolwhether an entry was removed

unserialize($data, $path, $instances)

Theme.php:82

The asset lists of the configuration are ADDED to the defaults, never merged onto them.

function unserialize( array $data, string $path, Psr\Container\ContainerInterface|array &$instances ): voidThe libraries add their files from their bootstraps (`'?js' => ['$[..]', __DIR__ . '/js*.js']`), and so does a project's config.json -- all of it loaded before this theme exists, when `$[..]` has nothing to splice yet. The configuration keeps what it could not resolve as it was written (`?js`, `$[..]` and all) and resolves the rest against nothing (`js` => the library's files alone). Injected over [`DefaultConfig`](https://mmoframework.fr/documentation/mmo.client/php/Theme.md#theme-defaultconfig), those lists merged index by index: `[editor, edms, oauth]` replaced this package's own `js*.js`, and a release bundled everything but mmo.client's own js, elements and icons. So each entry is applied here, in order, onto the defaults: a list adds its files (once), `?key` only adds to a list it splices (`$[..]`) or creates one that does not exist, and `=key` replaces the list outright.
$dataarray
$pathstring
$instancesContainerInterface | array
returnsvoid
Inherited members (46)
ConstantsDeclared byDescription
ALERTiLogLevelAlert: Action must be taken immediately.
ALLiLogLevelMask for all
ALL_PLUSiLogLeveldebug everything
BACKTRACEiLogLevel
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
PropertiesDeclared byDescription
verbosityaModule
MethodsDeclared byDescription
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.
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.
getVerbosity()aModule
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
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.
serialize($path, $serializer)aModule\MMO\core\interfaces\iSerializable::serialize -- exports every property (via
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.
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.
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.