Plugins support (#592)
This commit is contained in:
@@ -23,6 +23,8 @@ use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait;
|
||||
use Symfony\Component\Config\Loader\LoaderInterface;
|
||||
use Symfony\Component\DependencyInjection\Compiler\PassConfig;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\Finder\Finder;
|
||||
use Symfony\Component\Finder\SplFileInfo;
|
||||
use Symfony\Component\HttpKernel\Kernel as BaseKernel;
|
||||
use Symfony\Component\Routing\RouteCollectionBuilder;
|
||||
|
||||
@@ -64,6 +66,30 @@ class Kernel extends BaseKernel
|
||||
yield new $class();
|
||||
}
|
||||
}
|
||||
|
||||
$pluginsDir = $this->getProjectDir() . '/var/plugins';
|
||||
if (!file_exists($pluginsDir)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$finder = new Finder();
|
||||
$finder->ignoreUnreadableDirs()->directories()->name('*Bundle');
|
||||
/** @var SplFileInfo $bundleDir */
|
||||
foreach ($finder->in($pluginsDir) as $bundleDir) {
|
||||
$bundleName = $bundleDir->getRelativePathname();
|
||||
|
||||
$bundleFilename = $bundleDir->getRealPath() . '/' . $bundleName . '.php';
|
||||
if (!file_exists($bundleFilename)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$pluginClass = 'KimaiPlugin\\' . $bundleName . '\\' . $bundleName;
|
||||
if (!class_exists($pluginClass)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
yield new $pluginClass;
|
||||
}
|
||||
}
|
||||
|
||||
protected function configureContainer(ContainerBuilder $container, LoaderInterface $loader)
|
||||
@@ -106,6 +132,10 @@ class Kernel extends BaseKernel
|
||||
|
||||
// load application routes
|
||||
$routes->import($confDir . '/routes' . self::CONFIG_EXTS, '/', 'glob');
|
||||
|
||||
// load plugin routes
|
||||
$pluginsDir = $this->getProjectDir() . '/var/plugins';
|
||||
$routes->import($pluginsDir . '/*Bundle/Resources/config/routes'. self::CONFIG_EXTS, '/', 'glob');
|
||||
}
|
||||
|
||||
protected function configureFosUserRoutes(RouteCollectionBuilder $routes)
|
||||
|
||||
Reference in New Issue
Block a user