Skip to content

Commit 76bbe64

Browse files
committed
cookbook 2.5 updates
1 parent 8d5f840 commit 76bbe64

File tree

129 files changed

+5344
-1176
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

129 files changed

+5344
-1176
lines changed

book/routing.rst

Lines changed: 121 additions & 121 deletions
Large diffs are not rendered by default.

cookbook/assetic/jpeg_optimize.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ Sedaj je lahko uporabljen iz predloge:
6464

6565
.. code-block:: html+php
6666

67-
<?php foreach ($view['assetic']->images(
67+
<?php foreach ($view['assetic']->image(
6868
array('@AcmeFooBundle/Resources/public/images/example.jpg'),
6969
array('jpegoptim')
7070
) as $url): ?>

cookbook/assetic/yuicompressor.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ stilov:
6868
6969
.. note::
7070

71-
Windows uporabniki si morajo posodobiti nastavitve na ustrezno java lokacijo.
71+
Windows uporabniki si morajo posodobiti nastavitve na ustrezno Java lokacijo.
7272
V Windows7 x64 bit je privzeto ``C:\Program Files (x86)\Java\jre6\bin\java.exe``.
7373

7474
Sedaj imate dostop do dveh novih Assetic filtrov v vaši aplikaciji:
@@ -156,12 +156,12 @@ uporabi ta filter samo, ko je razhroščevalni način onemogočen.
156156
.. tip::
157157

158158
Namesto dodajanja filtra k značkam sredstev, ga lahko tudi globalno
159-
omogočite z dodatkom t.i. apply-to-attribute v nastavitvah filtra, na primer
160-
v filtru yui_js ``apply_to: "\.js$"``. Da imate samo filter
161-
uporabljen v produkciji, dodajte to v config_prod datoteko namesto v skupno
159+
omogočite z dodatkom t.i. ``apply-to-attribute`` v nastavitvah filtra, na primer
160+
v filtru ``yui_js`` ``apply_to: "\.js$"``. Da imate samo filter
161+
uporabljen v produkciji, dodajte to v ``config_prod`` datoteko namesto v skupno
162162
config datoteko. Za podrobnosti o uporabi filtrov glede na končnico datoteke,
163163
glejte :ref:`cookbook-assetic-apply-to`.
164164

165165
.. _`YUI Compressor`: http://developer.yahoo.com/yui/compressor/
166-
.. _`Prenesite JAR`: http://yuilibrary.com/projects/yuicompressor/
166+
.. _`Prenesite JAR`: https://github.com/yui/yuicompressor/releases
167167
.. _`deprecation process`: http://www.yuiblog.com/blog/2012/10/16/state-of-yui-compressor/

cookbook/bundles/best_practices.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ class name.
5656
.. note::
5757

5858
Symfony2 core Bundles do not prefix the Bundle class with ``Symfony``
59-
and always add a ``Bundle`` subnamespace; for example:
59+
and always add a ``Bundle`` sub-namespace; for example:
6060
:class:`Symfony\\Bundle\\FrameworkBundle\\FrameworkBundle`.
6161

6262
Each bundle has an alias, which is the lower-cased short version of the bundle
@@ -154,7 +154,7 @@ All classes and files must follow the Symfony2 coding
154154
Some classes should be seen as facades and should be as short as possible, like
155155
Commands, Helpers, Listeners, and Controllers.
156156

157-
Classes that connect to the Event Dispatcher should be suffixed with
157+
Classes that connect to the event dispatcher should be suffixed with
158158
``Listener``.
159159

160160
Exceptions classes should be stored in an ``Exception`` sub-namespace.
@@ -290,4 +290,4 @@ Learn more from the Cookbook
290290

291291
* :doc:`/cookbook/bundles/extension`
292292

293-
.. _standards: http://symfony.com/PSR0
293+
.. _standards: http://www.php-fig.org/psr/psr-0/

cookbook/bundles/extension.rst

Lines changed: 60 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ you'll see a number of different configuration "namespaces", such as ``framework
1111
you to configure things at a high level and then let the bundle make all the
1212
low-level, complex changes that result.
1313

14-
For example, the following tells the ``FrameworkBundle`` to enable the form
14+
For example, the following tells the FrameworkBundle to enable the form
1515
integration, which involves the defining of quite a few services as well
1616
as integration of other related components:
1717

@@ -62,15 +62,15 @@ When you create a bundle, you have two choices on how to handle configuration:
6262
The second option - which you'll learn about in this article - is much more
6363
flexible, but also requires more time to setup. If you're wondering which
6464
method you should use, it's probably a good idea to start with method #1,
65-
and then change to #2 later if you need to. If you plan to distribute your
65+
and then change to #2 later if you need to. If you plan to distribute your
6666
bundle, the second option is recommended.
6767

6868
The second method has several specific advantages:
6969

7070
* Much more powerful than simply defining parameters: a specific option value
7171
might trigger the creation of many service definitions;
7272

73-
* Ability to have configuration hierarchy
73+
* Ability to have configuration hierarchy;
7474

7575
* Smart merging when several configuration files (e.g. ``config_dev.yml``
7676
and ``config.yml``) override each other's configuration;
@@ -89,9 +89,14 @@ The second method has several specific advantages:
8989
supported configuration settings for which backward compatibility will
9090
be maintained.
9191

92+
.. seealso::
93+
94+
For parameter handling within a Dependency Injection class see
95+
:doc:`/cookbook/configuration/using_parameters_in_dic`.
96+
9297
.. index::
9398
single: Bundle; Extension
94-
single: Dependency Injection; Extension
99+
single: DependencyInjection; Extension
95100

96101
Creating an Extension Class
97102
---------------------------
@@ -177,6 +182,52 @@ You can begin specifying configuration under this namespace immediately:
177182
array. You can still provide some sensible defaults for your bundle if
178183
you want.
179184

185+
Registering the Extension Class
186+
-------------------------------
187+
188+
An Extension class will automatically be registered by Symfony2 when
189+
following these simple conventions:
190+
191+
* The extension must be stored in the ``DependencyInjection`` sub-namespace;
192+
193+
* The extension must be named after the bundle name and suffixed with
194+
``Extension`` (``AcmeHelloExtension`` for ``AcmeHelloBundle``);
195+
196+
* The extension *should* provide an XSD schema (but will be registered automatically
197+
regardless).
198+
199+
Manually Registering an Extension Class
200+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
201+
202+
When not following the conventions, you will have to manually register your
203+
extension. To manually register an extension class override the
204+
:method:`Bundle::build() <Symfony\\Component\\HttpKernel\\Bundle\\Bundle::build>`
205+
method in your bundle::
206+
207+
// ...
208+
use Acme\HelloBundle\DependencyInjection\UnconventionalExtensionClass;
209+
210+
class AcmeHelloBundle extends Bundle
211+
{
212+
public function build(ContainerBuilder $container)
213+
{
214+
parent::build($container);
215+
216+
// register extensions that do not follow the conventions manually
217+
$container->registerExtension(new UnconventionalExtensionClass());
218+
}
219+
}
220+
221+
In this case, the extension class must also implement a ``getAlias()`` method
222+
and return a unique alias named after the bundle (e.g. ``acme_hello``). This
223+
is required because the class name doesn't follow the conventions by ending
224+
in ``Extension``.
225+
226+
Additionally, the ``load()`` method of your extension will *only* be called
227+
if the user specifies the ``acme_hello`` alias in at least one configuration
228+
file. Once again, this is because the Extension class doesn't follow the
229+
conventions set out above, so nothing happens automatically.
230+
180231
Parsing the ``$configs`` Array
181232
------------------------------
182233

@@ -494,7 +545,7 @@ configuration arrays together.
494545
The ``Configuration`` class can be much more complicated than shown here,
495546
supporting array nodes, "prototype" nodes, advanced validation, XML-specific
496547
normalization and advanced merging. You can read more about this in
497-
:doc:`the Config Component documentation </components/config/definition>`.
548+
:doc:`the Config component documentation </components/config/definition>`.
498549
You can also see it in action by checking out some of the core Configuration classes,
499550
such as the one from the `FrameworkBundle Configuration`_ or the `TwigBundle Configuration`_.
500551

@@ -504,19 +555,19 @@ Modifying the configuration of another Bundle
504555
If you have multiple bundles that depend on each other, it may be useful
505556
to allow one ``Extension`` class to modify the configuration passed to another
506557
bundle's ``Extension`` class, as if the end-developer has actually placed that
507-
configuration in his/her ``app/config/config.yml`` file.
558+
configuration in their ``app/config/config.yml`` file.
508559

509560
For more details, see :doc:`/cookbook/bundles/prepend_extension`.
510561

511562
Default Configuration Dump
512563
~~~~~~~~~~~~~~~~~~~~~~~~~~
513564

514565
The ``config:dump-reference`` command allows a bundle's default configuration to
515-
be output to the console in yaml.
566+
be output to the console in YAML.
516567

517568
As long as your bundle's configuration is located in the standard location
518569
(``YourBundle\DependencyInjection\Configuration``) and does not have a
519-
``__construct()`` it will work automatically. If you have something
570+
``__construct()`` it will work automatically. If you have something
520571
different, your ``Extension`` class must override the
521572
:method:`Extension::getConfiguration() <Symfony\\Component\\HttpKernel\\DependencyInjection\\Extension::getConfiguration>`
522573
method and return an instance of your
@@ -552,52 +603,11 @@ Comments and examples can be added to your configuration nodes using the
552603
}
553604
}
554605

555-
This text appears as yaml comments in the output of the ``config:dump-reference``
606+
This text appears as YAML comments in the output of the ``config:dump-reference``
556607
command.
557608

558609
.. index::
559610
pair: Convention; Configuration
560611

561-
Extension Conventions
562-
---------------------
563-
564-
When creating an extension, follow these simple conventions:
565-
566-
* The extension must be stored in the ``DependencyInjection`` sub-namespace;
567-
568-
* The extension must be named after the bundle name and suffixed with
569-
``Extension`` (``AcmeHelloExtension`` for ``AcmeHelloBundle``);
570-
571-
* The extension should provide an XSD schema.
572-
573-
If you follow these simple conventions, your extensions will be registered
574-
automatically by Symfony2. If not, override the
575-
:method:`Bundle::build() <Symfony\\Component\\HttpKernel\\Bundle\\Bundle::build>`
576-
method in your bundle::
577-
578-
// ...
579-
use Acme\HelloBundle\DependencyInjection\UnconventionalExtensionClass;
580-
581-
class AcmeHelloBundle extends Bundle
582-
{
583-
public function build(ContainerBuilder $container)
584-
{
585-
parent::build($container);
586-
587-
// register extensions that do not follow the conventions manually
588-
$container->registerExtension(new UnconventionalExtensionClass());
589-
}
590-
}
591-
592-
In this case, the extension class must also implement a ``getAlias()`` method
593-
and return a unique alias named after the bundle (e.g. ``acme_hello``). This
594-
is required because the class name doesn't follow the standards by ending
595-
in ``Extension``.
596-
597-
Additionally, the ``load()`` method of your extension will *only* be called
598-
if the user specifies the ``acme_hello`` alias in at least one configuration
599-
file. Once again, this is because the Extension class doesn't follow the
600-
standards set out above, so nothing happens automatically.
601-
602612
.. _`FrameworkBundle Configuration`: https://github.com/symfony/symfony/blob/master/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php
603613
.. _`TwigBundle Configuration`: https://github.com/symfony/symfony/blob/master/src/Symfony/Bundle/TwigBundle/DependencyInjection/Configuration.php

cookbook/bundles/inheritance.rst

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ things like controllers, templates, and other files in a bundle's
1212

1313
For example, suppose that you're installing the `FOSUserBundle`_, but you
1414
want to override its base ``layout.html.twig`` template, as well as one of
15-
its controllers. Suppose also that you have your own ``AcmeUserBundle``
16-
where you want the overridden files to live. Start by registering the ``FOSUserBundle``
15+
its controllers. Suppose also that you have your own AcmeUserBundle
16+
where you want the overridden files to live. Start by registering the FOSUserBundle
1717
as the "parent" of your bundle::
1818

1919
// src/Acme/UserBundle/AcmeUserBundle.php
@@ -29,7 +29,7 @@ as the "parent" of your bundle::
2929
}
3030
}
3131

32-
By making this simple change, you can now override several parts of the ``FOSUserBundle``
32+
By making this simple change, you can now override several parts of the FOSUserBundle
3333
simply by creating a file with the same name.
3434

3535
.. note::
@@ -41,7 +41,7 @@ Overriding Controllers
4141
~~~~~~~~~~~~~~~~~~~~~~
4242

4343
Suppose you want to add some functionality to the ``registerAction`` of a
44-
``RegistrationController`` that lives inside ``FOSUserBundle``. To do so,
44+
``RegistrationController`` that lives inside FOSUserBundle. To do so,
4545
just create your own ``RegistrationController.php`` file, override the bundle's
4646
original method, and change its functionality::
4747

@@ -79,11 +79,11 @@ Overriding Resources: Templates, Routing, etc
7979
Most resources can also be overridden, simply by creating a file in the same
8080
location as your parent bundle.
8181

82-
For example, it's very common to need to override the ``FOSUserBundle``'s
82+
For example, it's very common to need to override the FOSUserBundle's
8383
``layout.html.twig`` template so that it uses your application's base layout.
84-
Since the file lives at ``Resources/views/layout.html.twig`` in the ``FOSUserBundle``,
85-
you can create your own file in the same location of ``AcmeUserBundle``.
86-
Symfony will ignore the file that lives inside the ``FOSUserBundle`` entirely,
84+
Since the file lives at ``Resources/views/layout.html.twig`` in the FOSUserBundle,
85+
you can create your own file in the same location of AcmeUserBundle.
86+
Symfony will ignore the file that lives inside the FOSUserBundle entirely,
8787
and use your file instead.
8888

8989
The same goes for routing files and some other resources.

cookbook/bundles/installation.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Add Composer Dependencies
1313
In Symfony, dependencies are managed with Composer. It's a good idea to learn
1414
some basics of Composer in `their documentation`_.
1515

16-
Before you can use composer to install a bundle, you should look for a
16+
Before you can use Composer to install a bundle, you should look for a
1717
`Packagist`_ package of that bundle. For example, if you search for the popular
1818
`FOSUserBundle`_ you will find a package called `friendsofsymfony/user-bundle`_.
1919

@@ -36,7 +36,7 @@ this happens, you can try a different version.
3636
Now you can add the bundle to your ``composer.json`` file and update the
3737
dependencies. You can do this manually:
3838

39-
1. **Add it to the composer.json file:**
39+
1. **Add it to the ``composer.json`` file:**
4040

4141
.. code-block:: json
4242
@@ -132,7 +132,7 @@ Other Setup
132132
-----------
133133

134134
At this point, check the ``README`` file of your brand new bundle to see
135-
what do to next.
135+
what to do next.
136136

137137
.. _their documentation: http://getcomposer.org/doc/00-intro.md
138138
.. _Packagist: https://packagist.org

cookbook/bundles/override.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ v jedru FrameworkBundle paketa:
5353
5454
# app/config/config.yml
5555
parameters:
56-
translator.class: Acme\HelloBundle\Translation\Translator
56+
translator.class: Acme\HelloBundle\Translation\Translator
5757
5858
.. code-block:: xml
5959

0 commit comments

Comments
 (0)