1: <?php
2:
3: namespace LaravelUi5\Core\Ui5;
4:
5: use LaravelUi5\Core\Enums\ArtifactType;
6: use LaravelUi5\Core\Infrastructure\Contracts\Ui5SourceStrategyInterface;
7: use LaravelUi5\Core\Ui5\Contracts\Ui5ModuleInterface;
8:
9: /**
10: * Abstract base class for a UI5 module definition.
11: *
12: * A module represents a self-contained unit of business logic and artifacts,
13: * and is registered via config/ui5.php under the 'modules' key.
14: * Each module is assigned a unique route-level slug used in all URL constructions.
15: *
16: * It may provide one App or one Library (not both), and related sub-artifacts
17: * such as Cards, Reports, Tiles, and Actions. All artifact instances are expected
18: * to be fully constructed and ready to register at boot time.
19: */
20: abstract class AbstractUi5Module implements Ui5ModuleInterface
21: {
22: protected string $slug;
23:
24: protected Ui5SourceStrategyInterface $strategy;
25:
26: /**
27: * Create a new UI5 module instance.
28: *
29: * @param string $slug Route-level slug as configured in config/ui5.php
30: * @param Ui5SourceStrategyInterface $strategy Physical path where this module resides in
31: */
32: public function __construct(string $slug, Ui5SourceStrategyInterface $strategy)
33: {
34: $this->slug = $slug;
35: $this->strategy = $strategy;
36: }
37:
38: public function getType(): ArtifactType
39: {
40: return ArtifactType::Module;
41: }
42:
43: public function getSlug(): string
44: {
45: return $this->slug;
46: }
47:
48: public function getSourceStrategy(): Ui5SourceStrategyInterface
49: {
50: return $this->strategy;
51: }
52:
53: public function getAllArtifacts(): array
54: {
55: return [
56: $this->getArtifactRoot(),
57: ...$this->getCards(),
58: ...$this->getKpis(),
59: ...$this->getTiles(),
60: ...$this->getActions(),
61: ...$this->getResources(),
62: ...$this->getReports(),
63: ...$this->getDashboards(),
64: ...$this->getDialogs(),
65: ];
66: }
67: }
68: