[FrameworkBundle] Added flex-compatible default implementations for MicroKernelTrait::registerBundles()
and getProjectDir()
This commit is contained in:
parent
65a988880d
commit
a689807387
@ -7,6 +7,7 @@ CHANGELOG
|
||||
* Marked `MicroKernelTrait::configureRoutes()` as `@internal` and `@final`.
|
||||
* Deprecated not overriding `MicroKernelTrait::configureRouting()`.
|
||||
* Added a new `mailer.message_bus` option to configure or disable the message bus to use to send mails.
|
||||
* Added flex-compatible default implementations for `MicroKernelTrait::registerBundles()` and `getProjectDir()`
|
||||
|
||||
5.0.0
|
||||
-----
|
||||
|
@ -72,6 +72,27 @@ trait MicroKernelTrait
|
||||
*/
|
||||
abstract protected function configureContainer(ContainerBuilder $c, LoaderInterface $loader);
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getProjectDir(): string
|
||||
{
|
||||
return \dirname((new \ReflectionObject($this))->getFileName(), 2);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function registerBundles(): iterable
|
||||
{
|
||||
$contents = require $this->getProjectDir().'/config/bundles.php';
|
||||
foreach ($contents as $class => $envs) {
|
||||
if ($envs[$this->environment] ?? $envs['all'] ?? false) {
|
||||
yield new $class();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
@ -100,8 +121,8 @@ trait MicroKernelTrait
|
||||
}
|
||||
|
||||
$this->configureContainer($container, $loader);
|
||||
|
||||
$container->addObjectResource($this);
|
||||
$container->fileExists($this->getProjectDir().'/config/bundles.php');
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -151,8 +151,8 @@ class PhpDumper extends Dumper
|
||||
$this->namespace = $options['namespace'];
|
||||
$this->asFiles = $options['as_files'];
|
||||
$this->hotPathTag = $options['hot_path_tag'];
|
||||
$this->inlineFactories = $this->asFiles && $options['inline_factories_parameter'] && $this->container->hasParameter($options['inline_factories_parameter']) && $this->container->getParameter($options['inline_factories_parameter']);
|
||||
$this->inlineRequires = $options['inline_class_loader_parameter'] && $this->container->hasParameter($options['inline_class_loader_parameter']) && $this->container->getParameter($options['inline_class_loader_parameter']);
|
||||
$this->inlineFactories = $this->asFiles && $options['inline_factories_parameter'] && (!$this->container->hasParameter($options['inline_factories_parameter']) || $this->container->getParameter($options['inline_factories_parameter']));
|
||||
$this->inlineRequires = $options['inline_class_loader_parameter'] && ($this->container->hasParameter($options['inline_class_loader_parameter']) ? $this->container->getParameter($options['inline_class_loader_parameter']) : \PHP_VERSION_ID < 70400);
|
||||
$this->serviceLocatorTag = $options['service_locator_tag'];
|
||||
|
||||
if (0 !== strpos($baseClass = $options['base_class'], '\\') && 'Container' !== $baseClass) {
|
||||
|
@ -227,7 +227,7 @@ class PhpDumperTest extends TestCase
|
||||
->addError('No-no-no-no');
|
||||
$container->compile();
|
||||
$dumper = new PhpDumper($container);
|
||||
$dump = print_r($dumper->dump(['as_files' => true, 'file' => __DIR__, 'hot_path_tag' => 'hot']), true);
|
||||
$dump = print_r($dumper->dump(['as_files' => true, 'file' => __DIR__, 'hot_path_tag' => 'hot', 'inline_factories_parameter' => false, 'inline_class_loader_parameter' => false]), true);
|
||||
if ('\\' === \DIRECTORY_SEPARATOR) {
|
||||
$dump = str_replace('\\\\Fixtures\\\\includes\\\\foo.php', '/Fixtures/includes/foo.php', $dump);
|
||||
}
|
||||
@ -297,7 +297,7 @@ class PhpDumperTest extends TestCase
|
||||
->setLazy(true);
|
||||
$container->compile();
|
||||
$dumper = new PhpDumper($container);
|
||||
$dump = print_r($dumper->dump(['as_files' => true, 'file' => __DIR__]), true);
|
||||
$dump = print_r($dumper->dump(['as_files' => true, 'file' => __DIR__, 'inline_factories_parameter' => false, 'inline_class_loader_parameter' => false]), true);
|
||||
|
||||
if ('\\' === \DIRECTORY_SEPARATOR) {
|
||||
$dump = str_replace('\\\\Fixtures\\\\includes\\\\foo_lazy.php', '/Fixtures/includes/foo_lazy.php', $dump);
|
||||
@ -478,7 +478,7 @@ class PhpDumperTest extends TestCase
|
||||
$container->compile();
|
||||
$dumper = new PhpDumper($container);
|
||||
|
||||
$this->assertStringEqualsFile(self::$fixturesPath.'/php/services26.php', $dumper->dump(['class' => 'Symfony_DI_PhpDumper_Test_EnvParameters', 'file' => self::$fixturesPath.'/php/services26.php']));
|
||||
$this->assertStringEqualsFile(self::$fixturesPath.'/php/services26.php', $dumper->dump(['class' => 'Symfony_DI_PhpDumper_Test_EnvParameters', 'file' => self::$fixturesPath.'/php/services26.php', 'inline_factories_parameter' => false, 'inline_class_loader_parameter' => false]));
|
||||
|
||||
require self::$fixturesPath.'/php/services26.php';
|
||||
$container = new \Symfony_DI_PhpDumper_Test_EnvParameters();
|
||||
@ -944,7 +944,7 @@ class PhpDumperTest extends TestCase
|
||||
|
||||
$dumper = new PhpDumper($container);
|
||||
|
||||
$this->assertStringEqualsFile(self::$fixturesPath.'/php/services_array_params.php', str_replace('\\\\Dumper', '/Dumper', $dumper->dump(['file' => self::$fixturesPath.'/php/services_array_params.php'])));
|
||||
$this->assertStringEqualsFile(self::$fixturesPath.'/php/services_array_params.php', str_replace('\\\\Dumper', '/Dumper', $dumper->dump(['file' => self::$fixturesPath.'/php/services_array_params.php', 'inline_factories_parameter' => false, 'inline_class_loader_parameter' => false])));
|
||||
}
|
||||
|
||||
public function testExpressionReferencingPrivateService()
|
||||
|
Reference in New Issue
Block a user