Uri
Localized URI documents and flexible routing without coupling URLs to language selection.
Document-based routing is optional
Concrete runtime contexts can override Core\Uri::getCollection() to map a URI collection.
Without one, APPNETOS skips document-based URI resolution and leaves application routing to the
developer.
Stored slugs omit the leading slash, domain and context prefix.
Request resolution
Unmatched trailing segments remain accessible as a runtime index. A missing document results in the 404 fallback when document-based routing is enabled.
Global URI and localized children
A base URI document can have active child documents identified by parentId and
languageKey. The runtime controller asks Core\Languages for the language
fallback
keys and looks up an active matching child. When none exists, it retains the base document. The URI
itself
does not change the selected runtime language.
The supplied Core\Uri\Base
initializes content using the selected child document when one is found. Whether the document model
inherits
or merges content fields from its parent must be verified in the URI document implementation; do not
assume
an automatic field-level merge.
Resolution and lookup API
getDocument() returns the base document resolved for the request, while getLanguageDocument()
returns the document selected by the language resolver (which may be the base document).
getSlug() is the normalized request slug; getResolvedSlug() is the matched
document slug. getRuntimeSegments() and getIndex() expose unresolved trailing
path
segments.
$uri = Registry::get(\Core\Uri::class);
$document = $uri->getDocument();
$languageDocument = $uri->getLanguageDocument();
$slug = $uri->getResolvedSlug();
$remaining = $uri->getRuntimeSegments();
Other lookup methods include getById(), getBySlug(),
getManyByIds(),
getManyBySlugs(), getUrl() and getUrlBySlug(). Lookup methods
check
for active documents and permissions; URL generation respects the runtime context prefix unless the
context
is resolved through a domain or subdomain.
URI Loader
Core\Uri\Loader\Base offers reusable ID/slug lookups and maps through the active URI
collection.
If no collection is configured, it returns null or empty results. The loader does not
implement
a separate cache; it benefits from the collection layer's caching. Its direct lookups return active
documents and do not independently apply the URI controller's localized-child or permission-resolution
logic.
Additional runtime behavior
The URI controller supports redirect URLs and redirect document IDs (301, 302, 307 and 308), group-based permission checks, render title/favicon metadata, content initialization, AJAX dispatch and response delivery.
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 |
|---|---|
getUrl(ObjectId|string|null $id = null): string|null |
Resolve the URL for a URI document ID, or the current document when omitted. |
getUrlBySlug(string $slug): string|null |
Resolve the URL for a stored URI slug. |
getById(ObjectId|string|null $id): UriDocument|null |
Look up an active URI document by ID, subject to controller checks. |
getBySlug(string $slug): UriDocument|null |
Look up an active URI document by slug, subject to controller checks. |
getManyByIds(array $ids): array |
Retrieve URI documents matching multiple IDs. |
getManyBySlugs(array $slugs): array |
Retrieve URI documents matching multiple slugs. |
getCollection(): UriCollection|null |
Return the mapped URI collection, or null when document routing is disabled. |
getSegments(): array |
Return normalized request path segments. |
getRuntimeSegments(): array |
Return the unresolved trailing request segments. |
getDocument(): UriDocument|null |
Return the base document resolved for the request. |
getLanguageDocument(): UriDocument|null |
Return the localized document selected for the request, if any. |
getRequestUri(): string |
Return the request URI. |
getSlug(): string |
Return the normalized request slug. |
getResolvedSlug(): string |
Return the matched document slug. |
getIndex(int|null $index = null): array|string|null |
Return the remaining route index or one indexed segment. |
getBaseUrl(): string |
Return the base URL for the current context. |
getSelfUrl(): string |
Return the URL for the current request. |
getStatus(): int|null |
Return the current response status, if set. |
getError(): bool |
Indicate whether URI resolution has an error. |
getContent(): Content|null |
Return the resolved content object, if present. |