| 1: | <?php |
| 2: | |
| 3: | namespace LaravelUi5\Core\Infrastructure; |
| 4: | |
| 5: | use JsonException; |
| 6: | use LaravelUi5\Core\Infrastructure\Contracts\Ui5SourceStrategyInterface; |
| 7: | use LaravelUi5\Core\Introspection\App\Ui5AppSource; |
| 8: | use LaravelUi5\Core\Introspection\Library\Ui5LibrarySource; |
| 9: | |
| 10: | final readonly class WorkspaceStrategy extends AbstractSourceStrategy |
| 11: | { |
| 12: | public function __construct( |
| 13: | private string $srcPath |
| 14: | ) |
| 15: | { |
| 16: | } |
| 17: | |
| 18: | public function getSourcePath(): string |
| 19: | { |
| 20: | return $this->srcPath; |
| 21: | } |
| 22: | |
| 23: | |
| 24: | |
| 25: | |
| 26: | public function createAppSource(string $vendor): Ui5AppSource |
| 27: | { |
| 28: | return Ui5AppSource::fromWorkspace( |
| 29: | $this->getSourcePath(), |
| 30: | $vendor, |
| 31: | !app()->runningInConsole() |
| 32: | ); |
| 33: | } |
| 34: | |
| 35: | |
| 36: | |
| 37: | |
| 38: | public function createLibrarySource(string $vendor): Ui5LibrarySource |
| 39: | { |
| 40: | return Ui5LibrarySource::fromWorkspace($this->getSourcePath()); |
| 41: | } |
| 42: | } |
| 43: | |