Commit e2aab40e authored by Tino Goratsch's avatar Tino Goratsch

it is now possible that module register their own compiler passes

parent 54f0ce1a
......@@ -92,11 +92,14 @@ class ServiceContainerBuilder extends ContainerBuilder
foreach ($availableModules as $module) {
foreach ($vendors as $vendor) {
$path = $this->applicationPath->getModulesDir() . $vendor . '/' . $module['dir'] . '/Resources/config/services.yml';
$modulePath = $this->applicationPath->getModulesDir() . $vendor . '/' . $module['dir'];
$path = $modulePath . '/Resources/config/services.yml';
if (is_file($path)) {
$loader->load($path);
}
$this->registerCompilerPass($vendor, $module['dir']);
}
}
......@@ -118,4 +121,21 @@ class ServiceContainerBuilder extends ContainerBuilder
) {
return new static($applicationPath, $symfonyRequest, $applicationMode, $allModules);
}
/**
* @param string $vendor
* @param string $moduleName
*/
private function registerCompilerPass($vendor, $moduleName)
{
$fqn = "\\ACP3\\Modules\\" . $vendor . "\\" . $moduleName . "\\ModuleRegistration";
if (class_exists($fqn)) {
$instance = new $fqn;
if ($instance instanceof Modules\ModuleRegistration) {
$instance->build($this);
}
}
}
}
<?php
/**
* Copyright (c) 2016 by the ACP3 Developers.
* See the LICENCE file at the top-level module directory for licencing details.
*/
namespace ACP3\Core\Modules;
use Symfony\Component\DependencyInjection\ContainerBuilder;
class ModuleRegistration
{
public function build(ContainerBuilder $containerBuilder)
{
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment