| 1: | <?php |
| 2: | |
| 3: | namespace LaravelUi5\Core\Ui5; |
| 4: | |
| 5: | use LaravelUi5\Core\Enums\ArtifactType; |
| 6: | use LaravelUi5\Core\Exceptions\MissingArtifactRootException; |
| 7: | use LaravelUi5\Core\Infrastructure\Contracts\Ui5SourceStrategyInterface; |
| 8: | use LaravelUi5\Core\Ui5\Contracts\Ui5AppInterface; |
| 9: | use LaravelUi5\Core\Ui5\Contracts\Ui5LibraryInterface; |
| 10: | use LaravelUi5\Core\Ui5\Contracts\Ui5ModuleInterface; |
| 11: | |
| 12: | |
| 13: | |
| 14: | |
| 15: | |
| 16: | |
| 17: | |
| 18: | |
| 19: | |
| 20: | |
| 21: | |
| 22: | |
| 23: | abstract class AbstractUi5Module implements Ui5ModuleInterface |
| 24: | { |
| 25: | protected Ui5SourceStrategyInterface $strategy; |
| 26: | |
| 27: | |
| 28: | |
| 29: | |
| 30: | |
| 31: | |
| 32: | public function __construct(Ui5SourceStrategyInterface $strategy) |
| 33: | { |
| 34: | $this->strategy = $strategy; |
| 35: | } |
| 36: | |
| 37: | public function getApp(): ?Ui5AppInterface |
| 38: | { |
| 39: | return null; |
| 40: | } |
| 41: | |
| 42: | public function hasApp(): bool |
| 43: | { |
| 44: | return null !== $this->getApp(); |
| 45: | } |
| 46: | |
| 47: | public function getLibrary(): ?Ui5LibraryInterface |
| 48: | { |
| 49: | return null; |
| 50: | } |
| 51: | |
| 52: | public function hasLibrary(): bool |
| 53: | { |
| 54: | return null !== $this->getLibrary(); |
| 55: | } |
| 56: | |
| 57: | public function getArtifactRoot(): Ui5AppInterface|Ui5LibraryInterface |
| 58: | { |
| 59: | if ($this->hasApp()) { |
| 60: | return $this->getApp(); |
| 61: | } |
| 62: | |
| 63: | if ($this->hasLibrary()) { |
| 64: | return $this->getLibrary(); |
| 65: | } |
| 66: | |
| 67: | throw new MissingArtifactRootException(get_class($this)); |
| 68: | } |
| 69: | |
| 70: | public function getType(): ArtifactType |
| 71: | { |
| 72: | return ArtifactType::Module; |
| 73: | } |
| 74: | |
| 75: | public function getSourceStrategy(): Ui5SourceStrategyInterface |
| 76: | { |
| 77: | return $this->strategy; |
| 78: | } |
| 79: | |
| 80: | public function getAllArtifacts(): array |
| 81: | { |
| 82: | return [ |
| 83: | $this->getArtifactRoot(), |
| 84: | ...$this->getCards(), |
| 85: | ...$this->getKpis(), |
| 86: | ...$this->getTiles(), |
| 87: | ...$this->getActions(), |
| 88: | ...$this->getResources(), |
| 89: | ...$this->getReports(), |
| 90: | ...$this->getDashboards(), |
| 91: | ...$this->getDialogs(), |
| 92: | ]; |
| 93: | } |
| 94: | } |
| 95: | |