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
+3-3Lines changed: 3 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -11,11 +11,11 @@ A [Doctrine MongoDB ODM](https://www.doctrine-project.org/projects/mongodb-odm.h
11
11
12
12
However, you may want to:
13
13
14
-
* store data to other persistence layers (ElasticSearch, external web services...)
14
+
* store data to other persistence layers (Elasticsearch, external web services...)
15
15
* not publicly expose the internal model mapped with the database through the API
16
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)
17
17
18
-
Custom data persisters can be used to do so. A project can include as many data persisters as it needs. The first able to
18
+
Custom data persisters can be used to do so. A project can include as many data persisters as needed. The first able to
19
19
persist data for a given resource will be used.
20
20
21
21
## Creating a Custom Data Persister
@@ -25,7 +25,7 @@ This interface defines only 3 methods:
25
25
26
26
*`persist`: to create or update the given data
27
27
*`remove`: to delete the given data
28
-
*`support`: checks whether the given data is supported by this data persister
28
+
*`support`: to check whether the given data is supported by this data persister
ApiPlatform provides a few extensions that you can reuse in your custom DataProvider.
170
-
Note that there are a few kind of extensions which are detailed in [their own chapter of the documentation](extensions.md).
170
+
Note that there are a few kinds of extensions which are detailed in [their own chapter of the documentation](extensions.md).
171
171
Because extensions are tagged services, you can use the [injection of tagged services](https://symfony.com/blog/new-in-symfony-3-4-simpler-injection-of-tagged-services):
Copy file name to clipboardExpand all lines: core/design.md
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -32,7 +32,7 @@ For [Rapid Application Development](https://en.wikipedia.org/wiki/Rapid_applicat
32
32
**if and only if the class marked with `@ApiResource` is also a Doctrine entity**, the developer can use the Doctrine
33
33
ORM's data provider and persister implementations shipped with API Platform.
34
34
35
-
In this case, the public (`@ApiResource`) and internal (Doctrine entity) data model are shared. Then, API Platform will
35
+
In this case, the public (`@ApiResource`) and internal (Doctrine entity) data models are shared. Then, API Platform will
36
36
be able to query, filter, paginate and persist data automatically.
37
37
This approach is super-convenient and efficient, but is probably **not a good idea** for non-[CRUD](https://en.wikipedia.org/wiki/Create,_read,_update_and_delete)
Copy file name to clipboardExpand all lines: core/filters.md
+25-25Lines changed: 25 additions & 25 deletions
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,7 @@
1
1
# Filters
2
2
3
3
API Platform Core provides a generic system to apply filters on collections. Useful filters for the Doctrine ORM and
4
-
MongoDB ODM are provided with the library. You can also create custom filters that would fit your specific needs.
4
+
MongoDB ODM are provided with the library. You can also create custom filters that fit your specific needs.
5
5
You can also add filtering support to your custom [data providers](data-providers.md) by implementing interfaces provided
6
6
by the library.
7
7
@@ -127,19 +127,19 @@ If Doctrine ORM or MongoDB ODM support is enabled, adding filters is as easy as
127
127
128
128
The search filter supports `exact`, `partial`, `start`, `end`, and `word_start` matching strategies:
129
129
130
-
* `partial` strategy uses `LIKE %text%` to search for fields that containing the text.
131
-
* `start` strategy uses `LIKE text%` to search for fields that starts with text.
132
-
* `end` strategy uses `LIKE %text` to search for fields that ends with text.
133
-
* `word_start` strategy uses `LIKE text% OR LIKE % text%` to search for fields that contains the word starting with `text`.
130
+
* `partial` strategy uses `LIKE %text%` to search for fields that contain `text`.
131
+
* `start` strategy uses `LIKE text%` to search for fields that start with `text`.
132
+
* `end` strategy uses `LIKE %text` to search for fields that end with `text`.
133
+
* `word_start` strategy uses `LIKE text% OR LIKE % text%` to search for fields that contain words starting with `text`.
134
134
135
135
Prepend the letter `i` to the filter if you want it to be case insensitive. For example `ipartial` or `iexact`. Note that
136
136
this will use the `LOWER` function and **will** impact performance [if there is no proper index](performance.md#search-filter).
137
137
138
138
Case insensitivity may already be enforced at the database level depending on the [collation](https://en.wikipedia.org/wiki/Collation)
139
139
used. If you are using MySQL, note that the commonly used `utf8_unicode_ci` collation (and its sibling `utf8mb4_unicode_ci`)
140
-
are already caseinsensitive, as indicated by the `_ci` part in their names.
140
+
are already case-insensitive, as indicated by the `_ci` part in their names.
141
141
142
-
Note: Search filters with the exact strategy can have multiple values for a same property (in this case the condition will be similar to a SQL IN clause).
142
+
Note: Search filters with the `exact` strategy can have multiple values for the same property (in this case the condition will be similar to a SQL IN clause).
143
143
144
144
Syntax: `?property[]=foo&property[]=bar`
145
145
@@ -191,22 +191,22 @@ class Offer
191
191
```
192
192
193
193
With this service definition, it is possible to find all offers belonging to the product identified by a given IRI.
194
-
Try the following: `http://localhost:8000/api/offers?product=/api/products/12`
194
+
Try the following: `http://localhost:8000/api/offers?product=/api/products/12`.
195
195
Using a numeric ID is also supported: `http://localhost:8000/api/offers?product=12`
196
196
197
-
Previous URLs will return all offers for the product having the following IRI as JSON-LD identifier (`@id`): `http://localhost:8000/api/products/12`.
197
+
The above URLs will return all offers for the product having the following IRI as JSON-LD identifier (`@id`): `http://localhost:8000/api/products/12`.
198
198
199
199
### Date Filter
200
200
201
-
The date filter allows for filtering a collection by date intervals.
201
+
The date filter allows to filter a collection by date intervals.
The value can take any date format supported by the [`\DateTime` constructor](http://php.net/manual/en/datetime.construct.php).
206
206
207
207
The `after` and `before` filters will filter including the value whereas `strictly_after` and `strictly_before` will filter excluding the value.
208
208
209
-
As others filters, the date filter must be explicitly enabled:
209
+
Like others filters, the date filter must be explicitly enabled:
210
210
211
211
```php
212
212
<?php
@@ -245,7 +245,7 @@ Consider items as oldest | `ApiPlatform\Core\Bridge\Doctrine\Orm\Fil
245
245
Consider items as youngest | `ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\DateFilter::INCLUDE_NULL_AFTER` (`include_null_after`)
246
246
Always include items | `ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\DateFilter::INCLUDE_NULL_BEFORE_AND_AFTER` (`include_null_before_and_after`)
247
247
248
-
For instance, exclude entries with a property value of `null`, with the following service definition:
248
+
For instance, exclude entries with a property value of `null` with the following service definition:
249
249
250
250
```php
251
251
<?php
@@ -359,15 +359,15 @@ class Offer
359
359
}
360
360
```
361
361
362
-
Given that the collection endpoint is `/offers`, you can filters the price with the following query: `/offers?price[between]=12.99..15.99`.
362
+
Given that the collection endpoint is `/offers`, you can filter the price with the following query: `/offers?price[between]=12.99..15.99`.
363
363
364
364
It will return all offers with `price` between 12.99 and 15.99.
365
365
366
366
You can filter offers by joining two values, for example: `/offers?price[gt]=12.99&price[lt]=19.99`.
367
367
368
368
### Exists Filter
369
369
370
-
The exists filter allows you to select items based on nullable field value.
370
+
The exists filter allows you to select items based on a nullable field value.
371
371
372
372
Syntax: `?property[exists]=<true|false|1|0>`
373
373
@@ -553,9 +553,9 @@ class Offer
553
553
}
554
554
```
555
555
556
-
**Note: Filters on nested properties must still be enabled explicitly, in order to keep things sane**
556
+
**Note: Filters on nested properties must still be enabled explicitly, in order to keep things sane.**
557
557
558
-
Regardless of this option, filters can by applied on a property only if:
558
+
Regardless of this option, filters can be applied on a property only if:
559
559
560
560
* the property exists
561
561
* the value is supported (ex: `asc` or `desc` for the order filters).
@@ -1003,12 +1003,12 @@ class AndOperatorFilterExtension implements RequestBodySearchCollectionExtension
1003
1003
1004
1004
### Using Doctrine ORM Filters
1005
1005
1006
-
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).
1007
-
These are applied on collections and items, so are incredibly useful.
1006
+
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 of the place where the SQL is generated (e.g. from a DQL query, or by loading associated entities).
1007
+
These are applied on collections and items and therefore are incredibly useful.
1008
1008
1009
1009
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/).
1010
1010
1011
-
Suppose we have a `User` entity and an `Order` entity related to the `User` one. A user should only see his orders and no others's ones.
1011
+
Suppose we have a `User` entity and an `Order` entity related to the `User` one. A user should only see his orders and no one else's.
1012
1012
1013
1013
```php
1014
1014
<?php
@@ -1157,7 +1157,7 @@ doctrine:
1157
1157
class: App\Filter\UserFilter
1158
1158
```
1159
1159
1160
-
And add a listener for every request that initializes the Doctrine filter with the current user in your bundle services declaration file.
1160
+
Add a listener for every request that initializes the Doctrine filter with the current user in your bundle services declaration file.
1161
1161
1162
1162
```yaml
1163
1163
# api/config/services.yaml
@@ -1266,13 +1266,13 @@ class DummyCar
1266
1266
1267
1267
```
1268
1268
1269
-
On the first property, `name`, it's straightforward. The first annotation argument is the filter class, the second specifies options, here the strategy:
1269
+
On the first property, `name`, it's straightforward. The first annotation argument is the filter class, the second specifies options, here, the strategy:
The second annotation, we specify `properties` on which the filter should apply. It's necessary here because we don't want to filter `colors` but the property `prop` of the `colors` association.
1275
+
In the second annotation, we specify `properties` on which the filter should apply. It's necessary here because we don't want to filter `colors` but the `prop` property of the `colors` association.
1276
1276
Note that for each given property we specify the strategy:
1277
1277
1278
1278
```
@@ -1314,13 +1314,13 @@ class DummyCar
1314
1314
1315
1315
```
1316
1316
1317
-
The `BooleanFilter` is applied to every `Boolean` property of the class. Indeed, in each core filters we check the Doctrine type. It's written only by using the filter class:
1317
+
The `BooleanFilter` is applied to every `Boolean` property of the class. Indeed, in each core filter we check the Doctrine type. It's written only by using the filter class:
1318
1318
1319
1319
```
1320
1320
@ApiFilter(BooleanFilter::class)
1321
1321
```
1322
1322
1323
-
The `DateFilter` given here will be applied to every `Date` property of the class `DummyCar` with the `DateFilter::EXCLUDE_NULL` strategy:
1323
+
The `DateFilter` given here will be applied to every `Date` property of the `DummyCar` class with the `DateFilter::EXCLUDE_NULL` strategy:
@@ -1334,7 +1334,7 @@ The `SearchFilter` here adds properties. The result is the exact same as the exa
1334
1334
1335
1335
Note that you can specify the `properties` argument on every filter.
1336
1336
1337
-
The next filters are not related to how the data is fetched but rather on the how the serialization is done on those, we can give an `arguments` option ([see here for the available arguments](#serializer-filters)):
1337
+
The next filters are not related to how the data is fetched but rather to how the serialization is done on those. We can give an `arguments` option ([see here for the available arguments](#serializer-filters)):
Copy file name to clipboardExpand all lines: core/getting-started.md
+11-11Lines changed: 11 additions & 11 deletions
Original file line number
Diff line number
Diff line change
@@ -3,18 +3,18 @@
3
3
## Installing API Platform Core
4
4
5
5
If you are starting a new project, the easiest way to get API Platform up is to install the [API Platform Distribution](../distribution/index.md).
6
-
It ships with the API Platform Core library integrated with [the Symfony framework](https://symfony.com), [the schema generator](../schema-generator/),
6
+
It comes 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
9
[Doctrine MongoDB ODM](https://www.doctrine-project.org/projects/mongodb-odm.html) can also be enabled by following the [MongoDB documentation](mongodb.md).
10
10
Basically, it is a Symfony edition packaged with the best tools to develop a REST API and sensible default settings.
11
11
12
-
Alternatively, you can use [Composer](http://getcomposer.org) to install the standalone bundle in an existing Symfony Flex
12
+
Alternatively, you can use [Composer](http://getcomposer.org) to install the stand-alone bundle in an existing Symfony Flex
13
13
project:
14
14
15
15
`composer require api`
16
16
17
-
There is no mandatory configuration options although [many settings are available](configuration.md).
17
+
There are no mandatory configuration options although [many settings are available](configuration.md).
18
18
19
19
## Before Reading this Documentation
20
20
@@ -70,15 +70,15 @@ class Product // The class name will be used to name exposed resources
70
70
71
71
public function __construct()
72
72
{
73
-
$this->offers = new ArrayCollection(); // Initialize $offers as an Doctrine collection
73
+
$this->offers = new ArrayCollection(); // Initialize $offers as a Doctrine collection
74
74
}
75
75
76
76
public function getId(): ?int
77
77
{
78
78
return $this->id;
79
79
}
80
80
81
-
// Adding both an adder and a remover as well as updating the reverse relation are mandatory
81
+
// Adding both an adder and a remover as well as updating the reverse relation is mandatory
82
82
// if you want Doctrine to automatically update and persist (thanks to the "cascade" option) the related entity
83
83
public function addOffer(Offer $offer): void
84
84
{
@@ -147,18 +147,18 @@ web API.
147
147
If you are familiar with the Symfony ecosystem, you noticed that entity classes are also mapped with Doctrine ORM annotations
148
148
and validation constraints from [the Symfony Validator Component](http://symfony.com/doc/current/book/validation.html).
149
149
This isn't mandatory. You can use [your preferred persistence](data-providers.md) and [validation](validation.md) systems.
150
-
However, API Platform Core has built-in support for those library and is able to use them without requiring any specific
151
-
code or configuration to automatically persist and validate your data. They are good default and we encourage you to use
150
+
However, API Platform Core has built-in support for those libraries and is able to use them without requiring any specific
151
+
code or configuration to automatically persist and validate your data. They are a good default option and we encourage you to use
152
152
them unless you know what you are doing.
153
153
154
154
Thanks to the mapping done previously, API Platform Core will automatically register the following REST [operations](operations.md)
Copy file name to clipboardExpand all lines: core/graphql.md
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,7 @@
4
4
5
5
[GraphQL](http://graphql.org/) is a query language made to communicate with an API and therefore is an alternative to REST.
6
6
7
-
It has some advantages compared to REST: it solves the over-fetching or under-fetching of data, is strongly typed, and is capable of retrieving multiple and nested data in one time; but it also comes with drawbacks: for example it creates overhead depending of the request.
7
+
It has some advantages compared to REST: it solves the over-fetching or under-fetching of data, is strongly typed, and is capable of retrieving multiple and nested data in one go, but it also comes with drawbacks. For example it creates overhead depending on the request.
8
8
9
9
API Platform creates a REST API by default. But you can choose to enable GraphQL as well.
0 commit comments