Skip to content

Commit 0d6bea8

Browse files
authored
CmsExtension: Add custom homepage option (#68)
1 parent bca73c0 commit 0d6bea8

1 file changed

Lines changed: 17 additions & 1 deletion

File tree

src/CmsExtension.php

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ public function getConfigSchema(): Schema
6161
'url' => Expect::string()->required(),
6262
])->castTo('array'),
6363
)),
64+
'homepage' => Expect::string()->nullable(),
6465
]);
6566
}
6667

@@ -157,13 +158,28 @@ public function beforeCompile(): void
157158

158159
/** @var ServiceDefinition $pluginManager */
159160
$pluginManager = $this->getContainerBuilder()->getDefinitionByType(PluginManager::class);
161+
162+
// Homepage
163+
$homepageSource = $this->config->homepage !== null
164+
? $this->config->homepage : __DIR__ . '/../template/vue/homepage-default.js';
165+
166+
if (is_file($homepageSource) === false) {
167+
if ($this->config->homepage !== null) {
168+
throw new \RuntimeException(
169+
'Custom homepage file "' . $this->config->homepage . '" does not exist. ' .
170+
'Please check the path in your configuration or remove the homepage setting to use the default.'
171+
);
172+
}
173+
throw new \RuntimeException('Default homepage file "' . $homepageSource . '" does not exist.');
174+
}
175+
160176
$pluginManager->addSetup('?->addComponent(?)', ['@self', [
161177
'key' => 'homepageDashboardDefault',
162178
'name' => 'homepage-default',
163179
'implements' => HomepagePlugin::class,
164180
'componentClass' => VueComponent::class,
165181
'view' => 'default',
166-
'source' => __DIR__ . '/../template/vue/homepage-default.js',
182+
'source' => $homepageSource,
167183
'position' => 100,
168184
'tab' => 'Dashboard',
169185
'params' => [],

0 commit comments

Comments
 (0)