Skip to content

Commit 9ef4e12

Browse files
committed
Merge branch '2.5'
* 2.5: update default branch references update supported branches Update operations.md (#1253) Update elasticsearch.md (#1204) Use int type instead of integer deprecated type (#1252)
2 parents abc94b9 + 2f01186 commit 9ef4e12

16 files changed

+76
-26
lines changed

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
33
If your pull request fixes a BUG, use the last stable branch that contains the bug.
44
5-
If your pull request documents a NEW FEATURE, use the `master` branch.
5+
If your pull request documents a NEW FEATURE, use the `main` branch.
66
77
Versions and branches are described there: https://api-platform.com/docs/extra/releases/
88

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,4 @@ deploy:
3737
fqdn: api-platform.com
3838
on:
3939
all_branches: true
40-
condition: $TRAVIS_BRANCH =~ ^(master|2.5|2.4|2.3|2.2|2.1)$
40+
condition: $TRAVIS_BRANCH =~ ^(main|2.6|2.5|2.4|2.3|2.2|2.1)$

core/content-negotiation.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ Format | Format name |
3333
If the client's requested format is not specified, the response format will be the first format defined in the `formats` configuration key (see below).
3434
If the request format is not supported, an [Unsupported Media Type](https://developer.mozilla.org/fr/docs/Web/HTTP/Status/415) error will be returned.
3535

36-
Examples showcasing how to use the different mechanisms are available [in the API Platform test suite](https://github.com/api-platform/core/blob/master/features/main/content_negotiation.feature).
36+
Examples showcasing how to use the different mechanisms are available [in the API Platform test suite](https://github.com/api-platform/core/blob/main/features/main/content_negotiation.feature).
3737

3838
## Configuring Formats Globally
3939

core/data-persisters.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ persist data for a given resource will be used.
2222

2323
## Creating a Custom Data Persister
2424

25-
To create a data persister, you have to implement the [`ContextAwareDataPersisterInterface`](https://github.com/api-platform/core/blob/master/src/DataPersister/ContextAwareDataPersisterInterface.php).
25+
To create a data persister, you have to implement the [`ContextAwareDataPersisterInterface`](https://github.com/api-platform/core/blob/main/src/DataPersister/ContextAwareDataPersisterInterface.php).
2626
This interface defines only 3 methods:
2727

2828
* `persist`: to create or update the given data
@@ -71,7 +71,7 @@ services:
7171
#tags: [ 'api_platform.data_persister' ]
7272
```
7373

74-
Note that if you don't need any `$context` in your data persister's methods, you can implement the [`DataPersisterInterface`](https://github.com/api-platform/core/blob/master/src/DataPersister/DataPersisterInterface.php) instead.
74+
Note that if you don't need any `$context` in your data persister's methods, you can implement the [`DataPersisterInterface`](https://github.com/api-platform/core/blob/main/src/DataPersister/DataPersisterInterface.php) instead.
7575

7676
## Decorating the Built-In Data Persisters
7777

core/data-providers.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,23 +13,23 @@ retrieve data for a given resource will be used.
1313

1414
For a given resource, you can implement two kinds of interface:
1515

16-
* the [`CollectionDataProviderInterface`](https://github.com/api-platform/core/blob/master/src/DataProvider/CollectionDataProviderInterface.php)
16+
* the [`CollectionDataProviderInterface`](https://github.com/api-platform/core/blob/main/src/DataProvider/CollectionDataProviderInterface.php)
1717
is used when fetching a collection.
18-
* the [`ItemDataProviderInterface`](https://github.com/api-platform/core/blob/master/src/DataProvider/ItemDataProviderInterface.php)
18+
* the [`ItemDataProviderInterface`](https://github.com/api-platform/core/blob/main/src/DataProvider/ItemDataProviderInterface.php)
1919
is used when fetching items.
2020

2121
Both implementations can also implement a third, optional, interface called
22-
['RestrictedDataProviderInterface'](https://github.com/api-platform/core/blob/master/src/DataProvider/RestrictedDataProviderInterface.php)
22+
['RestrictedDataProviderInterface'](https://github.com/api-platform/core/blob/main/src/DataProvider/RestrictedDataProviderInterface.php)
2323
if you want to limit their effects to a single resource or operation.
2424

2525
In the following examples we will create custom data providers for an entity class called `App\Entity\BlogPost`.
2626
Note, that if your entity is not Doctrine-related, you need to flag the identifier property by using `@ApiProperty(identifier=true)` for things to work properly (see also [Entity Identifier Case](serialization.md#entity-identifier-case)).
2727

2828
## Custom Collection Data Provider
2929

30-
First, your `BlogPostCollectionDataProvider` has to implement the [`CollectionDataProviderInterface`](https://github.com/api-platform/core/blob/master/src/DataProvider/CollectionDataProviderInterface.php):
30+
First, your `BlogPostCollectionDataProvider` has to implement the [`CollectionDataProviderInterface`](https://github.com/api-platform/core/blob/main/src/DataProvider/CollectionDataProviderInterface.php):
3131

32-
The `getCollection` method must return an `array`, a `Traversable` or a [`ApiPlatform\Core\DataProvider\PaginatorInterface`](https://github.com/api-platform/core/blob/master/src/DataProvider/PaginatorInterface.php) instance.
32+
The `getCollection` method must return an `array`, a `Traversable` or a [`ApiPlatform\Core\DataProvider\PaginatorInterface`](https://github.com/api-platform/core/blob/main/src/DataProvider/PaginatorInterface.php) instance.
3333
If no data is available, you should return an empty array.
3434

3535
```php
@@ -75,11 +75,11 @@ Tagging the service with the tag `api_platform.collection_data_provider` will en
7575
register and use this data provider. The optional attribute `priority` allows you to define the order in which the
7676
data providers are called. Implementing the `ApiPlatform\Core\DataProvider\RestrictedDataProviderInterface` let you restrict the data provider use. Alternatively, you can also throw a `ApiPlatform\Core\Exception\ResourceClassNotSupportedException`. Without the `RestrictedDataProviderInterface`, the first data provider not throwing this exception will be used.
7777

78-
You can find a full working example in the [API Platform's demo application](https://github.com/api-platform/demo/blob/master/api/src/DataProvider/TopBookCollectionDataProvider.php).
78+
You can find a full working example in the [API Platform's demo application](https://github.com/api-platform/demo/blob/main/api/src/DataProvider/TopBookCollectionDataProvider.php).
7979

8080
## Custom Item Data Provider
8181

82-
The process is similar for item data providers. Create a `BlogPostItemDataProvider` implementing the [`ItemDataProviderInterface`](https://github.com/api-platform/core/blob/master/src/DataProvider/ItemDataProviderInterface.php)
82+
The process is similar for item data providers. Create a `BlogPostItemDataProvider` implementing the [`ItemDataProviderInterface`](https://github.com/api-platform/core/blob/main/src/DataProvider/ItemDataProviderInterface.php)
8383
interface:
8484

8585
The `getItem` method can return `null` if no result has been found.
@@ -124,7 +124,7 @@ services:
124124
#tags: [ 'api_platform.item_data_provider' ]
125125
```
126126

127-
You can find a full working example in the [API Platform's demo application](https://github.com/api-platform/demo/blob/master/api/src/DataProvider/TopBookItemDataProvider.php).
127+
You can find a full working example in the [API Platform's demo application](https://github.com/api-platform/demo/blob/main/api/src/DataProvider/TopBookItemDataProvider.php).
128128

129129
## Injecting the Serializer in an `ItemDataProvider`
130130

core/elasticsearch.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ API Platform follows the best practices of Elasticsearch:
4444
index](https://www.elastic.co/guide/en/elasticsearch/reference/current/removal-of-types.html);
4545
* index name should be the short resource name in lower snake case;
4646
* the default `_doc` type should be used;
47-
* all fields should be lower case and should use snake case for combining words.
47+
* all fields should be lower case and should use camel case for combining words.
4848

4949
This involves having mappings and models which absolutely match each other.
5050

core/events.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ Attribute | Type | Default | Description
5959

6060
Registering your own event listeners to add extra logic is convenient.
6161

62-
The [`ApiPlatform\Core\EventListener\EventPriorities`](https://github.com/api-platform/core/blob/master/src/EventListener/EventPriorities.php) class comes with a convenient set of class constants corresponding to commonly used priorities:
62+
The [`ApiPlatform\Core\EventListener\EventPriorities`](https://github.com/api-platform/core/blob/main/src/EventListener/EventPriorities.php) class comes with a convenient set of class constants corresponding to commonly used priorities:
6363

6464
Constant | Event | Priority |
6565
-------------------|-------------------|----------|

core/getting-started.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,4 +230,4 @@ Run the Symfony app with the [Symfony Local Web Server](https://symfony.com/doc/
230230

231231
Interact with the API using a REST client (we recommend [Postman](https://www.getpostman.com/)) or an Hydra-aware application
232232
(you should give [Hydra Console](https://github.com/lanthaler/HydraConsole) a try). Take
233-
a look at the usage examples in [the `features` directory](https://github.com/api-platform/core/tree/master/features).
233+
a look at the usage examples in [the `features` directory](https://github.com/api-platform/core/tree/main/features).

core/identifiers.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,5 +177,5 @@ final class Person
177177
API Platform supports the following identifier types:
178178

179179
- `scalar` (string, integer)
180-
- `\DateTime` (uses the symfony `DateTimeNormalizer` internally, see [DateTimeIdentifierNormalizer](https://github.com/api-platform/core/blob/master/src/Identifier/Normalizer/DateTimeIdentifierDenormalizer.php))
181-
- `\Ramsey\Uuid\Uuid` (see [UuidNormalizer](https://github.com/api-platform/core/blob/master/src/Bridge/RamseyUuid/Identifier/Normalizer/UuidNormalizer.php))
180+
- `\DateTime` (uses the symfony `DateTimeNormalizer` internally, see [DateTimeIdentifierNormalizer](https://github.com/api-platform/core/blob/main/src/Identifier/Normalizer/DateTimeIdentifierDenormalizer.php))
181+
- `\Ramsey\Uuid\Uuid` (see [UuidNormalizer](https://github.com/api-platform/core/blob/main/src/Bridge/RamseyUuid/Identifier/Normalizer/UuidNormalizer.php))

core/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ Here is the fully featured REST API you'll get in minutes:
3838

3939
Everything is fully customizable through a powerful [event system](events.md) and strong OOP.
4040

41-
This bundle is extensively tested (unit and functional). The [`Fixtures/` directory](https://github.com/api-platform/core/tree/master/tests/Fixtures) contains a working app covering all features of the library.
41+
This bundle is extensively tested (unit and functional). The [`Fixtures/` directory](https://github.com/api-platform/core/tree/main/tests/Fixtures) contains a working app covering all features of the library.
4242

4343
## Screencasts
4444

core/mongodb.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ use Symfony\Component\Validator\Constraints as Assert;
111111
class Product
112112
{
113113
/**
114-
* @ODM\Id(strategy="INCREMENT", type="integer")
114+
* @ODM\Id(strategy="INCREMENT", type="int")
115115
*/
116116
private $id;
117117

@@ -170,7 +170,7 @@ use Symfony\Component\Validator\Constraints as Assert;
170170
class Offer
171171
{
172172
/**
173-
* @ODM\Id(strategy="INCREMENT", type="integer")
173+
* @ODM\Id(strategy="INCREMENT", type="int")
174174
*/
175175
private $id;
176176

core/openapi.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,7 @@ As described [in the Symfony documentation](https://symfony.com/doc/current/temp
442442
</html>
443443
```
444444

445-
You may want to copy the [one shipped with API Platform](https://github.com/api-platform/core/blob/master/src/Bridge/Symfony/Bundle/Resources/views/SwaggerUi/index.html.twig) and customize it.
445+
You may want to copy the [one shipped with API Platform](https://github.com/api-platform/core/blob/main/src/Bridge/Symfony/Bundle/Resources/views/SwaggerUi/index.html.twig) and customize it.
446446

447447
## Compatibility Layer with Amazon API Gateway
448448

core/operation-path-naming.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ Let's assume we need URLs without separators (e.g. `api.tld/myresources`)
2727

2828
### Defining the Operation Segment Name Generator
2929

30-
Make sure the custom segment generator implements [`ApiPlatform\Core\Operation\PathSegmentNameGeneratorInterface`](https://github.com/api-platform/core/blob/master/src/Operation/PathSegmentNameGeneratorInterface.php):
30+
Make sure the custom segment generator implements [`ApiPlatform\Core\Operation\PathSegmentNameGeneratorInterface`](https://github.com/api-platform/core/blob/main/src/Operation/PathSegmentNameGeneratorInterface.php):
3131

3232
```php
3333
<?php

core/operations.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,56 @@ App\Entity\Book:
167167
```
168168
[/codeSelector]
169169

170+
You can also disable all operations for an item or a collection. This example disables every item-related routes (PUT, GET, DELETE):
171+
172+
[codeSelector]
173+
```php
174+
<?php
175+
// api/src/Entity/Book.php
176+
177+
namespace App\Entity;
178+
179+
use ApiPlatform\Core\Annotation\ApiResource;
180+
181+
/**
182+
* ...
183+
* @ApiResource(
184+
* collectionOperations={"get"},
185+
* itemOperations={}
186+
* )
187+
*/
188+
class Book
189+
{
190+
// ...
191+
}
192+
```
193+
194+
```yaml
195+
# api/config/api_platform/resources.yaml
196+
App\Entity\Book:
197+
collectionOperations:
198+
get: ~ # nothing more to add if we want to keep the default controller
199+
itemOperations: []
200+
```
201+
202+
```xml
203+
<?xml version="1.0" encoding="UTF-8" ?>
204+
<!-- api/config/api_platform/resources.xml -->
205+
206+
<resources xmlns="https://api-platform.com/schema/metadata"
207+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
208+
xsi:schemaLocation="https://api-platform.com/schema/metadata
209+
https://api-platform.com/schema/metadata/metadata-2.0.xsd">
210+
<resource class="App\Entity\Book">
211+
<collectionOperations>
212+
<collectionOperation name="get" />
213+
</collectionOperations>
214+
<itemOperations />
215+
</resource>
216+
</resources>
217+
```
218+
[/codeSelector]
219+
170220
API Platform Core is smart enough to automatically register the applicable Symfony route referencing a built-in CRUD action
171221
just by specifying the method name as key, or by checking the explicitly configured HTTP method.
172222

core/pagination.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@ To know more about cursor-based pagination take a look at [this blog post on med
359359

360360
## Controlling the behavior of the Doctrine ORM Paginator
361361

362-
The [PaginationExtension](https://github.com/api-platform/core/blob/master/src/Bridge/Doctrine/Orm/Extension/PaginationExtension.php) of API Platform performs some checks on the `QueryBuilder` to guess, in most common cases, the correct values to use when configuring the Doctrine ORM Paginator:
362+
The [PaginationExtension](https://github.com/api-platform/core/blob/main/src/Bridge/Doctrine/Orm/Extension/PaginationExtension.php) of API Platform performs some checks on the `QueryBuilder` to guess, in most common cases, the correct values to use when configuring the Doctrine ORM Paginator:
363363

364364
- `$fetchJoinCollection` argument: Whether there is a join to a collection-valued association. When set to `true`, the Doctrine ORM Paginator will perform an additional query, in order to get the correct number of results.
365365

extra/contribution-guides.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Contribution guides
22

3-
1. [API Platform Core Library](https://github.com/api-platform/core/blob/master/CONTRIBUTING.md)
4-
2. [API Platform Schema Generator](https://github.com/api-platform/schema-generator/blob/master/CONTRIBUTING.md)
3+
1. [API Platform Core Library](https://github.com/api-platform/core/blob/main/CONTRIBUTING.md)
4+
2. [API Platform Schema Generator](https://github.com/api-platform/schema-generator/blob/main/CONTRIBUTING.md)
55
3. [API Platform Admin](https://github.com/api-platform/admin/blob/master/CONTRIBUTING.md)
66
4. [API Platform CRUD Generator](https://github.com/api-platform/client-generator/blob/master/CONTRIBUTING.md)
77

0 commit comments

Comments
 (0)