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

Modes

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

class

Modes

Modes.php:41

The display modes of the application (Mode): one level -- how dense it is, simple, standard or expert -- and any number of layers drawn over it -- dev, writer... A mode is presentation only: what a user may do stays their scopes' (mmo.oauth), a mode only decides what is shown.

class MMO\client\Modes extends MMO\core\classes\aModule
Espace de noms
MMO\client
Étend
aModule
The modes shown are, for the level and for the layers each, the first of: 1. `?modes=simple+dev` in a page's url, kept for the session (`?modes=` forgets it): to look at a page as someone else would; 2. what the user saved (`config.modes`, mmo.oauth through [`ModesPreference`](https://mmoframework.fr/documentation/mmo.client/php/events/ModesPreference.md#modespreference)); 3. what the user's roles give (`Role::$modes`, mmo.oauth through [`ModesPreference`](https://mmoframework.fr/documentation/mmo.client/php/events/ModesPreference.md#modespreference)); 4. the `mmo-modes` cookie, which the page writes when there is no user to save it on; 5. this module's [`$default`](https://mmoframework.fr/documentation/mmo.client/php/Modes.md#modes-default). A mode the user may not turn on (its scope, [`ModeAccess`](https://mmoframework.fr/documentation/mmo.client/php/events/ModeAccess.md#modeaccess)) is never shown. What takes part: - a page or a folder (`index.json`) with `"level": "expert"` is in the menu from that level up, and with `"modes": ["dev"]` only while one of these layers is on (`"!dev"` while it is off). Left out of the menu only: its url still opens it, its rights are its scopes'. - markup with `data-level="expert"` or `data-mode="dev"` (`"!dev"`): hidden by the stylesheet this module writes in every page ([`css`](https://mmoframework.fr/documentation/mmo.client/php/Modes.md#modes-css)), so it never flashes before the scripts run. - the page's scripts: `MMO.modes` (`has('dev')`, `atLeast('expert')`, `set()`), from `MMO.config.modes` ([`export`](https://mmoframework.fr/documentation/mmo.client/php/Modes.md#modes-export)), and `<mmo-app level="standard" layers="dev">`, which a stylesheet of the shadow DOM can read.
\MMO\client\mode()->has('dev'); // true when the developer layer is on\MMO\client\mode()->atLeast('expert'); // true at the expert level{"MMO\\client\\Modes": {"levels": ["simple", "standard", "expert"], "default": {"level": "standard"}, "modes": {"writer": {"kind": "layer", "label": "Writer", "icon": "pen", "scope": "modes.writer"}}}}

Index

LEVELSthe levels mmo.client knows: id => [label, icon, rank, description]
SESSIONthe session key of the url's override
access
all
cookie
default
enabled
layers
level
levels
modes
query
all()
atLeast($level)
available()
css()
DefaultConfig() static
export()
filterContents($contents)Leave out of the menu what the modes shown do not show (matches): a content keeps its url and its rights.
get($id)
has($id)
isAvailable($mode)
isEnabled()
isOverridden()
layerModes()
layers()
level()
levels()
matches($level, $modes)Whether what asks a $level and $modes is shown.
onDocumentInit($event)Give the page its modes: MMO.config.modes, the shell's level and layers attributes, and the css hiding what they leave out -- in the page itself, so nothing flashes before the scripts run.
onPageContents($contents)
override()
parse($spec)Read a modes' spec: what a url, the cookie or a saved preference say.
reset()forget what was resolved: the next call resolves again (another user, a test)
resolve()Work out the level and the layers shown, from the first source saying each (see the class).

Constantes2

LEVELS

the levels mmo.client knows: id => [label, icon, rank, description]

const LEVELS = […3 items]

SESSION

the session key of the url's override

const SESSION = 'mmo.client.modes'

Propriétés10

access

protected array $access = []
Type
array

all

protected ?array $all = null
Type
null | array

default

protected array $default = ['level' => 'standard', 'layers' => []]
Type
array

enabled

protected bool $enabled = true
Type
bool

layers

protected ?array $layers = null
Type
null | array

level

protected ?string $level = null
Type
null | string

levels

protected array $levels = ['standard']
Type
array

modes

protected array $modes = []
Type
array

query

protected string $query = 'modes'
Type
string

Méthodes23

atLeast($level)

Modes.php:171
function atLeast(string $level): bool
$levelstring
retourneboolwhether the level shown is $level or above it; an unknown level is never reached

available()

Modes.php:144
function available(): array
retournearrayMode> the modes whoever is asking may turn on

css()

Modes.php:308
function css(): string
retournestringthe css hiding what the modes shown leave out: [data-level] above the level, [data-mode] of a layer that is off (or !layer of one that is on)

export()

Modes.php:293
function export(): array
retournearraywhat the page is given (MMO.config.modes): the level and the layers shown, every mode whoever is asking may turn on, whether the url overrides them, and the cookie the page saves them in without a user

filterContents($contents)

Modes.php:325

Leave out of the menu what the modes shown do not show (matches): a content keeps its url and its rights.

function filterContents(array $contents): void
$contentsarray
retournevoid

has($id)

Modes.php:166
function has(string $id): bool
$idstringa layer, or a level
retourneboolwhether that layer is on, or that level is the one shown

isAvailable($mode)

Modes.php:136
function isAvailable(MMO\client\classes\Mode|string $mode): bool
$modeMode | string
retourneboolwhether whoever is asking may turn $mode on: a mode with no scope is everybody's (ModeAccess)

isOverridden()

Modes.php:281
function isOverridden(): bool
retourneboolwhether the url's override is what is shown (the page then says how to leave it)

levels()

Modes.php:126
function levels(): array
retournearrayMode> the levels, the lowest first

matches($level, $modes)

Modes.php:186

Whether what asks a $level and $modes is shown.

function matches(?string $level, array|string|null $modes = null): bool
$levelnull | stringthe level it is shown from (an unknown one: always shown, as when nothing asks)
$modes = nullarray | string | nulllayers, one of which must be on; !dev one which must be off
retournebool
$modes->matches('expert', null); // at the expert level only$modes->matches(null, ['dev']); // with the developer layer on only

onDocumentInit($event)

Modes.php:345

Give the page its modes: MMO.config.modes, the shell's level and layers attributes, and the css hiding what they leave out -- in the page itself, so nothing flashes before the scripts run.

function onDocumentInit(MMO\core\events\DocumentInit $event): void
$eventDocumentInit
retournevoid

onPageContents($contents)

Modes.php:335
function onPageContents(MMO\client\events\PageContents $contents): void
Voir
filterContents, before mmo.oauth's rights hide what a user may not open
$contentsPageContents
retournevoid

override()

Modes.php:266
protected function override(): array
retournearraystring, layers?: list<string>} what the url says (?modes=simple+dev), kept for the session; ?modes= forgets it

parse($spec)

Modes.php:206

Read a modes' spec: what a url, the cookie or a saved preference say.

function parse(mixed $spec): array
$specmixedsimple+dev, expert, +dev (layers alone), or {level, layers}
retournearraystring, layers?: list<string>} what it says, the unknown ids left out; a spec naming layers says they are the only ones (expert alone says nothing of the layers, + says there are none)
$modes->parse('simple+dev'); // ['level' => 'simple', 'layers' => ['dev']]

reset()

Modes.php:97

forget what was resolved: the next call resolves again (another user, a test)

function reset(): void
retournevoid

resolve()

Modes.php:230

Work out the level and the layers shown, from the first source saying each (see the class).

function resolve(): void
retournevoid
Membres hérités (47)
ConstantesDéclaré parDescription
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
PropriétésDéclaré parDescription
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.
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.
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.
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.