diff --git a/src/CmsExtension.php b/src/CmsExtension.php index ab44531..44edec8 100644 --- a/src/CmsExtension.php +++ b/src/CmsExtension.php @@ -61,6 +61,7 @@ public function getConfigSchema(): Schema 'url' => Expect::string()->required(), ])->castTo('array'), )), + 'homepage' => Expect::string()->nullable(), ]); } @@ -157,13 +158,28 @@ public function beforeCompile(): void /** @var ServiceDefinition $pluginManager */ $pluginManager = $this->getContainerBuilder()->getDefinitionByType(PluginManager::class); + + // Homepage + $homepageSource = $this->config->homepage !== null + ? $this->config->homepage : __DIR__ . '/../template/vue/homepage-default.js'; + + if (is_file($homepageSource) === false) { + if ($this->config->homepage !== null) { + throw new \RuntimeException( + 'Custom homepage file "' . $this->config->homepage . '" does not exist. ' . + 'Please check the path in your configuration or remove the homepage setting to use the default.' + ); + } + throw new \RuntimeException('Default homepage file "' . $homepageSource . '" does not exist.'); + } + $pluginManager->addSetup('?->addComponent(?)', ['@self', [ 'key' => 'homepageDashboardDefault', 'name' => 'homepage-default', 'implements' => HomepagePlugin::class, 'componentClass' => VueComponent::class, 'view' => 'default', - 'source' => __DIR__ . '/../template/vue/homepage-default.js', + 'source' => $homepageSource, 'position' => 100, 'tab' => 'Dashboard', 'params' => [],