@@ -88,7 +88,7 @@ that extends
8888
8989 class HelloExtension extends Extension 
9090 { 
91-  public function configLoad($config , ContainerBuilder $container) 
91+  public function load(array $configs , ContainerBuilder $container) 
9292 { 
9393 // ... 
9494 } 
@@ -109,15 +109,15 @@ that extends
109109 } 
110110 } 
111111
112- The previous class defines a ``hello:config  `` namespace, usable in any
113- configuration  file:
112+ The previous class defines a ``hello `` namespace, usable in any configuration 
113+ file:
114114
115115.. configuration-block ::
116116
117117 .. code-block :: yaml 
118118
119119 #  app/config/config.yml 
120-  hello.config  : ~  
120+  hello : ~  
121121
122122code-block :: xml 
123123
@@ -137,20 +137,20 @@ configuration file:
137137code-block :: php 
138138
139139 // app/config/config.php 
140-  $container->loadFromExtension('hello', 'config',  array()); 
140+  $container->loadFromExtension('hello', array()); 
141141
142- note ::
142+ tip ::
143143
144-  You can create as many ``xxxLoad() `` methods as you want to define more
145-  configuration blocks for your extension.
144+  Your extension code is always called, even if the user does not provide
145+  any configuration. In that case, the array of configurations will be empty
146+  and you can still provide some sensible defaults if you want.
146147
147148Parsing a Configuration
148149~~~~~~~~~~~~~~~~~~~~~~~ 
149150
150- Whenever a user includes the ``hello.config `` namespace in a configuration
151- file, the ``configLoad() `` method of your extension is called and the
152- configuration is passed as an array (Symfony2 automatically converts XML and
153- YAML to an array).
151+ Whenever a user includes the ``hello `` namespace in a configuration file, it
152+ is added to an array of configurations and passed to the ``load() `` method of
153+ your extension (Symfony2 automatically converts XML and YAML to an array).
154154
155155So, given the following configuration:
156156
@@ -159,7 +159,7 @@ So, given the following configuration:
159159 .. code-block :: yaml 
160160
161161 #  app/config/config.yml 
162-  hello.config  : 
162+  hello : 
163163 foo : foo  
164164 bar : bar  
165165
@@ -182,24 +182,26 @@ So, given the following configuration:
182182code-block :: php 
183183
184184 // app/config/config.php 
185-  $container->loadFromExtension('hello', 'config',  array( 
185+  $container->loadFromExtension('hello', array( 
186186 'foo' => 'foo', 
187187 'bar' => 'bar', 
188188 )); 
189189
190190
191191
192192 array( 
193-  'foo' => 'foo', 
194-  'bar' => 'bar', 
193+  array( 
194+  'foo' => 'foo', 
195+  'bar' => 'bar', 
196+  ) 
195197 ) 
196198
197- Within ``configLoad ()$container `` variable refers to a container
198- that only  knows about this namespace configuration. You can manipulate it the
199- way you  want to add services and parameters. The first time the method is
200- called, the  container only knows about global parameters. For subsequent
201- calls, it  contains the configuration as defined by previous calls. So, the
202- method needs  to merge new configuration settings with old ones::
199+ Within ``load ()$container `` variable refers to a container that only 
200+ knows about this namespace configuration. You can manipulate it the way you 
201+ want to add services and parameters. The first time the method is called, the 
202+ container only knows about global parameters. For subsequent calls, it 
203+ contains the configuration as defined by previous calls. So, the method needs 
204+ to merge new configuration settings with old ones::
203205
204206 // only load default services and parameters once 
205207 if (!$container->hasDefinition('xxxxx')) { 
@@ -235,21 +237,20 @@ When creating an extension, follow these simple conventions:
235237* The extension must be stored in the ``DependencyInjection `` sub-namespace;
236238
237239* The extension must be named after the bundle name and suffixed with
238-  ``Extension `` (``HelloExtension `` for ``HelloBundle ``) -- when you provide
239-  several extensions for a single bundle, just end them with ``Extension ``;
240+  ``Extension `` (``SensioHelloExtension `` for ``SensioHelloBundle ``);
240241
241- * The alias must be unique and named after the bundle name (``hello `` for 
242-  `` HelloBundle `` or `` sensio.social.blog ``  for ``Sensio\Social\BlogBundle ``);
242+ * The alias must be unique and named after the bundle name (``sensio_blog `` 
243+  for ``SensioBlogBundle ``);
243244
244245* The extension should provide an XSD schema.
245246
246247If you follow these simple conventions, your extensions will be registered
247248automatically by Symfony2. If not, override the Bundle
248- :method: `Symfony\\ Component\\ HttpKernel\\ Bundle\\ Bundle::registerExtensions  ` method::
249+ :method: `Symfony\\ Component\\ HttpKernel\\ Bundle\\ Bundle::build  ` method::
249250
250251 class HelloBundle extends Bundle 
251252 { 
252-  public function registerExtensions (ContainerBuilder $container) 
253+  public function build (ContainerBuilder $container) 
253254 { 
254255 // register the extension(s) found in DependencyInjection/ directory 
255256 parent::registerExtensions($container); 
@@ -261,29 +262,3 @@ automatically by Symfony2. If not, override the Bundle
261262
262263.. index ::
263264 single: Bundles; Default Configuration
264- 
265- Default Configuration
266- ~~~~~~~~~~~~~~~~~~~~~ 
267- 
268- As stated before, the user of the bundle should include the ``hello.config ``
269- namespace in a configuration file for your extension code to be called. But you
270- can automatically register a default configuration by overriding the Bundle
271- :method: `Symfony\\ Component\\ HttpKernel\\ Bundle\\ Bundle::registerExtensions `
272- method::
273- 
274-  class HelloBundle extends Bundle 
275-  { 
276-  public function registerExtensions(ContainerBuilder $container) 
277-  { 
278-  // will register the HelloBundle extension(s) found in DependencyInjection/ directory 
279-  parent::registerExtensions($container); 
280- 
281-  // load some defaults 
282-  $container->loadFromExtension('hello', 'config', array(/* your default config for the hello.config namespace */)); 
283-  } 
284-  } 
285- 
286- .. caution ::
287- 
288-  Symfony2 tries to be as explicit as possible. So, registering a default
289-  configuration automatically is probably not a good idea.
0 commit comments