Skip to content

Commit 202d861

Browse files
committed
Added missing formats
1 parent bdebbdf commit 202d861

File tree

1 file changed

+61
-11
lines changed

1 file changed

+61
-11
lines changed

cookbook/symfony1.rst

Lines changed: 61 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -267,23 +267,61 @@ configuration inside a bundle must be included manually. For example, to
267267
include a routing resource from a bundle called ``AcmeDemoBundle``, you can
268268
do the following:
269269

270-
.. code-block:: yaml
270+
.. configuration-block::
271+
272+
.. code-block:: yaml
273+
274+
# app/config/routing.yml
275+
_hello:
276+
resource: "@AcmeDemoBundle/Resources/config/routing.yml"
277+
278+
.. code-block:: xml
279+
280+
<!-- app/config/routing.yml -->
281+
<?xml version="1.0" encoding="UTF-8" ?>
282+
283+
<routes xmlns="http://symfony.com/schema/routing"
284+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
285+
xsi:schemaLocation="http://symfony.com/schema/routing http://symfony.com/schema/routing/routing-1.0.xsd">
271286
272-
# app/config/routing.yml
273-
_hello:
274-
resource: "@AcmeDemoBundle/Resources/config/routing.yml"
287+
<import resource="@AcmeDemoBundle/Resources/config/routing.xml" />
288+
</routes>
289+
290+
.. code-block:: php
291+
292+
// app/config/routing.php
293+
use Symfony\Component\Routing\RouteCollection;
294+
295+
$collection = new RouteCollection();
296+
$collection->addCollection($loader->import("@AcmeHelloBundle/Resources/config/routing.php"));
297+
298+
return $collection;
275299
276300
This will load the routes found in the ``Resources/config/routing.yml`` file
277301
of the ``AcmeDemoBundle``. The special ``@AcmeDemoBundle`` is a shortcut syntax
278302
that, internally, resolves to the full path to that bundle.
279303

280304
You can use this same strategy to bring in configuration from a bundle:
281305

282-
.. code-block:: yaml
306+
.. configuration-block::
283307

284-
# app/config/config.yml
285-
imports:
286-
- { resource: "@AcmeDemoBundle/Resources/config/config.yml" }
308+
.. code-block:: yaml
309+
310+
# app/config/config.yml
311+
imports:
312+
- { resource: "@AcmeDemoBundle/Resources/config/config.yml" }
313+
314+
.. code-block:: xml
315+
316+
<!-- app/config/config.xml -->
317+
<imports>
318+
<import resource="@AcmeDemoBundle/Resources/config/config.xml" />
319+
</imports>
320+
321+
.. code-block:: php
322+
323+
// app/config/config.php
324+
$this->import('@AcmeDemoBundle/Resources/config/config.php')
287325
288326
In Symfony2, configuration is a bit like ``app.yml`` in symfony1, except much
289327
more systematic. With ``app.yml``, you could simply create any keys you wanted.
@@ -300,10 +338,22 @@ used them in your application:
300338
In Symfony2, you can also create arbitrary entries under the ``parameters``
301339
key of your configuration:
302340

303-
.. code-block:: yaml
341+
.. configuration-block::
342+
343+
.. code-block:: yaml
344+
345+
parameters:
346+
email.from_address: foo.bar@example.com
347+
348+
.. code-block:: xml
349+
350+
<parameters>
351+
<parameter key="email.from_address">foo.bar@example.com</parameter>
352+
</parameters>
353+
354+
.. code-block:: php
304355
305-
parameters:
306-
email.from_address: foo.bar@example.com
356+
$container->setParameter('email.from_address', 'foo.bar@example.com');
307357
308358
You can now access this from a controller, for example::
309359

0 commit comments

Comments
 (0)