Skip to content

Commit b464629

Browse files
committed
updated configuration
1 parent 8966a9e commit b464629

File tree

19 files changed

+288
-274
lines changed

19 files changed

+288
-274
lines changed

guides/bundles/configuration.rst

Lines changed: 29 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -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
122122
.. code-block:: xml
123123
@@ -137,20 +137,20 @@ configuration file:
137137
.. code-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

147148
Parsing 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

155155
So, 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:
182182
.. code-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
The array passed to your method looks like the following::
191191

192192
array(
193-
'foo' => 'foo',
194-
'bar' => 'bar',
193+
array(
194+
'foo' => 'foo',
195+
'bar' => 'bar',
196+
)
195197
)
196198

197-
Within ``configLoad()``, the ``$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()``, the ``$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

246247
If you follow these simple conventions, your extensions will be registered
247248
automatically 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.

guides/cache/http.rst

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -644,7 +644,7 @@ route:
644644
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
645645
xsi:schemaLocation="http://www.symfony-project.org/schema/routing http://www.symfony-project.org/schema/routing/routing-1.0.xsd">
646646
647-
<import resource="FrameworkBundle/Resources/config/routing/internal.xml" prefix="/_internal" />
647+
<import resource="@FrameworkBundle/Resources/config/routing/internal.xml" prefix="/_internal" />
648648
</routes>
649649
650650
.. code-block:: php
@@ -653,7 +653,7 @@ route:
653653
use Symfony\Component\Routing\RouteCollection;
654654
use Symfony\Component\Routing\Route;
655655
656-
$collection->addCollection($loader->import('FrameworkBundle/Resources/config/routing/internal.xml', '/_internal'));
656+
$collection->addCollection($loader->import('@FrameworkBundle/Resources/config/routing/internal.xml', '/_internal'));
657657
658658
return $collection;
659659
@@ -694,7 +694,7 @@ To use ESI, be sure to enable it in your application configuration:
694694
.. code-block:: yaml
695695
696696
# app/config/config.yml
697-
app.config:
697+
framework:
698698
# ...
699699
esi:
700700
enabled: true
@@ -704,15 +704,15 @@ To use ESI, be sure to enable it in your application configuration:
704704
<!-- app/config/config.xml -->
705705
<?xml version="1.0" encoding="UTF-8" ?>
706706
707-
<app:config charset="UTF-8">
707+
<framework:config charset="UTF-8">
708708
<!-- ... -->
709-
<app:esi enabled="true" />
710-
</app:config>
709+
<framework:esi enabled="true" />
710+
</framework:config>
711711
712712
.. code-block:: php
713713
714714
// app/config/config.php
715-
$container->loadFromExtension('app', 'config', array(
715+
$container->loadFromExtension('framework', array(
716716
// ...
717717
'esi' => array(
718718
'enabled' => true,

guides/doctrine/dbal/configuration.rst

Lines changed: 57 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,12 @@ example:
1111
.. code-block:: yaml
1212
1313
# app/config/config.yml
14-
doctrine.dbal:
15-
driver: pdo_mysql
16-
dbname: Symfony2
17-
user: root
18-
password: null
14+
doctrine:
15+
dbal:
16+
driver: pdo_mysql
17+
dbname: Symfony2
18+
user: root
19+
password: null
1920
2021
The DoctrineBundle supports all parameters that all the default doctrine drivers
2122
accept, converted to the XML or YAML naming standards that Symfony enforces.
@@ -28,45 +29,48 @@ further:
2829

2930
.. code-block:: yaml
3031
31-
doctrine.dbal:
32-
dbname: database
33-
host: localhost
34-
port: 1234
35-
user: user
36-
password: secret
37-
driver: pdo_mysql
38-
driver_class: MyNamespace\MyDriverImpl
39-
options:
40-
foo: bar
41-
path: %kernel.data_dir%/data.sqlite
42-
memory: true
43-
unix_socket: /tmp/mysql.sock
44-
wrapper_class: MyDoctrineDbalConnectionWrapper
45-
charset: UTF-8
46-
logging: %kernel.debug%
47-
platform_service: MyOwnDatabasePlatformService
32+
doctrine:
33+
dbal:
34+
dbname: database
35+
host: localhost
36+
port: 1234
37+
user: user
38+
password: secret
39+
driver: pdo_mysql
40+
driver_class: MyNamespace\MyDriverImpl
41+
options:
42+
foo: bar
43+
path: %kernel.data_dir%/data.sqlite
44+
memory: true
45+
unix_socket: /tmp/mysql.sock
46+
wrapper_class: MyDoctrineDbalConnectionWrapper
47+
charset: UTF-8
48+
logging: %kernel.debug%
49+
platform_service: MyOwnDatabasePlatformService
4850
4951
.. code-block:: xml
5052
5153
<!-- xmlns:doctrine="http://www.symfony-project.org/schema/dic/doctrine" -->
5254
<!-- xsi:schemaLocation="http://www.symfony-project.org/schema/dic/doctrine http://www.symfony-project.org/schema/dic/doctrine/doctrine-1.0.xsd"> -->
5355
54-
<doctrine:dbal
55-
dbname="database"
56-
host="localhost"
57-
port="1234"
58-
user="user"
59-
password="secret"
60-
driver="pdo_mysql"
61-
driver-class="MyNamespace\MyDriverImpl"
62-
path="%kernel.data_dir%/data.sqlite"
63-
memory="true"
64-
unix-socket="/tmp/mysql.sock"
65-
wrapper-class="MyDoctrineDbalConnectionWrapper"
66-
charset="UTF-8"
67-
logging="%kernel.debug%"
68-
platform-service="MyOwnDatabasePlatformService"
69-
/>
56+
<doctrine:config>
57+
<doctrine:dbal
58+
dbname="database"
59+
host="localhost"
60+
port="1234"
61+
user="user"
62+
password="secret"
63+
driver="pdo_mysql"
64+
driver-class="MyNamespace\MyDriverImpl"
65+
path="%kernel.data_dir%/data.sqlite"
66+
memory="true"
67+
unix-socket="/tmp/mysql.sock"
68+
wrapper-class="MyDoctrineDbalConnectionWrapper"
69+
charset="UTF-8"
70+
logging="%kernel.debug%"
71+
platform-service="MyOwnDatabasePlatformService"
72+
/>
73+
</doctrine:config>
7074
7175
There are also a bunch of dependency injection container parameters
7276
that allow you to specify which classes are used (with their default values):
@@ -88,19 +92,20 @@ can also be specified in the connections subkeys.
8892

8993
.. code-block:: yaml
9094
91-
doctrine.dbal:
92-
default_connection: default
93-
connections:
94-
default:
95-
dbname: Symfony2
96-
user: root
97-
password: null
98-
host: localhost
99-
customer:
100-
dbname: customer
101-
user: root
102-
password: null
103-
host: localhost
95+
doctrine:
96+
dbal:
97+
default_connection: default
98+
connections:
99+
default:
100+
dbname: Symfony2
101+
user: root
102+
password: null
103+
host: localhost
104+
customer:
105+
dbname: customer
106+
user: root
107+
password: null
108+
host: localhost
104109
105110
If you have defined multiple connections you can use the
106111
``$this->get('doctrine.dbal.[connectionname]_connection)``
@@ -119,4 +124,4 @@ connection name that you want get::
119124
}
120125
}
121126

122-
.. _documentation: http://www.doctrine-project.org/projects/dbal/2.0/docs/en
127+
.. _documentation: http://www.doctrine-project.org/projects/dbal/2.0/docs/en

guides/doctrine/dbal/overview.rst

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,12 @@ To get started you just need to enable and configure the DBAL:
1919
2020
# app/config/config.yml
2121
22-
doctrine.dbal:
23-
driver: pdo_mysql
24-
dbname: Symfony2
25-
user: root
26-
password: null
22+
doctrine:
23+
dbal:
24+
driver: pdo_mysql
25+
dbname: Symfony2
26+
user: root
27+
password: null
2728
2829
You can then access the Doctrine DBAL connection by accessing the
2930
``database_connection`` service::

0 commit comments

Comments
 (0)