Skip to content

Commit dd446f4

Browse files
author
Nathan Vonnahme
committed
Merge branch 'master' of http://github.com/symfony/symfony-docs
2 parents 856a016 + 5e82d27 commit dd446f4

Some content is hidden

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

41 files changed

+213
-191
lines changed

book/doctrine/orm.rst

Lines changed: 53 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ can control. The following configuration options exist for a mapping:
291291
- ``dir`` Path to the mapping or entity files (depending on the driver). If
292292
this path is relative it is assumed to be relative to the bundle root. This
293293
only works if the name of your mapping is a bundle name. If you want to use
294-
this option to specifiy absolute paths you should prefix the path with the
294+
this option to specify absolute paths you should prefix the path with the
295295
kernel parameters that exist in the DIC (for example %kernel.root_dir%).
296296
- ``prefix`` A common namespace prefix that all entities of this mapping
297297
share. This prefix should never conflict with prefixes of other defined
@@ -341,44 +341,6 @@ The following configuration shows a bunch of mapping examples:
341341
prefix: DoctrineExtensions\Entity\
342342
alias: DExt
343343
344-
Registering Event Listeners and Subscribers
345-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
346-
347-
Doctrine uses the lightweight ``Doctrine\Common\EventManager`` class to trigger
348-
a number of different events which you can hook into. You can register Event
349-
Listeners or Subscribers by tagging the respective services with
350-
``doctrine.dbal.<connection>_event_listener`` or
351-
``doctrine.dbal.<connection>_event_subscriber`` using the Dependency Injection
352-
container.
353-
354-
You have to use the name of the DBAL connection to clearly identify which
355-
connection the listeners should be registered with. If you are using multiple
356-
connections you can hook different events into each connection.
357-
358-
.. code-block:: xml
359-
360-
<container xmlns="http://symfony.com/schema/dic/services"
361-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
362-
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
363-
364-
<services>
365-
366-
<service id="doctrine.extensions.versionable_listener" class="DoctrineExtensions\Versionable\VersionableListener">
367-
<tag name="doctrine.dbal.default_event_subscriber" />
368-
</service>
369-
370-
<service id="mybundle.doctrine.mylistener" class="MyBundle\Doctrine\MyListener">
371-
<tag name="doctrine.dbal.default_event_listener" event="prePersist" />
372-
</service>
373-
374-
</services>
375-
376-
</container>
377-
378-
Although the Event Listener and Subscriber tags are prefixed with ``doctrine.dbal``
379-
these tags also work for the ORM events. Internally Doctrine re-uses the EventManager
380-
that is registered with the connection for the ORM.
381-
382344
Multiple Entity Managers
383345
~~~~~~~~~~~~~~~~~~~~~~~~
384346

@@ -425,18 +387,50 @@ retrieve it from the Symfony Dependency Injection Container::
425387
The service ``doctrine.orm.entity_manager`` is an alias for the default entity
426388
manager defined in the ``default_entity_manager`` configuration option.
427389

390+
Registering Event Listeners and Subscribers
391+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
392+
393+
394+
.. code-block:: xml
395+
396+
<container xmlns="http://symfony.com/schema/dic/services"
397+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
398+
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
399+
400+
<services>
401+
402+
<service id="doctrine.extensions.versionable_listener" class="DoctrineExtensions\Versionable\VersionableListener">
403+
<tag name="doctrine.dbal.default_event_subscriber" />
404+
</service>
405+
406+
<service id="mybundle.doctrine.mylistener" class="MyBundle\Doctrine\MyListener">
407+
<tag name="doctrine.dbal.default_event_listener" event="prePersist" />
408+
</service>
409+
410+
</services>
411+
412+
</container>
413+
414+
Although the Event Listener and Subscriber tags are prefixed with ``doctrine.dbal``
415+
these tags also work for the ORM events. Internally Doctrine re-uses the EventManager
416+
that is registered with the connection for the ORM.
417+
428418
.. _doctrine-event-config:
429419

430420
Registering Event Listeners and Subscribers
431421
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
432422

433-
Doctrine ships with an event system that allows to hook into many different
434-
events happening during the lifecycle of entities or at other occasions.
423+
Doctrine uses the lightweight ``Doctrine\Common\EventManager`` class to
424+
trigger a number of different events which you can hook into. You can register
425+
Event Listeners or Subscribers by tagging the respective services with
426+
``doctrine.event_listener`` or ``doctrine.event_subscriber`` using the service
427+
container.
435428

436-
To register services to act as event listeners or subscribers (listeners from here)
437-
you have to tag them with the appropriate names. Depending on your use-case you can hook
438-
a listener into every DBAL Connection and ORM Entity Manager or just into one
439-
specific DBAL connection and all the EntityManagers that use this connection.
429+
To register services to act as event listeners or subscribers (listeners from
430+
here) you have to tag them with the appropriate names. Depending on your
431+
use-case you can hook a listener into every DBAL Connection and ORM Entity
432+
Manager or just into one specific DBAL connection and all the EntityManagers
433+
that use this connection.
440434

441435
.. configuration-block::
442436

@@ -454,15 +448,15 @@ specific DBAL connection and all the EntityManagers that use this connection.
454448
my.listener:
455449
class: MyEventListener
456450
tags:
457-
- { name: doctrine.common.event_listener }
451+
- { name: doctrine.event_listener }
458452
my.listener2:
459453
class: MyEventListener2
460454
tags:
461-
- { name: doctrine.dbal.default_event_listener }
455+
- { name: doctrine.event_listener, connection: default }
462456
my.subscriber:
463457
class: MyEventSubscriber
464458
tags:
465-
- { name: doctrine.dbal.default_event_subscriber }
459+
- { name: doctrine.event_subscriber, connection: default }
466460
467461
.. code-block:: xml
468462
@@ -478,13 +472,13 @@ specific DBAL connection and all the EntityManagers that use this connection.
478472
479473
<services>
480474
<service id="my.listener" class="MyEventListener">
481-
<tag name="doctrine.common.event_listener" />
475+
<tag name="doctrine.event_listener" />
482476
</service>
483477
<service id="my.listener2" class="MyEventListener2">
484-
<tag name="doctrine.dbal.default_event_listener" />
478+
<tag name="doctrine.event_listener" connection="default" />
485479
</service>
486480
<service id="my.subscriber" class="MyEventSubscriber">
487-
<tag name="doctrine.dbal.default_event_subscriber" />
481+
<tag name="doctrine.event_subscriber" connection="default" />
488482
</service>
489483
</services>
490484
</container>
@@ -552,34 +546,24 @@ types such as strings, integers and fields. However you can also integrate
552546
them nicely with associations.
553547

554548
This is done by the help of a dedicated field:
555-
:class:`Symfony\\Component\\Form\\EntityChoiceField`. It provides a list of
549+
:class:`Symfony\\Bridge\\Doctrine\\Form\\Type\\EntityType`. It provides a list of
556550
choices from which an entity can be selected.
557551

558552
.. code-block:: php
559553
560-
use Symfony\Component\Form\EntityChoiceField;
554+
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
561555
562-
$field = new EntityChoiceField('users', array(
563-
'em' => $em,
564-
'class' => 'Acme\\HelloBundle\\Entity\\User',
565-
'property' => 'username',
566-
'query_builder' => $qb,
556+
$builder->add('users','entity',
557+
array('class' => 'Acme\\HelloBundle\\Entity\\User',
567558
));
568559
569-
$form->addField($field);
570-
571-
The 'em' option expects the EntityManager, the 'class' option expects the Entity
572-
class name as an argument. The optional 'property' option allows you to choose
573-
the property used to display the entity (``__toString`` will be used if not
574-
set). The optional 'query_builder' option expects a ``QueryBuilder`` instance or
560+
The required 'class' option expects the Entity class name as an argument.
561+
The optional 'property' option allows you to choose the property used to
562+
display the entity (``__toString`` will be used if not set).
563+
The optional 'query_builder' option expects a ``QueryBuilder`` instance or
575564
a closure receiving the repository as an argument and returning the QueryBuilder
576565
used to get the choices. If not set all entities will be used.
577566

578-
.. tip::
579-
580-
``EntityChoiceField`` extends :class:`Symfony\\Component\\Form\\ChoiceField`
581-
so you can also give the array of choices with the 'choices' option instead
582-
of using a QueryBuilder.
583567

584568
.. _documentation: http://www.doctrine-project.org/docs/orm/2.0/en
585569
.. _Doctrine: http://www.doctrine-project.org

book/forms.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ helper functions:
142142

143143
{# src/Acme/StoreBundle/Resources/views/Default/index.html.twig #}
144144

145-
<form action="{{ path('store_product') }}" method="post">
145+
<form action="{{ path('store_product') }}" method="post" {{ form_enctype(form) }}>
146146
{{ form_widget(form) }}
147147

148148
<input type="submit" />
@@ -152,7 +152,7 @@ helper functions:
152152

153153
<?php // src/Acme/StoreBundle/Resources/views/Default/index.html.php ?>
154154

155-
<form action="<?php echo $view['router']->generate('store_product') ?>" method="post">
155+
<form action="<?php echo $view['router']->generate('store_product') ?>" method="post" <?php echo $view['form']->enctype($form) ?> >
156156
<?php echo $view['form']->widget($form) ?>
157157

158158
<input type="submit" />

book/from_flat_php_to_symfony2.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,7 @@ files in the application and to configure the autoloader:
438438

439439
$loader = new Symfony\Component\ClassLoader\UniversalClassLoader();
440440
$loader->registerNamespaces(array(
441-
'Symfony' => __DIR__.'/vendor/symfony/src',
441+
'Symfony' => __DIR__.'/vendor/symfony/src',
442442
));
443443

444444
$loader->register();

book/http_fundamentals.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ Now, every request is handled exactly the same. Instead of individual URLs
320320
executing different PHP files, the front controller is *always* executed,
321321
and the routing of different URLs to different parts of your application
322322
is done internally. This solves both problems with the original approach.
323-
Almost all modern web apps do this - including apps like Wordpress.
323+
Almost all modern web apps do this - including apps like WordPress.
324324

325325
Stay Organized
326326
~~~~~~~~~~~~~~

book/internals/event_dispatcher.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ define and document your event:
228228
* The onStoreOrder event is thrown each time an order is created
229229
* in the system.
230230
*
231-
* The event listener recieves an Acme\StoreBundle\Event\FilterOrderEvent
231+
* The event listener receives an Acme\StoreBundle\Event\FilterOrderEvent
232232
* instance.
233233
*
234234
* @var string

book/page_creation.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ to the ``app/autoload.php`` file (see the :ref:`Autoloading sidebar<autoloading-
6666
.. code-block:: php
6767
6868
$loader->registerNamespaces(array(
69-
'Acme' => __DIR__.'/../src',
69+
'Acme' => __DIR__.'/../src',
7070
// ...
7171
));
7272
@@ -268,7 +268,7 @@ of writing the HTML inside the controller, use a template instead::
268268
.. note::
269269

270270
In order to use the ``render()`` method, you must extend the
271-
:class:`Symfony\Bundle\FrameworkBundle\Controller\Controller` class, which
271+
:class:`Symfony\\Bundle\\FrameworkBundle\\Controller\\Controller` class, which
272272
adds shortcuts for tasks that are common inside controllers.
273273

274274
The ``render()`` method creates a ``Response`` object filled with the content
@@ -466,7 +466,7 @@ about each of these directories in later chapters.
466466
behalf the instance you need a class::
467467
468468
$loader->registerNamespaces(array(
469-
'Acme' => __DIR__.'/../src',
469+
'Acme' => __DIR__.'/../src',
470470
// ...
471471
));
472472
@@ -619,8 +619,8 @@ tools later.
619619

620620
.. tip::
621621

622-
Whenever creating a new bundle or using a third-party bundle, be sure
623-
to always make sure that the bundle has been enabled in ``registerBundles()``.
622+
Whenever creating a new bundle or using a third-party bundle, always make
623+
sure the bundle has been enabled in ``registerBundles()``.
624624

625625
Bundle Directory Structure
626626
~~~~~~~~~~~~~~~~~~~~~~~~~~

book/service_container.rst

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -404,19 +404,19 @@ invokes the service container extension inside the ``FrameworkBundle``:
404404
405405
# app/config/config.yml
406406
framework:
407+
secret: xxxxxxxxxx
407408
charset: UTF-8
408409
error_handler: null
409410
csrf_protection:
410411
enabled: true
411-
secret: xxxxxxxxxx
412412
router: { resource: "%kernel.root_dir%/config/routing.yml" }
413413
# ...
414414
415415
.. code-block:: xml
416416
417417
<!-- app/config/config.xml -->
418-
<framework:config charset="UTF-8" error-handler="null">
419-
<framework:csrf-protection enabled="true" secret="xxxxxxxxxx" />
418+
<framework:config charset="UTF-8" error-handler="null" secret="xxxxxxxxxx">
419+
<framework:csrf-protection enabled="true" />
420420
<framework:router resource="%kernel.root_dir%/config/routing.xml" cache-warmer="true" />
421421
<!-- ... -->
422422
</framework>
@@ -425,9 +425,10 @@ invokes the service container extension inside the ``FrameworkBundle``:
425425
426426
// app/config/config.php
427427
$container->loadFromExtension('framework', array(
428+
'secret' => 'xxxxxxxxxx',
428429
'charset' => 'UTF-8',
429430
'error_handler' => null,
430-
'csrf-protection' => array('enabled' => true, 'secret' => 'xxxxxxxxxx'),
431+
'csrf-protection' => array('enabled' => true),
431432
'router' => array('resource' => '%kernel.root_dir%/config/routing.php'),
432433
// ...
433434
));

book/templating.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1121,7 +1121,7 @@ and in Symfony2, that's absolutely fine.
11211121
Learn more from the Cookbook
11221122
----------------------------
11231123

1124-
* :doc:`/cookbook/controller/PHP`
1124+
* :doc:`/cookbook/templating/PHP`
11251125
* :doc:`/cookbook/controller/error_pages`
11261126

11271127
.. _`Twig`: http://www.twig-project.org

book/testing.rst

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -664,9 +664,12 @@ The Client used by functional tests creates a Kernel that runs in a special
664664
toolbar: false
665665
intercept_redirects: false
666666
667-
zend:
668-
logger:
669-
priority: debug
667+
monolog:
668+
handlers:
669+
main:
670+
type: stream
671+
path: %kernel.logs_dir%/%kernel.environment%.log
672+
level: debug
670673
671674
.. code-block:: xml
672675
@@ -685,9 +688,13 @@ The Client used by functional tests creates a Kernel that runs in a special
685688
<framework:test />
686689
</framework:config>
687690
688-
<zend:config>
689-
<zend:logger priority="debug" />
690-
</zend:config>
691+
<monolog:config>
692+
<monolog:main
693+
type="stream"
694+
path="%kernel.logs_dir%/%kernel.environment%.log"
695+
level="debug"
696+
/>
697+
</monolog:config>
691698
</container>
692699
693700
.. code-block:: php
@@ -705,9 +712,13 @@ The Client used by functional tests creates a Kernel that runs in a special
705712
'intercept-redirects' => false,
706713
));
707714
708-
$container->loadFromExtension('zend', array(
709-
'logger' => array('priority' => 'debug'),
710-
));
715+
$container->loadFromExtension('monolog', array(
716+
'handlers' => array(
717+
'main' => array('type' => 'stream',
718+
'path' => '%kernel.logs_dir%/%kernel.environment%.log'
719+
'level' => 'debug')
720+
721+
)));
711722
712723
You can also change the default environment (``test``) and override the
713724
default debug mode (``true``) by passing them as options to the

0 commit comments

Comments
 (0)