Uri
Resolves optional URI collection documents and provides normalized URI state, URL lookup and language-specific URI content resolution.
Standard URI runtime flow
Automatic bootstrap processing
The standard APPNETOS bootstrap initializes Core\Uri. The controller prepares URLs and the
normalized request slug, then performs document-based resolution only when getCollection()
supplies a URI collection.
No mapped collection
If getCollection() returns null, document resolution is skipped without
generating
a 404. Normalized URI information remains available and the application implements its own routing. This
does not disable the rest of the APPNETOS bootstrap.
Automatic document resolution
With a mapped collection, APPNETOS searches active URI documents using progressively shorter slug candidates. After a match, it processes redirects, permissions, render variables, content initialization, AJAX dispatch and the final response. Missing documents cause a 404; denied permissions cause a 403.
Language-specific child documents
The URI controller uses the already active language fallback keys to find an active child URI document. A
matching child supplies URI-specific metadata and content; otherwise the parent document is used. This
does
not change Core\Languages, the active language or
Core\Translations. It only selects child URI documents.
Document and URL getters
getById(), getBySlug(), getManyByIds() and
getManyBySlugs() resolve accessible, active URI documents. getUrl() and getUrlBySlug()
generate context-aware URLs from mapped documents. With no collection, document lookups return null or
empty
arrays.
Runtime segments
getSegments() exposes the normalized request path; getRuntimeSegments() and
getIndex()
expose unresolved segments after a successful document match. A root-document match currently does not
preserve additional path segments in the runtime index.
Example
$uri = Registry::get(Uri::class);
$document = $uri->getBySlug('products/furniture');
$url = $uri->getUrlBySlug('products/furniture');
$segments = $uri->getRuntimeSegments();
Public API Reference
Core\Uri
Class & Registry
Class:
Core\Uri
Extends:
Core\Uri\Base
use Core\Uri;
use Core\Registry;
$uri = Registry::get(Uri::class);
| Method | Description |
|---|---|
init():void |
Initializes URI dependencies, request URLs and the normalized slug, then performs document-based URI resolution when a URI collection is available. |
getUrl(ObjectId|string|null $id = null):string|null |
Returns the current request URL when no ID is supplied, or builds a context-aware URL for the accessible URI document identified by its ID. |
getUrlBySlug(string $slug):string|null |
Returns the context-aware URL of an accessible URI document identified by its slug, or
null if no matching document is available.
|
getById(ObjectId|string|null $id):UriDocument|null |
Retrieves an active, accessible URI document by its ID, preferring a matching
language-specific document when available. Returns null if no valid
document is found.
|
getBySlug(string $slug):UriDocument|null |
Retrieves an active, accessible URI document by its normalized slug, preferring a matching language-specific document when available. |
getManyByIds(array $ids):array |
Retrieves URI documents for the supplied IDs, applying active-state, permission and language resolution checks. Missing or inaccessible documents are omitted. |
getManyBySlugs(array $slugs):array |
Retrieves URI documents for the supplied slugs, applying active-state, permission and language resolution checks. Missing or inaccessible documents are omitted. |
getCollection():UriCollection|null |
Returns the URI collection used for document-based routing. The default implementation
returns null, disabling document-based URI resolution for the current
context.
|
getSegments():array |
Returns all normalized request slug segments as an indexed array, excluding the runtime context prefix. |
getRuntimeSegments():array |
Returns the remaining URI segments that were not consumed when resolving the matching URI document. |
getDocument():UriDocument|null |
Returns the resolved base URI document for the current request, or null if
none has been resolved.
|
getLanguageDocument():UriDocument|null |
Returns the language-resolved URI document selected for the current request, or null
if none has been resolved.
|
getRequestUri():string |
Returns the processed request URI with the query string and application base path removed. |
getSlug():string |
Returns the normalized request slug without the runtime context prefix. |
getResolvedSlug():string |
Returns the slug of the URI document matched during routing, which may be shorter than the original request slug. |
getIndex(int|null $index = null):array|string|null |
Returns all unresolved URI segments, or a single segment at the specified zero-based
index. Returns null if the requested index does not exist.
|
getBaseUrl():string |
Returns the current request's base URL, constructed from the resolved scheme and HTTP host. |
getSelfUrl():string |
Returns the complete current request URL, including its request URI and query string when available. |
getStatus():int|null |
Returns the HTTP status code recorded by URI processing, or null if no
status has been assigned.
|
getError():bool |
Indicates whether URI processing has recorded an error, such as a forbidden or not-found response. |
getContent():Content|null |
Returns the shared content controller associated with URI processing, or
null if it has not been initialized.
|