| 1: | <?php |
| 2: | |
| 3: | namespace LaravelUi5\Core\Ui5; |
| 4: | |
| 5: | use LaravelUi5\Core\Exceptions\MissingDashboardException; |
| 6: | use LaravelUi5\Core\Traits\SluggedSource; |
| 7: | use LaravelUi5\Core\Ui5\Contracts\Ui5DashboardInterface; |
| 8: | use LaravelUi5\Core\Ui5\Contracts\Ui5ModuleInterface; |
| 9: | |
| 10: | abstract class AbstractUi5Dashboard implements Ui5DashboardInterface |
| 11: | { |
| 12: | use SluggedSource; |
| 13: | |
| 14: | public function __construct(protected Ui5ModuleInterface $module) |
| 15: | { |
| 16: | } |
| 17: | |
| 18: | public function getModule(): Ui5ModuleInterface |
| 19: | { |
| 20: | return $this->module; |
| 21: | } |
| 22: | |
| 23: | public function getDashboard(): string |
| 24: | { |
| 25: | $path = $this->getModule() |
| 26: | ->getSourceStrategy() |
| 27: | ->resolvePath("dashboards/{$this->getSlug()}.blade.php"); |
| 28: | |
| 29: | if (!file_exists($path)) { |
| 30: | throw new MissingDashboardException($path); |
| 31: | } |
| 32: | |
| 33: | return file_get_contents($path); |
| 34: | } |
| 35: | } |
| 36: | |