| 1: | <?php |
| 2: | |
| 3: | namespace LaravelUi5\Core\Contracts; |
| 4: | |
| 5: | use Illuminate\Http\Request; |
| 6: | use LaravelUi5\Core\Ui5\Contracts\Ui5ArtifactInterface; |
| 7: | |
| 8: | /** |
| 9: | * Interface Ui5ContextInterface |
| 10: | * |
| 11: | * Defines the minimal technical runtime context contract for LaravelUi5. |
| 12: | * |
| 13: | * The context represents the *current execution scope* of a UI5 request |
| 14: | * and provides access to the technical information required by the Core |
| 15: | * to resolve and serve UI5 artifacts. |
| 16: | * |
| 17: | * This interface is intentionally minimal and semantically neutral. |
| 18: | * It must not expose business concepts, authorization data, or |
| 19: | * identity-related information. |
| 20: | * |
| 21: | * --------------------------------------------------------------------- |
| 22: | * Design principles |
| 23: | * --------------------------------------------------------------------- |
| 24: | * - Contract-first: consumers depend on this interface, not on a concrete class |
| 25: | * - Minimal surface: only information required by Core is exposed |
| 26: | * - Immutable by convention: one context per logical execution |
| 27: | * - Extensible: higher layers may provide richer implementations |
| 28: | * |
| 29: | * --------------------------------------------------------------------- |
| 30: | * Scope |
| 31: | * --------------------------------------------------------------------- |
| 32: | * Implementations of this interface may be created: |
| 33: | * - from HTTP requests (via middleware) |
| 34: | * - in console commands, jobs, or tests (without a Request) |
| 35: | * |
| 36: | * The actual implementation bound in the service container |
| 37: | * may vary depending on the active layer (Core-only or SDK-extended). |
| 38: | * |
| 39: | * --------------------------------------------------------------------- |
| 40: | * Responsibilities |
| 41: | * --------------------------------------------------------------------- |
| 42: | * The context provides: |
| 43: | * - access to the current HTTP request (if any) |
| 44: | * - access to the resolved UI5 artifact addressed by the URI |
| 45: | * - access to the effective locale for technical rendering |
| 46: | * |
| 47: | * The context does NOT: |
| 48: | * - perform authorization |
| 49: | * - represent tenants or users |
| 50: | * - interpret semantic meaning |
| 51: | * - resolve or dispatch intents |
| 52: | * |
| 53: | * @package LaravelUi5\Core\Contracts |
| 54: | */ |
| 55: | interface Ui5ContextInterface |
| 56: | { |
| 57: | /** |
| 58: | * Returns the current HTTP request, if available. |
| 59: | * |
| 60: | * Implementations must return null when the context |
| 61: | * was created outside of an HTTP lifecycle |
| 62: | * (e.g. console commands, queue jobs, tests). |
| 63: | * |
| 64: | * @return Request|null |
| 65: | */ |
| 66: | public function request(): ?Request; |
| 67: | |
| 68: | /** |
| 69: | * Returns the UI5 artifact resolved for the current execution. |
| 70: | * |
| 71: | * This artifact is determined by the Core based on the request URI |
| 72: | * and represents the technical entry point being served |
| 73: | * (e.g. App, Library, Report, Action). |
| 74: | * |
| 75: | * @return Ui5ArtifactInterface |
| 76: | */ |
| 77: | public function artifact(): Ui5ArtifactInterface; |
| 78: | |
| 79: | /** |
| 80: | * Returns the effective locale for this execution, if defined. |
| 81: | * |
| 82: | * The locale is used for technical rendering purposes |
| 83: | * (e.g. UI5 bootstrap, resource resolution). |
| 84: | * |
| 85: | * Implementations may return null when locale resolution |
| 86: | * is handled elsewhere. |
| 87: | * |
| 88: | * @return string|null |
| 89: | */ |
| 90: | public function locale(): ?string; |
| 91: | } |
| 92: |