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 26d021c

Browse filesBrowse files
Use "$container" consistently
1 parent 3f95ef1 commit 26d021c
Copy full SHA for 26d021c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Dismiss banner
Expand file treeCollapse file tree

56 files changed

+375
-375
lines changed

‎.doctor-rst.yaml

Copy file name to clipboardExpand all lines: .doctor-rst.yaml
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ rules:
22
american_english: ~
33
argument_variable_must_match_type:
44
arguments:
5-
- { type: 'ContainerBuilder', name: 'containerBuilder' }
6-
- { type: 'ContainerConfigurator', name: 'containerConfigurator' }
5+
- { type: 'ContainerBuilder', name: 'container' }
6+
- { type: 'ContainerConfigurator', name: 'container' }
77
avoid_repetetive_words: ~
88
blank_line_after_anchor: ~
99
blank_line_after_directive: ~

‎bundles/best_practices.rst

Copy file name to clipboardExpand all lines: bundles/best_practices.rst
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -442,8 +442,8 @@ The end user can provide values in any configuration file:
442442
// config/services.php
443443
namespace Symfony\Component\DependencyInjection\Loader\Configurator;
444444
445-
return static function (ContainerConfigurator $containerConfigurator) {
446-
$containerConfigurator->parameters()
445+
return static function (ContainerConfigurator $container) {
446+
$container->parameters()
447447
->set('acme_blog.author.email', 'fabien@example.com')
448448
;
449449
};

‎bundles/configuration.rst

Copy file name to clipboardExpand all lines: bundles/configuration.rst
+6-6Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ force validation (e.g. if an additional option was passed, an exception will be
217217
thrown)::
218218

219219
// src/Acme/SocialBundle/DependencyInjection/AcmeSocialExtension.php
220-
public function load(array $configs, ContainerBuilder $containerBuilder)
220+
public function load(array $configs, ContainerBuilder $container)
221221
{
222222
$configuration = new Configuration();
223223

@@ -259,15 +259,15 @@ In your extension, you can load this and dynamically set its arguments::
259259
use Symfony\Component\Config\FileLocator;
260260
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
261261

262-
public function load(array $configs, ContainerBuilder $containerBuilder)
262+
public function load(array $configs, ContainerBuilder $container)
263263
{
264-
$loader = new XmlFileLoader($containerBuilder, new FileLocator(dirname(__DIR__).'/Resources/config'));
264+
$loader = new XmlFileLoader($container, new FileLocator(dirname(__DIR__).'/Resources/config'));
265265
$loader->load('services.xml');
266266

267267
$configuration = new Configuration();
268268
$config = $this->processConfiguration($configuration, $configs);
269269

270-
$definition = $containerBuilder->getDefinition('acme.social.twitter_client');
270+
$definition = $container->getDefinition('acme.social.twitter_client');
271271
$definition->replaceArgument(0, $config['twitter']['client_id']);
272272
$definition->replaceArgument(1, $config['twitter']['client_secret']);
273273
}
@@ -288,7 +288,7 @@ In your extension, you can load this and dynamically set its arguments::
288288
class AcmeHelloExtension extends ConfigurableExtension
289289
{
290290
// note that this method is called loadInternal and not load
291-
protected function loadInternal(array $mergedConfig, ContainerBuilder $containerBuilder)
291+
protected function loadInternal(array $mergedConfig, ContainerBuilder $container)
292292
{
293293
// ...
294294
}
@@ -304,7 +304,7 @@ In your extension, you can load this and dynamically set its arguments::
304304
(e.g. by overriding configurations and using :phpfunction:`isset` to check
305305
for the existence of a value). Be aware that it'll be very hard to support XML::
306306

307-
public function load(array $configs, ContainerBuilder $containerBuilder)
307+
public function load(array $configs, ContainerBuilder $container)
308308
{
309309
$config = [];
310310
// let resources override the previous set value

‎bundles/extension.rst

Copy file name to clipboardExpand all lines: bundles/extension.rst
+4-4Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ This is how the extension of an AcmeHelloBundle should look like::
3434

3535
class AcmeHelloExtension extends Extension
3636
{
37-
public function load(array $configs, ContainerBuilder $containerBuilder)
37+
public function load(array $configs, ContainerBuilder $container)
3838
{
3939
// ... you'll load the files here later
4040
}
@@ -89,10 +89,10 @@ For instance, assume you have a file called ``services.xml`` in the
8989
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
9090

9191
// ...
92-
public function load(array $configs, ContainerBuilder $containerBuilder)
92+
public function load(array $configs, ContainerBuilder $container)
9393
{
9494
$loader = new XmlFileLoader(
95-
$containerBuilder,
95+
$container,
9696
new FileLocator(__DIR__.'/../Resources/config')
9797
);
9898
$loader->load('services.xml');
@@ -115,7 +115,7 @@ they are compiled when generating the application cache to improve the overall
115115
performance. Define the list of annotated classes to compile in the
116116
``addAnnotatedClassesToCompile()`` method::
117117

118-
public function load(array $configs, ContainerBuilder $containerBuilder)
118+
public function load(array $configs, ContainerBuilder $container)
119119
{
120120
// ...
121121

‎bundles/prepend_extension.rst

Copy file name to clipboardExpand all lines: bundles/prepend_extension.rst
+10-10Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ To give an Extension the power to do this, it needs to implement
3131
{
3232
// ...
3333

34-
public function prepend(ContainerBuilder $containerBuilder)
34+
public function prepend(ContainerBuilder $container)
3535
{
3636
// ...
3737
}
@@ -52,15 +52,15 @@ a configuration setting in multiple bundles as well as disable a flag in multipl
5252
in case a specific other bundle is not registered::
5353

5454
// src/Acme/HelloBundle/DependencyInjection/AcmeHelloExtension.php
55-
public function prepend(ContainerBuilder $containerBuilder)
55+
public function prepend(ContainerBuilder $container)
5656
{
5757
// get all bundles
58-
$bundles = $containerBuilder->getParameter('kernel.bundles');
58+
$bundles = $container->getParameter('kernel.bundles');
5959
// determine if AcmeGoodbyeBundle is registered
6060
if (!isset($bundles['AcmeGoodbyeBundle'])) {
6161
// disable AcmeGoodbyeBundle in bundles
6262
$config = ['use_acme_goodbye' => false];
63-
foreach ($containerBuilder->getExtensions() as $name => $extension) {
63+
foreach ($container->getExtensions() as $name => $extension) {
6464
switch ($name) {
6565
case 'acme_something':
6666
case 'acme_other':
@@ -70,21 +70,21 @@ in case a specific other bundle is not registered::
7070
// note that if the user manually configured
7171
// use_acme_goodbye to true in config/services.yaml
7272
// then the setting would in the end be true and not false
73-
$containerBuilder->prependExtensionConfig($name, $config);
73+
$container->prependExtensionConfig($name, $config);
7474
break;
7575
}
7676
}
7777
}
7878

7979
// get the configuration of AcmeHelloExtension (it's a list of configuration)
80-
$configs = $containerBuilder->getExtensionConfig($this->getAlias());
80+
$configs = $container->getExtensionConfig($this->getAlias());
8181

8282
// iterate in reverse to preserve the original order after prepending the config
8383
foreach (array_reverse($configs) as $config) {
8484
// check if entity_manager_name is set in the "acme_hello" configuration
8585
if (isset($config['entity_manager_name'])) {
8686
// prepend the acme_something settings with the entity_manager_name
87-
$containerBuilder->prependExtensionConfig('acme_something', [
87+
$container->prependExtensionConfig('acme_something', [
8888
'entity_manager_name' => $config['entity_manager_name'],
8989
]);
9090
}
@@ -141,13 +141,13 @@ registered and the ``entity_manager_name`` setting for ``acme_hello`` is set to
141141
// config/packages/acme_something.php
142142
namespace Symfony\Component\DependencyInjection\Loader\Configurator;
143143
144-
return static function (ContainerConfigurator $containerConfigurator) {
145-
$containerConfigurator->extension('acme_something', [
144+
return static function (ContainerConfigurator $container) {
145+
$container->extension('acme_something', [
146146
// ...
147147
'use_acme_goodbye' => false,
148148
'entity_manager_name' => 'non_default',
149149
]);
150-
$containerConfigurator->extension('acme_other', [
150+
$container->extension('acme_other', [
151151
// ...
152152
'use_acme_goodbye' => false,
153153
]);

‎cache.rst

Copy file name to clipboardExpand all lines: cache.rst
+4-4Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -384,8 +384,8 @@ with either :class:`Symfony\\Contracts\\Cache\\CacheInterface` or
384384
// config/services.php
385385
namespace Symfony\Component\DependencyInjection\Loader\Configurator;
386386
387-
return function(ContainerConfigurator $containerConfigurator) {
388-
$containerConfigurator->services()
387+
return function(ContainerConfigurator $container) {
388+
$container->services()
389389
// ...
390390
391391
->set('app.cache.adapter.redis')
@@ -465,14 +465,14 @@ and use that when configuring the pool.
465465
use Symfony\Component\DependencyInjection\ContainerBuilder;
466466
use Symfony\Config\FrameworkConfig;
467467
468-
return static function (ContainerBuilder $containerBuilder, FrameworkConfig $framework) {
468+
return static function (ContainerBuilder $container, FrameworkConfig $framework) {
469469
$framework->cache()
470470
->pool('cache.my_redis')
471471
->adapters(['cache.adapter.redis'])
472472
->provider('app.my_custom_redis_provider');
473473
474474
475-
$containerBuilder->register('app.my_custom_redis_provider', \Redis::class)
475+
$container->register('app.my_custom_redis_provider', \Redis::class)
476476
->setFactory([RedisAdapter::class, 'createConnection'])
477477
->addArgument('redis://localhost')
478478
->addArgument([

‎components/dependency_injection.rst

Copy file name to clipboardExpand all lines: components/dependency_injection.rst
+26-26Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ You can register this in the container as a service::
4545

4646
use Symfony\Component\DependencyInjection\ContainerBuilder;
4747

48-
$containerBuilder = new ContainerBuilder();
49-
$containerBuilder->register('mailer', 'Mailer');
48+
$container = new ContainerBuilder();
49+
$container->register('mailer', 'Mailer');
5050

5151
An improvement to the class to make it more flexible would be to allow
5252
the container to set the ``transport`` used. If you change the class
@@ -68,8 +68,8 @@ Then you can set the choice of transport in the container::
6868

6969
use Symfony\Component\DependencyInjection\ContainerBuilder;
7070

71-
$containerBuilder = new ContainerBuilder();
72-
$containerBuilder
71+
$container = new ContainerBuilder();
72+
$container
7373
->register('mailer', 'Mailer')
7474
->addArgument('sendmail');
7575

@@ -83,9 +83,9 @@ the ``Mailer`` service's constructor argument::
8383

8484
use Symfony\Component\DependencyInjection\ContainerBuilder;
8585

86-
$containerBuilder = new ContainerBuilder();
87-
$containerBuilder->setParameter('mailer.transport', 'sendmail');
88-
$containerBuilder
86+
$container = new ContainerBuilder();
87+
$container->setParameter('mailer.transport', 'sendmail');
88+
$container
8989
->register('mailer', 'Mailer')
9090
->addArgument('%mailer.transport%');
9191

@@ -112,14 +112,14 @@ not exist yet. Use the ``Reference`` class to tell the container to inject the
112112
use Symfony\Component\DependencyInjection\ContainerBuilder;
113113
use Symfony\Component\DependencyInjection\Reference;
114114

115-
$containerBuilder = new ContainerBuilder();
115+
$container = new ContainerBuilder();
116116

117-
$containerBuilder->setParameter('mailer.transport', 'sendmail');
118-
$containerBuilder
117+
$container->setParameter('mailer.transport', 'sendmail');
118+
$container
119119
->register('mailer', 'Mailer')
120120
->addArgument('%mailer.transport%');
121121

122-
$containerBuilder
122+
$container
123123
->register('newsletter_manager', 'NewsletterManager')
124124
->addArgument(new Reference('mailer'));
125125

@@ -144,14 +144,14 @@ If you do want to though then the container can call the setter method::
144144
use Symfony\Component\DependencyInjection\ContainerBuilder;
145145
use Symfony\Component\DependencyInjection\Reference;
146146

147-
$containerBuilder = new ContainerBuilder();
147+
$container = new ContainerBuilder();
148148

149-
$containerBuilder->setParameter('mailer.transport', 'sendmail');
150-
$containerBuilder
149+
$container->setParameter('mailer.transport', 'sendmail');
150+
$container
151151
->register('mailer', 'Mailer')
152152
->addArgument('%mailer.transport%');
153153

154-
$containerBuilder
154+
$container
155155
->register('newsletter_manager', 'NewsletterManager')
156156
->addMethodCall('setMailer', [new Reference('mailer')]);
157157

@@ -160,11 +160,11 @@ like this::
160160

161161
use Symfony\Component\DependencyInjection\ContainerBuilder;
162162

163-
$containerBuilder = new ContainerBuilder();
163+
$container = new ContainerBuilder();
164164

165165
// ...
166166

167-
$newsletterManager = $containerBuilder->get('newsletter_manager');
167+
$newsletterManager = $container->get('newsletter_manager');
168168

169169
Avoiding your Code Becoming Dependent on the Container
170170
------------------------------------------------------
@@ -198,8 +198,8 @@ Loading an XML config file::
198198
use Symfony\Component\DependencyInjection\ContainerBuilder;
199199
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
200200

201-
$containerBuilder = new ContainerBuilder();
202-
$loader = new XmlFileLoader($containerBuilder, new FileLocator(__DIR__));
201+
$container = new ContainerBuilder();
202+
$loader = new XmlFileLoader($container, new FileLocator(__DIR__));
203203
$loader->load('services.xml');
204204

205205
Loading a YAML config file::
@@ -208,8 +208,8 @@ Loading a YAML config file::
208208
use Symfony\Component\DependencyInjection\ContainerBuilder;
209209
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
210210

211-
$containerBuilder = new ContainerBuilder();
212-
$loader = new YamlFileLoader($containerBuilder, new FileLocator(__DIR__));
211+
$container = new ContainerBuilder();
212+
$loader = new YamlFileLoader($container, new FileLocator(__DIR__));
213213
$loader->load('services.yaml');
214214

215215
.. note::
@@ -233,8 +233,8 @@ into a separate config file and load it in a similar way::
233233
use Symfony\Component\DependencyInjection\ContainerBuilder;
234234
use Symfony\Component\DependencyInjection\Loader\PhpFileLoader;
235235

236-
$containerBuilder = new ContainerBuilder();
237-
$loader = new PhpFileLoader($containerBuilder, new FileLocator(__DIR__));
236+
$container = new ContainerBuilder();
237+
$loader = new PhpFileLoader($container, new FileLocator(__DIR__));
238238
$loader->load('services.php');
239239

240240
You can now set up the ``newsletter_manager`` and ``mailer`` services using
@@ -287,13 +287,13 @@ config files:
287287
288288
namespace Symfony\Component\DependencyInjection\Loader\Configurator;
289289
290-
return static function (ContainerConfigurator $containerConfigurator) {
291-
$containerConfigurator->parameters()
290+
return static function (ContainerConfigurator $container) {
291+
$container->parameters()
292292
// ...
293293
->set('mailer.transport', 'sendmail')
294294
;
295295
296-
$services = $containerConfigurator->services();
296+
$services = $container->services();
297297
$services->set('mailer', 'Mailer')
298298
->args(['%mailer.transport%'])
299299
;

‎components/dependency_injection/_imports-parameters-note.rst.inc

Copy file name to clipboardExpand all lines: components/dependency_injection/_imports-parameters-note.rst.inc
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,6 @@
3131
// config/services.php
3232
namespace Symfony\Component\DependencyInjection\Loader\Configurator;
3333

34-
return static function (ContainerConfigurator $containerConfigurator) {
35-
$containerConfigurator->import('%kernel.project_dir%/somefile.yaml');
34+
return static function (ContainerConfigurator $container) {
35+
$container->import('%kernel.project_dir%/somefile.yaml');
3636
};

0 commit comments

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