Skip to content

Commit 14bbdd4

Browse files
committed
bundles section updated for 2.5
1 parent 6a8475c commit 14bbdd4

File tree

13 files changed

+292
-90
lines changed

13 files changed

+292
-90
lines changed

bundles/DoctrineFixturesBundle/index.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,15 @@ Standard edition. Add the following to your ``composer.json`` file:
2020
2121
{
2222
"require": {
23-
"doctrine/doctrine-fixtures-bundle": "dev-master"
23+
"doctrine/doctrine-fixtures-bundle": "2.2.*"
2424
}
2525
}
2626
2727
Update the vendor libraries:
2828

2929
.. code-block:: bash
3030
31-
$ php composer.phar update
31+
$ php composer.phar update doctrine/doctrine-fixtures-bundle
3232
3333
If everything worked, the ``DoctrineFixturesBundle`` can now be found
3434
at ``vendor/doctrine/doctrine-fixtures-bundle``.

bundles/DoctrineMigrationsBundle/index.rst

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ Standard edition. Add the following to your ``composer.json`` file:
2323
2424
{
2525
"require": {
26+
"doctrine/migrations": "dev-master",
2627
"doctrine/doctrine-migrations-bundle": "dev-master"
2728
}
2829
}
@@ -55,6 +56,20 @@ following:
5556
new Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle(),
5657
);
5758
}
59+
60+
Configuration
61+
-------------
62+
63+
You can configure the path, namespace, table_name and name in your `config.yml`. The examples below are the default values.
64+
65+
.. code-block:: yaml
66+
67+
// app/config/config.yml
68+
doctrine_migrations:
69+
dir_name: %kernel.root_dir%/DoctrineMigrations
70+
namespace: Application\Migrations
71+
table_name: migration_versions
72+
name: Application Migrations
5873
5974
Usage
6075
-----
@@ -126,7 +141,7 @@ migration to execute:
126141

127142
.. code-block:: bash
128143
129-
php app/console doctrine:migrations:status
144+
php app/console doctrine:migrations:status --show-versions
130145
131146
== Configuration
132147
@@ -150,7 +165,7 @@ finally migrate when you're ready:
150165

151166
.. code-block:: bash
152167
153-
php app/console doctrine:migrations:migrate
168+
php app/console doctrine:migrations:migrate 20100621140655
154169
155170
For more information on how to write the migrations themselves (i.e. how to
156171
fill in the ``up()`` and ``down()`` methods), see the official Doctrine Migrations
@@ -287,7 +302,9 @@ to get full access to the container.
287302
.. code-block:: php
288303
289304
// ...
290-
305+
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
306+
use Symfony\Component\DependencyInjection\ContainerInterface;
307+
291308
class Version20130326212938 extends AbstractMigration implements ContainerAwareInterface
292309
{
293310

bundles/DoctrineMongoDBBundle/config.rst

Lines changed: 58 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ Explicit definition of all the mapped documents is the only necessary
101101
configuration for the ODM and there are several configuration options that you
102102
can control. The following configuration options exist for a mapping:
103103

104-
- ``type`` One of ``annotations``, ``xml``, ``yml``, ``php`` or ``staticphp``.
104+
- ``type`` One of ``annotation``, ``xml``, ``yml``, ``php`` or ``staticphp``.
105105
This specifies which type of metadata type your mapping uses.
106106

107107
- ``dir`` Path to the mapping or entity files (depending on the driver). If
@@ -164,23 +164,65 @@ The following configuration shows a bunch of mapping examples:
164164
Filters
165165
~~~~~~~
166166

167-
You can easily add filters to a document manager by using the
168-
following syntax:
167+
Filter classes may be used in order to add criteria to ODM queries, regardless
168+
of where those queries are created within your application. Typically, filters
169+
will limit themselves to operating on a particular class or interface. Filters
170+
may also take parameters, which can be used to customize the injected query
171+
criteria.
169172

170-
.. code-block:: yaml
173+
Filters may be registered with a document manager by using the following syntax:
171174

172-
doctrine_mongodb:
173-
document_managers:
174-
default:
175-
filters:
176-
filter-one:
177-
class: Class\ExampleOne\Filter\ODM\ExampleFilter
178-
enabled: true
179-
filter-two:
180-
class: Class\ExampleTwo\Filter\ODM\ExampleFilter
181-
enabled: false
175+
.. configuration-block::
176+
177+
.. code-block:: yaml
178+
179+
doctrine_mongodb:
180+
document_managers:
181+
default:
182+
filters:
183+
basic_filter:
184+
class: Vendor\Filter\BasicFilter
185+
enabled: true
186+
complex_filter:
187+
class: Vendor\Filter\ComplexFilter
188+
enabled: false
189+
parameters:
190+
author: bob
191+
comments: { $gte: 10 }
192+
tags: { $in: [ 'foo', 'bar' ] }
193+
194+
.. code-block:: xml
195+
196+
<?xml version="1.0" ?>
197+
198+
<container xmlns="http://symfony.com/schema/dic/services"
199+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
200+
xmlns:doctrine="http://symfony.com/schema/dic/doctrine/odm/mongodb"
201+
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd
202+
http://symfony.com/schema/dic/doctrine/odm/mongodb http://symfony.com/schema/dic/doctrine/odm/mongodb/mongodb-1.0.xsd">
203+
204+
<doctrine:mongodb>
205+
<doctrine:connection id="default" server="mongodb://localhost:27017" />
206+
207+
<doctrine:document-manager id="default" connection="default">
208+
<doctrine:filter name="basic_filter" enabled="true" class="Vendor\Filter\BasicFilter" />
209+
<doctrine:filter name="complex_filter" enabled="true" class="Vendor\Filter\ComplexFilter">
210+
<doctrine:parameter name="author">bob</doctrine:parameter>
211+
<doctrine:parameter name="comments">{ "$gte": 10 }</doctrine:parameter>
212+
<doctrine:parameter name="tags">{ "$in": [ "foo", "bar" ] }</doctrine:parameter>
213+
</doctrine:filter>
214+
</doctrine:document-manager>
215+
</doctrine:mongodb>
216+
</container>
217+
218+
.. note::
182219

183-
Filters are used to append conditions to the queryBuilder regardless of where the query is generated.
220+
Unlike ORM, query parameters in MongoDB ODM may be non-scalar values. Since
221+
such values are difficult to express in XML, the bundle allows JSON strings
222+
to be used in ``parameter`` tags. While processing the configuration, the
223+
bundle will run the tag contents through ``json_decode()`` if the string is
224+
wrapped in square brackets or curly braces for arrays and objects,
225+
respectively.
184226

185227
Multiple Connections
186228
~~~~~~~~~~~~~~~~~~~~
@@ -335,6 +377,7 @@ Full Default Configuration
335377
replicaSet: ~
336378
username: ~
337379
password: ~
380+
db: ~
338381
proxy_namespace: MongoDBODMProxies
339382
proxy_dir: %kernel.cache_dir%/doctrine/odm/mongodb/Proxies
340383
auto_generate_proxy_classes: false

bundles/DoctrineMongoDBBundle/form.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,12 +89,12 @@ Next, create the form for the ``User`` model::
8989

9090
use Symfony\Component\Form\AbstractType;
9191
use Symfony\Component\Form\Extension\Core\Type\RepeatedType;
92-
use Symfony\Component\Form\FormBuilder;
92+
use Symfony\Component\Form\FormBuilderInterface;
9393
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
9494

9595
class UserType extends AbstractType
9696
{
97-
public function buildForm(FormBuilder $builder, array $options)
97+
public function buildForm(FormBuilderInterface $builder, array $options)
9898
{
9999
$builder->add('email', 'email');
100100
$builder->add('password', 'repeated', array(
@@ -185,11 +185,11 @@ Next, create the form for this ``Registration`` model::
185185

186186
use Symfony\Component\Form\AbstractType;
187187
use Symfony\Component\Form\Extension\Core\Type\RepeatedType;
188-
use Symfony\Component\Form\FormBuilder;
188+
use Symfony\Component\Form\FormBuilderInterface;
189189

190190
class RegistrationType extends AbstractType
191191
{
192-
public function buildForm(FormBuilder $builder, array $options)
192+
public function buildForm(FormBuilderInterface $builder, array $options)
193193
{
194194
$builder->add('user', new UserType());
195195
$builder->add('terms', 'checkbox', array('property_path' => 'termsAccepted'));

bundles/DoctrineMongoDBBundle/index.rst

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,12 @@ The ``@dev`` definition is necessary until non-beta versions of the bundle and
5050
ODM are available. Depending on your project needs, other version strings may
5151
be used, which are discussed in Composer's `schema documentation`_.
5252

53-
You can now can install the new dependencies by running Composer's ``update``
53+
You can now install the new dependencies by running Composer's ``update``
5454
command from the directory where your ``composer.json`` file is located:
5555

5656
.. code-block :: bash
5757
58-
php composer.phar update
58+
php composer.phar update doctrine/mongodb-odm doctrine/mongodb-odm-bundle
5959
6060
Now, Composer will automatically download all required files, and install them
6161
for you.
@@ -389,7 +389,7 @@ to easily fetch objects based on multiple conditions::
389389
// query for one product matching be name and price
390390
$product = $repository->findOneBy(array('name' => 'foo', 'price' => 19.99));
391391

392-
// query for all prdocuts matching the name, ordered by price
392+
// query for all products matching the name, ordered by price
393393
$product = $repository->findBy(
394394
array('name' => 'foo'),
395395
array('price', 'ASC')
@@ -689,7 +689,7 @@ and then :ref:`tagging<book-service-container-tags>` it with a specific tag.
689689
<service id="my_doctrine_listener" class="Acme\HelloBundle\Listener\MyDoctrineListener">
690690
<!-- ... -->
691691
<tag name="doctrine_mongodb.odm.event_listener" event="postPersist" />
692-
</service>.
692+
</service>
693693
694694
.. code-block:: php
695695
@@ -738,6 +738,17 @@ same than the `entity` provider described in :doc:`the cookbook</cookbook/securi
738738
</provider>
739739
</config>
740740
741+
Validation
742+
----------
743+
744+
This bundle provides a ``Unique`` constraint, which extends the `UniqueEntity`_
745+
constraint provided by Symfony's Doctrine bridge. This constraint allows you to
746+
validate the uniqueness of an document field against the database.
747+
748+
The ``Unique`` constraint shares the same options as `UniqueEntity`_, which
749+
means that the ``em`` option should be used if you wish to specify the document
750+
manager explicitly instead of having it be inferred from the document class.
751+
741752
Using the Abstraction Layer
742753
---------------------------
743754

@@ -785,10 +796,11 @@ Learn more from the Cookbook
785796
.. _`documentation`: http://docs.doctrine-project.org/projects/doctrine-mongodb-odm/en/latest/
786797
.. _`schema documentation`: http://getcomposer.org/doc/04-schema.md#minimum-stability
787798
.. _`Quick Start`: http://www.mongodb.org/display/DOCS/Quickstart
788-
.. _`Basic Mapping Documentation`: http://www.doctrine-project.org/docs/mongodb_odm/1.0/en/reference/basic-mapping.html
799+
.. _`Basic Mapping Documentation`: http://docs.doctrine-project.org/projects/doctrine-mongodb-odm/en/latest/reference/basic-mapping.html
789800
.. _`MongoDB type`: http://us.php.net/manual/en/mongo.types.php
790801
.. _`Mapping Types Documentation`: http://docs.doctrine-project.org/projects/doctrine-mongodb-odm/en/latest/reference/basic-mapping.html#doctrine-mapping-types
791802
.. _`Query Builder`: http://www.doctrine-project.org/docs/mongodb_odm/1.0/en/reference/query-builder-api.html
792803
.. _`Conditional Operators`: http://www.doctrine-project.org/docs/mongodb_odm/1.0/en/reference/query-builder-api.html#conditional-operators
793804
.. _`Event Documentation`: http://www.doctrine-project.org/docs/mongodb_odm/1.0/en/reference/events.html
794805
.. _`PHP Documentation`: http://www.php.net/manual/en/mongo.tutorial.php
806+
.. _`UniqueEntity`: http://symfony.com/doc/current/reference/constraints/UniqueEntity.html
Lines changed: 64 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,28 @@
11
@Cache
22
======
33

4-
Usage
5-
-----
4+
The ``@Cache`` annotation makes it easy to define HTTP caching headers for
5+
expiration and validation.
6+
7+
HTTP Expiration Strategies
8+
--------------------------
69

710
The ``@Cache`` annotation makes it easy to define HTTP caching::
811

912
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Cache;
1013

1114
/**
12-
* @Cache(expires="tomorrow", public="true")
15+
* @Cache(expires="tomorrow", public=true)
1316
*/
1417
public function indexAction()
1518
{
1619
}
1720

18-
You can also use the annotation on a class to define caching for all methods::
21+
You can also use the annotation on a class to define caching for all actions
22+
of a controller::
1923

2024
/**
21-
* @Cache(expires="tomorrow", public="true")
25+
* @Cache(expires="tomorrow", public=true)
2226
*/
2327
class BlogController extends Controller
2428
{
@@ -40,22 +44,63 @@ configuration, the latter overrides the former::
4044
}
4145
}
4246

43-
Attributes
44-
----------
47+
.. note::
4548

46-
Here is a list of accepted attributes and their HTTP header equivalent:
49+
The ``expires`` attribute takes any valid date understood by the PHP
50+
``strtotime()`` function.
51+
52+
HTTP Validation Strategies
53+
--------------------------
54+
55+
The ``lastModified`` and ``ETag`` attributes manages the HTTP validation cache
56+
headers. ``lastModified`` adds a ``Last-Modified`` header to Responses and
57+
``ETag`` adds an ``ETag`` header.
58+
59+
Both automatically trigger the logic to return a 304 response when the
60+
response is not modified (in this case, the controller is **not** called)::
61+
62+
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Cache;
63+
64+
/**
65+
* @Cache(lastModified="post.getUpdatedAt()", ETag="'Post' ~ post.getId() ~ post.getUpdatedAt()")
66+
*/
67+
public function indexAction(Post $post)
68+
{
69+
// your code
70+
// won't be called in case of a 304
71+
}
72+
73+
It's roughly doing the same as the following code::
74+
75+
public function myAction(Request $request, Post $post)
76+
{
77+
$response = new Response();
78+
$response->setLastModified($post->getUpdatedAt());
79+
if ($response->isNotModified($request)) {
80+
return $response;
81+
}
4782

48-
============================== ===============
49-
Annotation Response Method
50-
============================== ===============
51-
``@Cache(expires="tomorrow")`` ``$response->setExpires()``
52-
``@Cache(smaxage="15")`` ``$response->setSharedMaxAge()``
53-
``@Cache(maxage="15")`` ``$response->setMaxAge()``
54-
``@Cache(vary=["Cookie"])`` ``$response->setVary()``
55-
``@Cache(public="true")`` ``$response->setPublic()``
56-
============================== ===============
83+
// your code
84+
}
5785

5886
.. note::
5987

60-
The ``expires`` attribute takes any valid date understood by the PHP
61-
``strtotime()`` function.
88+
The ETag HTTP header value is the result of the expression hashed with the
89+
``sha256`` algorithm.
90+
91+
Attributes
92+
----------
93+
94+
Here is a list of accepted attributes and their HTTP header equivalent:
95+
96+
===================================================== ================================
97+
Annotation Response Method
98+
===================================================== ================================
99+
``@Cache(expires="tomorrow")`` ``$response->setExpires()``
100+
``@Cache(smaxage="15")`` ``$response->setSharedMaxAge()``
101+
``@Cache(maxage="15")`` ``$response->setMaxAge()``
102+
``@Cache(vary={"Cookie"})`` ``$response->setVary()``
103+
``@Cache(public=true)`` ``$response->setPublic()``
104+
``@Cache(lastModified="post.getUpdatedAt()")`` ``$response->setLastModified()``
105+
``@Cache(ETag="post.getId() ~ post.getUpdatedAt()")`` ``$response->setETag()``
106+
===================================================== ================================

0 commit comments

Comments
 (0)