APIRoute
MMO\core\attributes ยท 1 symbol ยท generated 30 Sep 2026
APIRoute
APIRoute.php:78Class to use to match a route in the router.
- Namespace
MMO\core\attributes- Implements
- JsonSerializable, Stringable
- Uses traits
- tWithOptions
Index
Properties10
body
cookie
fragment
header
info
- Type
- array
method
opts
- Type
- array
order
- Type
- int
path
- Type
- Path
query
Methods44
addAPIParameter($parameters, $info)
APIRoute.php:239addAPIParameters($params, $in)
APIRoute.php:256addInfo($info, $default)
APIRoute.php:153Add information to the route
addOptions($opts, $appendList)
tWithOptions.php:65Merge $opts into the existing options (through merge), rather than replacing them wholesale like setOptions.
| $opts | array | the options to merge in |
| $appendList = false | bool | if true, a list-valued option is appended to (rather than replaced by) the corresponding list in $opts -- see \MMO\core\arrays\merge for the exact semantics |
| returns | void |
api()
APIRoute.php:282Build this route's OpenAPI operation object (path parameters, query/header/cookie parameters, request body, merged with any extra addInfo info).
clearOptions()
tWithOptions.php:39Empty the options bag.
| returns | void |
createRequest($data, $method)
APIRoute.php:171Build a real Request matching this route, useful to synthesize/test a call without going through HTTP.
debugName()
APIRoute.php:133| returns | string | e.g. 'route:getUser' |
getBody($data)
APIRoute.php:507getCookie($data)
APIRoute.php:527getFragment()
APIRoute.php:346getHeader($data)
APIRoute.php:517getInfo($key, $default)
APIRoute.php:157getMethod()
APIRoute.php:223getOperation()
APIRoute.php:108| returns | callable | string | null | the id/callable this route was bound to (tWithRoutes::ConnectListeners) |
getOption($key, $default)
tWithOptions.php:49getOptions()
tWithOptions.php:20| returns | array | every option currently set |
getOrder()
APIRoute.php:537| returns | int | this route's matching priority (lower runs first among routes that both match) |
getParameters($in, $data)
APIRoute.php:470getPath()
APIRoute.php:331| returns | Path | the route's path (without method/query/fragment) |
getQuery($data)
APIRoute.php:497getUrl($data, $absolute)
APIRoute.php:364Get path url. If no data are passed, it return a relative url with placeholders
| $data = null | null | array | if null won't expand the data |
| $absolute = false | bool | if true, resolve to an absolute URL via \MMO\url() |
| returns | string | |
| throws | if $data is given but is missing a required query/fragment placeholder |
hasInfo($key)
APIRoute.php:161jsonSerialize()
APIRoute.php:143match($request, $matches)
APIRoute.php:185Check if a request match this path.
setBasepath($path)
APIRoute.php:452setBody($value)
APIRoute.php:512setCookie($value)
APIRoute.php:532setFragment($fragment)
APIRoute.php:351setHeader($value)
APIRoute.php:522setMethod($method)
APIRoute.php:232setOperation($id)
APIRoute.php:116setOption($key, $value)
tWithOptions.php:77Set (or, with a null $value, remove) a single option.
setOptions($opts)
tWithOptions.php:30Replace the whole options bag.
setOrder($value)
APIRoute.php:542setParameters($in, $value)
APIRoute.php:487Set parameters capture information
setPath($path)
APIRoute.php:341Same as From, except wildcard are converted to placeholders
setQuery($value)
APIRoute.php:502setUrl($url)
APIRoute.php:423Parse a full {method}|{path}?{query}#{fragment} route URL (see this class's own docblock for the format) and set every corresponding property (method, path, query, fragment) from it.
toLink($data, $rels)
APIRoute.php:462| $data = null | null | array | placeholder values, see getUrl |
| $rels = '' | array | string | one or more link relation types, e.g. 'self' or ['edit', 'delete'] |
| returns | Link | a Link pointing at this route's (expanded) URL |
uid()
APIRoute.php:127| returns | string | the operation id, or a readable name derived from its callable if it isn't a string |
__construct($url, $info, $body, $mediaTypes, $order, $options)
APIRoute.php:92__toString()
APIRoute.php:138| returns | string | e.g. 'GET|users/{id:integer}' |