Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 99c5694

Browse filesBrowse files
[DependencyInjection] Add ContainerBuilder::isInstalled() to help with conditional configuration
1 parent 386555b commit 99c5694
Copy full SHA for 99c5694

File tree

21 files changed

+148
-117
lines changed
Filter options

21 files changed

+148
-117
lines changed

‎src/Symfony/Bridge/Doctrine/DependencyInjection/CompilerPass/RegisterUidTypePass.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Doctrine/DependencyInjection/CompilerPass/RegisterUidTypePass.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ final class RegisterUidTypePass implements CompilerPassInterface
2424
*/
2525
public function process(ContainerBuilder $container)
2626
{
27-
if (!class_exists(AbstractUid::class)) {
27+
if (!$container->isInstalled('symfony/uid', AbstractUid::class)) {
2828
return;
2929
}
3030

‎src/Symfony/Bridge/Twig/Extension/TranslationExtension.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Twig/Extension/TranslationExtension.php
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public function __construct(TranslatorInterface $translator = null, TranslationN
4646
public function getTranslator(): TranslatorInterface
4747
{
4848
if (null === $this->translator) {
49-
if (!interface_exists(TranslatorInterface::class)) {
49+
if (!$container->isInstalled('symfony/translation', TranslatorInterface::class)) {
5050
throw new \LogicException(sprintf('You cannot use the "%s" if the Translation Contracts are not available. Try running "composer require symfony/translation".', __CLASS__));
5151
}
5252

@@ -136,7 +136,7 @@ public function trans($message, $arguments = [], string $domain = null, string $
136136

137137
public function createTranslatable(string $message, array $parameters = [], string $domain = null): TranslatableMessage
138138
{
139-
if (!class_exists(TranslatableMessage::class)) {
139+
if (!$container->isInstalled('symfony/translation', TranslatableMessage::class)) {
140140
throw new \LogicException(sprintf('You cannot use the "%s" as the Translation Component is not installed. Try running "composer require symfony/translation".', __CLASS__));
141141
}
142142

‎src/Symfony/Bridge/Twig/composer.json

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Twig/composer.json
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"egulias/email-validator": "^2.1.10",
2626
"phpdocumentor/reflection-docblock": "^3.0|^4.0|^5.0",
2727
"symfony/asset": "^4.4|^5.0",
28-
"symfony/dependency-injection": "^4.4|^5.0",
28+
"symfony/dependency-injection": "^5.3",
2929
"symfony/finder": "^4.4|^5.0",
3030
"symfony/form": "^5.3",
3131
"symfony/http-foundation": "^4.4|^5.0",
@@ -54,6 +54,7 @@
5454
"phpdocumentor/reflection-docblock": "<3.2.2",
5555
"phpdocumentor/type-resolver": "<1.4.0",
5656
"symfony/console": "<4.4",
57+
"symfony/dependency-injection": "<5.3",
5758
"symfony/form": "<5.3",
5859
"symfony/http-foundation": "<4.4",
5960
"symfony/http-kernel": "<4.4",

‎src/Symfony/Bundle/DebugBundle/DependencyInjection/Configuration.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/DebugBundle/DependencyInjection/Configuration.php
+6-14Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313

1414
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
1515
use Symfony\Component\Config\Definition\ConfigurationInterface;
16-
use Symfony\Component\VarDumper\Dumper\HtmlDumper;
1716

1817
/**
1918
* DebugExtension configuration structure.
@@ -51,22 +50,15 @@ public function getConfigTreeBuilder()
5150
->example('php://stderr, or tcp://%env(VAR_DUMPER_SERVER)% when using the "server:dump" command')
5251
->defaultNull()
5352
->end()
53+
->enumNode('theme')
54+
->info('Changes the color of the dump() output when rendered directly on the templating. "dark" (default) or "light"')
55+
->example('dark')
56+
->values(['dark', 'light'])
57+
->defaultValue('dark')
58+
->end()
5459
->end()
5560
;
5661

57-
if (method_exists(HtmlDumper::class, 'setTheme')) {
58-
$rootNode
59-
->children()
60-
->enumNode('theme')
61-
->info('Changes the color of the dump() output when rendered directly on the templating. "dark" (default) or "light"')
62-
->example('dark')
63-
->values(['dark', 'light'])
64-
->defaultValue('dark')
65-
->end()
66-
->end()
67-
;
68-
}
69-
7062
return $treeBuilder;
7163
}
7264
}

‎src/Symfony/Bundle/DebugBundle/DependencyInjection/DebugExtension.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/DebugBundle/DependencyInjection/DebugExtension.php
+4-4Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,12 @@ public function load(array $configs, ContainerBuilder $container)
4545
->addMethodCall('setMinDepth', [$config['min_depth']])
4646
->addMethodCall('setMaxString', [$config['max_string_length']]);
4747

48-
if (method_exists(ReflectionCaster::class, 'unsetClosureFileInfo')) {
48+
if ($container->isInstalled('symfony/var-dumper', ReflectionCaster::class, 'unsetClosureFileInfo')) {
4949
$container->getDefinition('var_dumper.cloner')
5050
->addMethodCall('addCasters', [ReflectionCaster::UNSET_CLOSURE_FILE_INFO]);
5151
}
5252

53-
if (method_exists(HtmlDumper::class, 'setTheme') && 'dark' !== $config['theme']) {
53+
if ($container->isInstalled('symfony/var-dumper', HtmlDumper::class, 'setTheme') && 'dark' !== $config['theme']) {
5454
$container->getDefinition('var_dumper.html_dumper')
5555
->addMethodCall('setTheme', [$config['theme']]);
5656
}
@@ -84,15 +84,15 @@ public function load(array $configs, ContainerBuilder $container)
8484
;
8585
}
8686

87-
if (method_exists(CliDumper::class, 'setDisplayOptions')) {
87+
if ($container->isInstalled('symfony/var-dumper', CliDumper::class, 'setDisplayOptions')) {
8888
$container->getDefinition('var_dumper.cli_dumper')
8989
->addMethodCall('setDisplayOptions', [[
9090
'fileLinkFormat' => new Reference('debug.file_link_formatter', ContainerBuilder::IGNORE_ON_INVALID_REFERENCE),
9191
]])
9292
;
9393
}
9494

95-
if (!class_exists(ServerLogCommand::class)) {
95+
if (!$container->isInstalled('symfony/monolog-bridge', ServerLogCommand::class)) {
9696
$container->removeDefinition('monolog.command.server_log');
9797
}
9898
}

‎src/Symfony/Bundle/DebugBundle/Resources/config/services.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/DebugBundle/Resources/config/services.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@
134134
->set('monolog.command.server_log', ServerLogCommand::class)
135135
;
136136

137-
if (class_exists(ConsoleFormatter::class) && interface_exists(FormatterInterface::class)) {
137+
if ($container->isInstalled('symfony/monolog-bridge', ConsoleFormatter::class) && $container->isInstalled('monolog/monolog', FormatterInterface::class)) {
138138
$container->services()->get('monolog.command.server_log')->tag('console.command');
139139
}
140140
};

‎src/Symfony/Bundle/DebugBundle/composer.json

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/DebugBundle/composer.json
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@
2424
},
2525
"require-dev": {
2626
"symfony/config": "^4.4|^5.0",
27-
"symfony/dependency-injection": "^4.4|^5.0",
27+
"symfony/dependency-injection": "^5.3",
2828
"symfony/web-profiler-bundle": "^4.4|^5.0"
2929
},
3030
"conflict": {
3131
"symfony/config": "<4.4",
32-
"symfony/dependency-injection": "<5.2"
32+
"symfony/dependency-injection": "<5.3"
3333
},
3434
"suggest": {
3535
"symfony/config": "For service container configuration",

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.