1: <?php
2:
3: namespace LaravelUi5\Core\Infrastructure\Contracts;
4:
5: use LaravelUi5\Core\Introspection\App\Ui5AppSource;
6: use LaravelUi5\Core\Introspection\Library\Ui5LibrarySource;
7: use LogicException;
8:
9: /**
10: * Strategy interface for resolving and accessing UI5 source artifacts.
11: *
12: * A Ui5SourceStrategy encapsulates *how* UI5 resources for a given module
13: * are located and accessed, depending on the module's origin.
14: *
15: * Typical implementations include:
16: * - Workspace-based strategies (live UI5 projects under development)
17: * - Package-based strategies (Composer-installed, self-contained modules)
18: *
19: * The strategy is resolved centrally (e.g. by the Ui5Registry) and is
20: * responsible for:
21: * - determining the runtime UI5 resource path,
22: * - and, optionally, creating an introspection-capable Ui5Source instance.
23: *
24: * Important:
25: * - The runtime path must always be resolvable and usable.
26: * - Introspection may be expensive and is therefore optional.
27: * - Consumers must not assume that introspection is available.
28: */
29: interface Ui5SourceStrategyInterface
30: {
31: /**
32: * Returns the absolute filesystem path to the runtime UI5 resources
33: * of the associated module.
34: *
35: * This path must point to a directory containing consumable UI5 artifacts
36: * such as:
37: * - manifest.json
38: * - preload bundles
39: * - i18n files
40: *
41: * The returned path is guaranteed to exist and be readable.
42: *
43: * @return string Absolute path to runtime UI5 resources.
44: */
45: public function getSourcePath(): string;
46:
47: /**
48: * Creates and returns a Ui5AppSource instance for introspection.
49: *
50: * This method MUST only be called if supportsAppIntrospection() returns true.
51: * Implementations may perform filesystem access, parsing, or other
52: * expensive operations.
53: *
54: * @param string $vendor The package vendor.
55: *
56: * @return Ui5AppSource Introspection-capable UI5 source object.
57: * @throws LogicException If introspection is not supported.
58: */
59: public function createAppSource(string $vendor): Ui5AppSource;
60:
61: /**
62: * Creates and returns a Ui5LibrarySource instance for introspection.
63: *
64: * This method MUST only be called if supportsLibraryIntrospection() returns true.
65: * Implementations may perform filesystem access, parsing, or other
66: * expensive operations.
67: *
68: * @return Ui5LibrarySource Introspection-capable UI5 source object.
69: * @throws LogicException If introspection is not supported.
70: */
71: public function createLibrarySource(string $vendor): Ui5LibrarySource;
72: }
73: