You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: core/data-persisters.md
+2-1Lines changed: 2 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -7,10 +7,11 @@ process](serialization.md).
7
7
8
8
A data persister using [Doctrine ORM](http://www.doctrine-project.org/projects/orm.html) is included with the library and
9
9
is enabled by default. It is able to persist and delete objects that are also mapped as [Doctrine entities](https://www.doctrine-project.org/projects/doctrine-orm/en/2.6/reference/basic-mapping.html).
10
+
A [Doctrine MongoDB ODM](https://www.doctrine-project.org/projects/mongodb-odm.html) data persister is also included and can be enabled by following the [MongoDB documentation](mongodb.md).
10
11
11
12
However, you may want to:
12
13
13
-
* store data to other persistence layers (ElasticSearch, MongoDB, external web services...)
14
+
* store data to other persistence layers (ElasticSearch, external web services...)
14
15
* not publicly expose the internal model mapped with the database through the API
15
16
* use a separate model for [read operations](data-providers.md) and for updates by implementing patterns such as [CQRS](https://martinfowler.com/bliki/CQRS.html)
Alternatively, [the subscriber must be registered manually](http://symfony.com/doc/current/components/http_kernel/introduction.html#creating-an-event-listener).
Creating custom extensions is the same as Doctrine ORM.
158
+
159
+
The interfaces are:
160
+
* `ApiPlatform\Core\Bridge\Doctrine\MongoDbOdm\Extension\AggregationItemExtensionInterface` and `ApiPlatform\Core\Bridge\Doctrine\MongoDbOdm\Extension\AggregationCollectionExtensionInterface` to add stages to the [aggregation builder](https://www.doctrine-project.org/projects/doctrine-mongodb-odm/en/latest/reference/aggregation-builder.html).
161
+
* `ApiPlatform\Core\Bridge\Doctrine\MongoDbOdm\Extension\AggregationResultItemExtensionInterface` and `ApiPlatform\Core\Bridge\Doctrine\MongoDbOdm\Extension\AggregationResultCollectionExtensionInterface` to return a result.
162
+
163
+
The tags are `api_platform.doctrine.mongodb.aggregation_extension.item` and `api_platform.doctrine.mongodb.aggregation_extension.collection`.
164
+
165
+
The custom extensions receive the [aggregation builder](https://www.doctrine-project.org/projects/doctrine-mongodb-odm/en/latest/reference/aggregation-builder.html),
166
+
used to execute [complex operations on data](https://docs.mongodb.com/manual/aggregation/).
167
+
155
168
## Custom Elasticsearch Extension
156
169
157
170
Currently only extensions querying for a collection of items through a [search request](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-body.html)
A conflict will occur if `order` is also the name of a property with the term filter enabled. Luckily, the query
628
+
A conflict will occur if `order` is also the name of a property with the term filter enabled. Luckily, the query
626
629
parameter name to use is configurable:
627
630
628
631
```yaml
@@ -810,21 +813,20 @@ If you want to include some properties of the nested "author" document, use: `/b
810
813
811
814
## Creating Custom Filters
812
815
813
-
Custom filters can be written by implementing the `ApiPlatform\Core\Api\FilterInterface`
814
-
interface.
816
+
Custom filters can be written by implementing the `ApiPlatform\Core\Api\FilterInterface` interface.
815
817
816
-
API Platform provides a convenient way to create Doctrine ORM filters. If you use [custom data providers](data-providers.md),
818
+
API Platform provides a convenient way to create Doctrine ORM and MongoDB ODM filters. If you use [custom data providers](data-providers.md),
817
819
you can still create filters by implementing the previously mentioned interface, but - as API Platform isn't aware of your
818
820
persistence system's internals - you have to create the filtering logic by yourself.
819
821
820
822
### Creating Custom Doctrine ORM Filters
821
823
822
-
Doctrine filters have access to the HTTP request (Symfony's `Request` object) and to the `QueryBuilder` instance used to
824
+
Doctrine ORM filters have access to the context created from the HTTP request and to the `QueryBuilder` instance used to
823
825
retrieve data from the database. They are only applied to collections. If you want to deal with the DQL query generated
824
-
to retrieve items, or don't need to access the HTTP request, [extensions](extensions.md) are the way to go.
826
+
to retrieve items, [extensions](extensions.md) are the way to go.
825
827
826
828
A Doctrine ORM filter is basically a class implementing the `ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\FilterInterface`.
827
-
API Platform includes a convenient abstract class implementing this interface and providing utility methods: `ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\AbstractFilter`
829
+
API Platform includes a convenient abstract class implementing this interface and providing utility methods: `ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\AbstractFilter`.
828
830
829
831
In the following example, we create a class to filter a collection by applying a regexp to a property. The `REGEXP` DQL
830
832
function used in this example can be found in the [`DoctrineExtensions`](https://github.com/beberlei/DoctrineExtensions)
@@ -902,7 +904,7 @@ it can also be enabled for some properties:
# Uncomment only if autoconfiguration isn't enabled
907
909
#tags: [ 'api_platform.filter' ]
908
910
```
@@ -952,6 +954,15 @@ class Offer
952
954
You can now enable this filter using URLs like `http://example.com/offers?regexp_email=^[FOO]`. This new filter will also
953
955
appear in Swagger and Hydra documentations.
954
956
957
+
### Creating Custom Doctrine MongoDB ODM Filters
958
+
959
+
Doctrine MongoDB ODM filters have access to the context created from the HTTP request and to the [aggregation builder](https://www.doctrine-project.org/projects/doctrine-mongodb-odm/en/latest/reference/aggregation-builder.html)
960
+
instance used to retrieve data from the database and to execute [complex operations on data](https://docs.mongodb.com/manual/aggregation/).
961
+
They are only applied to collections. If you want to deal with the aggregation pipeline generated to retrieve items, [extensions](extensions.md) are the way to go.
962
+
963
+
A Doctrine MongoDB ODM filter is basically a class implementing the `ApiPlatform\Core\Bridge\Doctrine\MongoDbOdm\Filter\FilterInterface`.
964
+
API Platform includes a convenient abstract class implementing this interface and providing utility methods: `ApiPlatform\Core\Bridge\Doctrine\MongoDbOdm\Filter\AbstractFilter`.
965
+
955
966
### Creating Custom Elasticsearch Filters
956
967
957
968
Elasticsearch filters have access to the context created from the HTTP request and to the Elasticsearch query clause.
@@ -963,9 +974,9 @@ A constant score query filter is basically a class implementing the `ApiPlatform
963
974
and the `ApiPlatform\Core\Bridge\Elasticsearch\DataProvider\Filter\FilterInterface`. API Platform includes a convenient
964
975
abstract class implementing this last interface and providing utility methods: `ApiPlatform\Core\Bridge\Elasticsearch\DataProvider\Filter\AbstractFilter`.
965
976
966
-
### Using Doctrine Filters
977
+
### Using Doctrine ORM Filters
967
978
968
-
Doctrine features [a filter system](http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/reference/filters.html) that allows the developer to add SQL to the conditional clauses of queries, regardless the place where the SQL is generated (e.g. from a DQL query, or by loading associated entities).
979
+
Doctrine ORM features [a filter system](http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/reference/filters.html) that allows the developer to add SQL to the conditional clauses of queries, regardless the place where the SQL is generated (e.g. from a DQL query, or by loading associated entities).
969
980
These are applied on collections and items, so are incredibly useful.
970
981
971
982
The following information, specific to Doctrine filters in Symfony, is based upon [a great article posted on Michaël Perrin's blog](http://blog.michaelperrin.fr/2014/12/05/doctrine-filters/).
Copy file name to clipboardExpand all lines: core/fosuser-bundle.md
+1Lines changed: 1 addition & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -39,6 +39,7 @@ api_platform:
39
39
## Creating a `User` Entity with Serialization Groups
40
40
41
41
Here's an example of declaration of a [Doctrine ORM User class](https://github.com/FriendsOfSymfony/FOSUserBundle/blob/master/Resources/doc/index.rst#a-doctrine-orm-user-class).
42
+
There's also an example for a [Doctrine MongoDB ODM](https://github.com/FriendsOfSymfony/FOSUserBundle/blob/master/Resources/doc/index.rst#b-mongodb-user-class).
42
43
You need to use serialization groups to hide some properties like `plainPassword` (only in read) and `password`. The properties
43
44
shown are handled with the [`normalization_context`](serialization.md#normalization), while the properties
44
45
you can modify are handled with [`denormalization_context`](serialization.md#denormalization).
Copy file name to clipboardExpand all lines: core/getting-started.md
+1Lines changed: 1 addition & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -6,6 +6,7 @@ If you are starting a new project, the easiest way to get API Platform up is to
6
6
It ships with the API Platform Core library integrated with [the Symfony framework](https://symfony.com), [the schema generator](../schema-generator/),
[NelmioCorsBundle](https://github.com/nelmio/NelmioCorsBundle) and [Behat](http://behat.org).
9
+
[Doctrine MongoDB ODM](https://www.doctrine-project.org/projects/mongodb-odm.html) can also be enabled by following the [MongoDB documentation](mongodb.md).
9
10
Basically, it is a Symfony edition packaged with the best tools to develop a REST API and sensible default settings.
10
11
11
12
Alternatively, you can use [Composer](http://getcomposer.org) to install the standalone bundle in an existing Symfony Flex
0 commit comments