Skip to content

Commit bd6c116

Browse files
committed
Merge remote-tracking branch 'origin/2.5' into 2026.1
2 parents 369021a + 75d83c5 commit bd6c116

1 file changed

Lines changed: 61 additions & 12 deletions

File tree

.github/ci/files/kernel/Kernel.php

Lines changed: 61 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,35 +11,84 @@
1111

1212
namespace App;
1313

14+
use Pimcore\Config\BundleConfigLocator;
1415
use Pimcore\Kernel as BaseKernel;
1516
use Symfony\Component\Config\Loader\LoaderInterface;
1617
use Symfony\Component\DependencyInjection\ContainerBuilder;
17-
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
1818

1919
class Kernel extends BaseKernel
2020
{
2121
/**
22-
* Override configureContainer to prevent MicroKernelTrait from auto-loading
23-
* config/services.yaml. In this CI setup, the bundle IS the project root,
24-
* so config/services.yaml belongs to the bundle and is already loaded by the
25-
* bundle extension's load() method. Loading it again here would overwrite
22+
* Override registerContainerConfiguration() to prevent MicroKernelTrait from
23+
* auto-loading config/services.yaml. In this CI setup, the bundle IS the project
24+
* root, so config/services.yaml belongs to the bundle and is already loaded by
25+
* the bundle extension's load() method. Loading it again here would overwrite
2626
* the programmatic argument assignments made by the extension
2727
* (e.g., $clientType, $queueSettings on SearchIndexConfigServiceInterface
2828
* and DispatchQueueMessagesHandler).
2929
*
30-
* We still load packages and environment-specific service files
31-
* (services_test.yaml) which provide test-only service overrides.
30+
* Previously this was achieved by overriding the protected configureContainer()
31+
* extension point exposed by Pimcore\Kernel via a MicroKernelTrait alias.
32+
* That extension point relies on a private method of Symfony's MicroKernelTrait
33+
* whose signature is not part of Symfony's public API and changes between
34+
* minor versions. Overriding the public registerContainerConfiguration() method
35+
* instead avoids this coupling and remains stable across Symfony 6.4, 7.x and
36+
* future versions.
37+
*
38+
* This implementation mirrors Pimcore\Kernel::registerContainerConfiguration()
39+
* (BundleConfigLocator + packages + env services) but intentionally skips the
40+
* MicroKernelTrait services.yaml auto-load and the dynamic Pimcore config
41+
* directories (image_thumbnails, document_types, etc.) which are not used in
42+
* this bundle's CI.
3243
*/
33-
protected function configureContainer(ContainerConfigurator $container, LoaderInterface $loader, ContainerBuilder $builder): void
44+
public function registerContainerConfiguration(LoaderInterface $loader): void
3445
{
35-
$configDir = $this->getProjectDir() . '/{config}';
46+
// Register the synthetic "kernel" service and configure the framework
47+
// router to load its routes from kernel::loadRoutes(). This is normally
48+
// done by MicroKernelTrait::registerContainerConfiguration(); we
49+
// replicate the relevant bits here so the kernel may be depended on via
50+
// DI and so framework.router.resource is configured (otherwise the
51+
// FrameworkBundle config validation fails with "The child config
52+
// 'resource' under 'framework.router' must be configured.").
53+
$loader->load(function (ContainerBuilder $container): void {
54+
$container->loadFromExtension('framework', [
55+
'router' => [
56+
'resource' => 'kernel::loadRoutes',
57+
'type' => 'service',
58+
],
59+
]);
60+
61+
if (!$container->hasDefinition('kernel')) {
62+
$container->register('kernel', static::class)
63+
->addTag('controller.service_arguments')
64+
->setAutoconfigured(true)
65+
->setSynthetic(true)
66+
->setPublic(true);
67+
}
68+
69+
$container->getDefinition('kernel')->addTag('routing.route_loader');
70+
});
71+
72+
// Load bundle-provided config files from <bundle>/Resources/config/pimcore
73+
// or <bundle>/config/pimcore (e.g. config.yaml -> messenger.yaml).
74+
// This mirrors Pimcore\Kernel::registerContainerConfiguration().
75+
$bundleConfigLocator = new BundleConfigLocator($this);
76+
foreach ($bundleConfigLocator->locate('config') as $bundleConfig) {
77+
$loader->load($bundleConfig);
78+
}
79+
80+
$configDir = $this->getProjectDir() . '/config';
3681

37-
$container->import($configDir . '/{packages}/*.{php,yaml}');
38-
$container->import($configDir . '/{packages}/' . $this->environment . '/*.{php,yaml}');
82+
// Load packages (mirrors MicroKernelTrait's default configureContainer behavior).
83+
$loader->load($configDir . '/packages/*.{php,yaml}', 'glob');
84+
$loader->load($configDir . '/packages/' . $this->environment . '/*.{php,yaml}', 'glob');
3985

4086
// Skip loading config/services.yaml — it is the bundle's own service config
4187
// and is already loaded by PimcoreGenericDataIndexExtension::load().
4288
// Only load the environment-specific services file (e.g., services_test.yaml).
43-
$container->import($configDir . '/{services}_' . $this->environment . '.yaml');
89+
$envServices = $configDir . '/services_' . $this->environment . '.yaml';
90+
if (file_exists($envServices)) {
91+
$loader->load($envServices);
92+
}
4493
}
4594
}

0 commit comments

Comments
 (0)