Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit eb36b92

Browse files
committed
Added missing formats
1 parent f60eac8 commit eb36b92

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
@@ -266,23 +266,61 @@ configuration inside a bundle must be included manually. For example, to
266266
include a routing resource from a bundle called ``AcmeDemoBundle``, you can
267267
do the following:
268268

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

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

281-
.. code-block:: yaml
305+
.. configuration-block::
282306

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

302-
.. code-block:: yaml
340+
.. configuration-block::
341+
342+
.. code-block:: yaml
343+
344+
parameters:
345+
email.from_address: [email protected]
346+
347+
.. code-block:: xml
348+
349+
<parameters>
350+
<parameter key="email.from_address">[email protected]</parameter>
351+
</parameters>
352+
353+
.. code-block:: php
303354
304-
parameters:
305-
email.from_address: [email protected]
355+
$container->setParameter('email.from_address', '[email protected]');
306356
307357
You can now access this from a controller, for example::
308358

0 commit comments

Comments
 (0)