Index

aController

MMO\core\classes · 1 symbol · generated 5 Oct 2026

class

aController

aController.php:71

Base class for any controller.

abstract class MMO\core\classes\aController extends MMO\core\classes\aModule use MMO\core\classes\tWithRoutes
Namespace
MMO\core\classes
Extends
aModule
Uses traits
tWithRoutes
WARNING: This first controller that matches the route is executed. There can be only one controller per request. You should tend to respect the general json api format for an answer if applicable. [json api](https://jsonapi.org/format/#query-parameters-families) # Answer's format ```json { data: { index: {..}//index is for the pagination }, links: { self: //current url for this request first: // if pagination first page for this request last: // if pagination last page for this request prev: // if pagination previous page for this request next: // if pagination next page for this request }, logs: [..]//server logs } ``` # Entity querying ## Pagination the pagination is provided in the query with `page[offset]` and `page[limit]` example: xxx?page[offset]=0&page[limit]=10 ## Sort request the sorting parameter is provided in the query as a comma separated value, with - for descending sorting example: xxx?sort=-created,title => sort by create(DESC) and title(ASC) ## Add/show fields example xxx?fields=articles.title,-articles.body,people.name => article.body is hidden ## Limit listing to ids example xxx?listOnly ## Filter request the filter is provided as a family under the format `filter[xxx]` example: xxx?filters[age][&gt;]=20&filters[age][&lt;]=50&filters[author.status]=active => (age > 20) && (age < 50) && (author.status = active)
class HealthController extends aController { #[APIRoute('GET|health.json', 'Health check', mediaTypes: ['json'])] public function routeHealth(Route $route): array {return ['status' => 'ok'];} } // registered with the Application, GET /health.json now serves this controller

Index

ExtractRoutes($config) staticExtract all the APIRoute from this class, regardless of the fact they are registered in the application
HasRoutes() staticTells if any APIRoute are registered in the application
Link($method, $data) staticBuild a Link (URL + label/icon/description/title, taken from the route's APIRoute metadata) for a registered route.
onRoute($route)This function is called before any api route declared.
Route($method) staticGet a registered APIRoute WARNING: if this class was not registered in the application, it will return null.
Routes() staticGet 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.
Url($method, $data) staticBuild the URL for a registered route, filling in any {placeholder} from $data.
__wakeup()Called 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…

Methods8

ExtractRoutes($config)

statictWithRoutes.php:92

Extract all the APIRoute from this class, regardless of the fact they are registered in the application

static function ExtractRoutes(array $config = []): array
$config = []array
returnsarray
RepositoryController::ExtractRoutes(); // every #[APIRoute] declared on this class, via reflection, // even if the class was never registered with an Application

HasRoutes()

statictWithRoutes.php:52

Tells if any APIRoute are registered in the application

static function HasRoutes(): bool
returnsbool
RepositoryController::HasRoutes(); // true once this controller has been registered with the Application

onRoute($route)

aController.php:94

This function is called before any api route declared.

function onRoute(MMO\core\server\Route $route): boolClaims $route for this controller ([`Route::setController`](https://mcp.mmoframework.fr/documentation/mmo.core/php/server/Route.md#route-setcontroller)) if no controller has claimed it yet -- since "the first controller that matches the route is executed" (see this class's own docblock), a controller that finds the route already claimed removes itself from the route's remaining middleware chain instead of running.
$routeRoute
returnsbooltrue if this controller became the route's main controller

Route($method)

statictWithRoutes.php:43

Get a registered APIRoute WARNING: if this class was not registered in the application, it will return null.

static function Route(string $method): ?MMO\core\attributes\APIRouteuse ExtractRoutes instead to get a list of all APIRoute, even if the class is not registered in the application
$methodstringthe name of the method carrying the #[APIRoute] attribute
returnsnull | APIRoute
RepositoryController::Route('routeSchemas'); // the APIRoute for that method, or null if not registered

Routes()

statictWithRoutes.php:31

Get 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.

static function Routes(): arrayuse ExtractRoutes instead to get a list of all APIRoute, even if the class is not registered in the application
returnsarray
RepositoryController::Routes(); // every APIRoute this controller registered with the running Application

Url($method, $data)

statictWithRoutes.php:64

Build the URL for a registered route, filling in any {placeholder} from $data.

static function Url(string $method, ?array $data = null): string
$methodstringthe name of the method carrying the #[APIRoute] attribute
$data = nullnull | arrayvalues for the route's URL placeholders (e.g. {uid} in data.json?uid={uid})
returnsstring
throwsif $method has no registered route (either the class or the method is not routed)
RepositoryController::Url('routeEntity', ['uid' => 'user/42']); // e.g. '/data.json?uid=user/42'

__wakeup()

aController.php:80

Called 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 runs before any of this controller's own #[APIRoute] handlers.

function __wakeup(): void
returnsvoid
Inherited members (48)
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.
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.
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.