Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for extension definition in bolt.yml file #6324

Merged
merged 3 commits into from
Jan 31, 2017
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions app/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Bolt\Configuration\Standard;
use Bolt\Debug\ShutdownHandler;
use Bolt\Exception\BootException;
use Bolt\Extension\ExtensionInterface;
use Silex;
use Symfony\Component\Yaml\Yaml;

Expand Down Expand Up @@ -81,6 +82,7 @@
'resources' => null,
'paths' => [],
'services' => [],
'extensions' => [],
];

if (file_exists($rootPath . '/.bolt.yml')) {
Expand Down Expand Up @@ -184,5 +186,27 @@

}

$extensionArray = [];
foreach ((array)$config['extensions'] as $extensionClass) {
if (is_string($extensionClass)) {
$extensionClass = new $extensionClass();
}
if ($extensionClass instanceof ExtensionInterface) {
$extensionArray[] = $extensionClass;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we invert and throw an exception as discussed in Slack?

}
}

if (count($extensionArray)) {
$app['extensions'] = $app->share(
$app->extend('extensions', function ($extensions) use ($extensionArray) {
foreach ($extensionArray as $ext) {
$extensions->add($ext);
}

return $extensions;
})
);
}

return $app;
});