Skip to content

Commit

Permalink
Merge pull request #6324 from rossriley/fix/local-extension-fixes
Browse files Browse the repository at this point in the history
Add support for extension definition in bolt.yml file
  • Loading branch information
GwendolenLynch committed Jan 31, 2017
2 parents 7c50ae8 + eb4b9ac commit 56a054f
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions app/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
use Bolt\Configuration\Standard;
use Bolt\Debug\ShutdownHandler;
use Bolt\Exception\BootException;
use Bolt\Extension\ExtensionInterface;
use LogicException;
use Silex;
use Symfony\Component\Yaml\Yaml;

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

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

}

$app['extensions'] = $app->share(
$app->extend('extensions', function ($extensions) use ($config) {
foreach ((array)$config['extensions'] as $extensionClass) {
if (is_string($extensionClass) && class_exists($extensionClass, true)) {
$extensionClass = new $extensionClass();
} else {
throw new LogicException(sprintf('Unable to load extension class %s', $extensionClass));
}
if ($extensionClass instanceof ExtensionInterface) {
$extensions->add($extensionClass);
}
}

return $extensions;
})
);

return $app;
});

0 comments on commit 56a054f

Please sign in to comment.