1: <?php
2:
3: namespace LaravelUi5\Core\Services;
4:
5: use Illuminate\Http\Request;
6: use LaravelUi5\Core\Contracts\Ui5ArtifactResolverInterface;
7: use LaravelUi5\Core\Enums\ArtifactType;
8: use LaravelUi5\Core\Ui5\Contracts\Ui5ArtifactInterface;
9: use LaravelUi5\Core\Ui5\Contracts\Ui5RegistryInterface;
10: use LaravelUi5\Core\Ui5CoreServiceProvider;
11:
12: readonly class PathBasedArtifactResolver implements Ui5ArtifactResolverInterface
13: {
14:
15: public function __construct(
16: private Ui5RegistryInterface $registry
17: )
18: {
19: }
20:
21: public function resolve(Request $request): ?Ui5ArtifactInterface
22: {
23: $path = $request->route('namespace');
24:
25: if (!is_string($path) || '' === $path) {
26: return null;
27: }
28:
29: $namespace = $this->registry->pathToNamespace($path);
30:
31: return $this->registry->get($namespace);
32: }
33: }
34: