Skip to content

chore: merge 2.6 #1391

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 53 commits into from
Jun 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
9527ec5
Complete example for Messenger with persistence (#1293)
andreystavitsky Feb 23, 2021
5fb5b7d
Update path to pwa/Dockerfile (#1294)
HugoFerrant Feb 23, 2021
c607d13
Correct the subresourceOperations php8 attribute (#1295)
Oipnet Feb 24, 2021
e37294a
We need to specify the generator because the default is Next. (#1296)
amouhzi Feb 27, 2021
b93eb7c
Use Php8 attributes in validation.md (#1302)
Oipnet Mar 1, 2021
d348e48
Use PHP 8 Attributes in graphql.md (#1301)
Oipnet Mar 1, 2021
b5a5443
Use the “auto” password encoder and fix typos (#1308)
samnela Mar 4, 2021
8854806
fix ArrayObject -> \ArrayObject (#1312)
dgfmdrv Mar 8, 2021
71d5eff
Update troubleshooting.md (#1311)
HugoFerrant Mar 16, 2021
1b1ec1d
Add a partial pagination section (#1316)
alanpoulain Mar 18, 2021
616f454
Fix typo (#1318)
samnela Mar 22, 2021
23c4f49
Add missing closing ) in annotations (#1320)
LeoBenoist Mar 22, 2021
9f6eba2
Fixes typo in ApiFilter Annotation (#1322)
theZieger Mar 23, 2021
72f4135
Add a note for user installing api platform with symfony flex (#1321)
louis-cuny Mar 23, 2021
b9e0ba8
Fix sintax error missing ] (#1327)
niccolopetti Mar 28, 2021
435ca9a
Replace has_role with is_granted (#1328)
jmontoyaa Mar 29, 2021
b920ea9
Add tag to JWT Token Operation (#1324)
lubo13 Mar 30, 2021
dfb5ef6
Update debugging.md (#1323)
brettins Mar 30, 2021
ad8b2f1
Updated Mac env setting names for Xdebug v3 (#1331)
rettal Mar 31, 2021
50aade5
add a deploy on Minikube entry (#1315)
dunglas Apr 7, 2021
9cd2293
Update docs with OpenApiFactoryInterface. (#1342)
alexsegura Apr 8, 2021
b626ac9
Replace event subscriber with normalizer for resolving file url of me…
Apr 8, 2021
b596c79
Update file-upload.md (#1345)
brettins Apr 10, 2021
2ec80b3
Update file-upload.md (#1346)
brettins Apr 12, 2021
a87a2d3
correction in PHP code (#1348)
dgoosens Apr 14, 2021
9b049f4
Update graphql.md (#1347)
brettins Apr 14, 2021
76d6984
Fix #1330: update doc about errors handled by API Platform only on re…
vincentchalamon Apr 27, 2021
f2024a5
Add a note about client generator from distribution (#1350)
vincentchalamon Apr 27, 2021
0a5d9fb
Fix rdfa => vocabularies change in documentation (#1352)
florent-andre Apr 27, 2021
74df760
Fix case on "PLatform" (#1353)
alexislefebvre Apr 27, 2021
8cd89d0
docs: fixes to Content Negotiation / Serialization (#1357)
jamesisaac May 8, 2021
d2a328b
feat: Add documentation to test file uploads (#1362)
artandor May 13, 2021
5e67f43
docs: add missing yaml identifiers documentation (#1365)
johnkrovitch May 25, 2021
7437c79
docs: add missing security yaml documentation (#1367)
johnkrovitch May 26, 2021
2f3f454
docs: use blackfire v2 (#1369)
lobodol May 27, 2021
0c2bc58
docs: replace deprecated assertRegExp (#1374)
jmontoyaa Jun 8, 2021
e633059
docs: add missing yaml example in the filters documentation (#1364)
johnkrovitch Jun 8, 2021
a233c75
feat: add URL generation strategy documentation (#1377)
alanpoulain Jun 14, 2021
599ae03
fix: use pagination_maximum_items_per_page instead of maximum_items_p…
alanpoulain Jun 15, 2021
f6fddb9
feat(serialization): describe property context (#1379)
alanpoulain Jun 15, 2021
6df35b9
docs: always use the latest version of the images (#1380)
dunglas Jun 16, 2021
abbe762
fix: change the service name (#1381)
samnela Jun 17, 2021
c3d4e1d
feat: file upload in an existing resource (#1385)
alanpoulain Jun 21, 2021
af4da3a
docs: change fakerPHP repository link (#1388)
djpremier Jun 22, 2021
7c1d753
docs: add missing serialization yaml documentation (#1370)
johnkrovitch Jun 23, 2021
7ea43d9
docs: add missing yaml documentation in the default order section (#1…
johnkrovitch Jun 23, 2021
f333812
docs: add YAML notation for single property deprecation (#1382)
jzabrodin Jun 23, 2021
d72bbaa
docs: add notice about disableReboot in tests with multiple requests …
carlobeltrame Jun 23, 2021
e75c656
docs(errors): document the different behaviour depending on status co…
odoucet Jun 23, 2021
1081cb4
docs: use attributes in controllers page (#1389)
alanpoulain Jun 23, 2021
6608635
fix: clarify __invoke distinction (#1358)
botris Jun 23, 2021
2a711d9
docs(filters): remove global order_nulls_comparison (available only i…
alanpoulain Jun 23, 2021
1afb843
Merge branch '2.6' into merge-2.6
alanpoulain Jun 23, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion client-generator/nextjs.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,10 @@ Install required dependencies:

$ npx @api-platform/client-generator https://demo.api-platform.com . --generator next --resource book
# Replace the URL by the entrypoint of your Hydra-enabled API
# Omit the resource flag to generate files for all resource types exposed by the API.

> Note: Omit the resource flag to generate files for all resource types exposed by the API.
> Note: On the [API Platform distribution](https://github.com/api-platform/api-platform), you can run
> `generate-api-platform-client` instead of `npx @api-platform/client-generator`.

## Starting the Project

Expand Down
2 changes: 1 addition & 1 deletion client-generator/react.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ Omit the resource flag to generate files for all resource types exposed by the A
If you don't use the standalone installation, run the following command instead:

```console
npx @api-platform/client-generator https://demo.api-platform.com src/ --resource book
npx @api-platform/client-generator https://demo.api-platform.com src/ --resource book -g react
```

Replace the URL with the entrypoint of your Hydra-enabled API.
Expand Down
4 changes: 4 additions & 0 deletions client-generator/troubleshooting.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,7 @@ cause: null } }
Check access to the specified URL, in this case `https://demo.api-platform.com/contexts/Entrypoint`, use curl to check
access and the response `curl https://demo.api-platform.com/contexts/Entrypoint`. In the above case an "Access Denied"
message in JSON format was being returned.

## Docker distribution on Windows and hot-reloading

Due to [a long-time known Docker for Windows issue](https://forums.docker.com/t/file-system-watch-does-not-work-with-mounted-volumes/12038), the files changes on the host are not notified on the `pwa` container. It causes the hot-reloading feature to not working properly for Windows users.
2 changes: 1 addition & 1 deletion client-generator/vuetify.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## Install with Docker

If you use the API Platform distribution with docker, first you have to add the [Vue CLI](https://cli.vuejs.org/guide/) to the `yarn global add` command in `client/Dockerfile`:
If you use the API Platform distribution with docker, first you have to add the [Vue CLI](https://cli.vuejs.org/guide/) to the `yarn global add` command in `pwa/Dockerfile`:

```dockerfile
RUN yarn global add @api-platform/client-generator @vue/cli @vue/cli-service-global
Expand Down
3 changes: 1 addition & 2 deletions core/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -425,8 +425,7 @@ api_platform:
stateless: ~

# The URL generation strategy to use for IRIs
# Use values from UrlGeneratorInterface
url_generation_strategy: ~
url_generation_strategy: !php/const ApiPlatform\Core\Api\UrlGeneratorInterface::ABS_PATH

# ...
```
3 changes: 2 additions & 1 deletion core/content-negotiation.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

The API system has built-in [content negotiation](https://en.wikipedia.org/wiki/Content_negotiation) capabilities.

By default, only the [JSON-LD](https://json-ld.org) format is enabled. However API Platform Core supports many more formats and can be extended.
By default, only the [JSON-LD](https://json-ld.org) and JSON formats are enabled. However API Platform Core supports many more formats and can be extended.

The framework natively supports JSON-LD (and Hydra), GraphQL, JSON:API, HAL, YAML, CSV, HTML (API docs), raw JSON and raw XML.
Using the raw JSON or raw XML formats is discouraged, prefer using JSON-LD instead, which provides more feature and is as easy to use.
Expand Down Expand Up @@ -52,6 +52,7 @@ api_platform:
yaml: ['application/x-yaml']
csv: ['text/csv']
html: ['text/html']
myformat: ['application/vnd.myformat']
```

To enable GraphQL support, [read the dedicated chapter](graphql.md).
Expand Down
98 changes: 48 additions & 50 deletions core/controllers.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,11 @@ First, let's create your custom operation:
namespace App\Controller;

use App\Entity\Book;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpKernel\Attribute\AsController;

class CreateBookPublication
#[AsController]
class CreateBookPublication extends AbstractController
{
private $bookPublishingHandler;

Expand Down Expand Up @@ -98,10 +101,10 @@ use App\Controller\CreateBookPublication;
'path' => '/books/{id}/publication',
'controller' => CreateBookPublication::class,
],
])
])]
class Book
{
//...
// ...
}
```

Expand Down Expand Up @@ -157,24 +160,20 @@ use ApiPlatform\Core\Annotation\ApiResource;
use App\Controller\CreateBookPublication;
use Symfony\Component\Serializer\Annotation\Groups;

/**
* @ApiResource(itemOperations={
* "get",
* "post_publication"={
* "method"="POST",
* "path"="/books/{id}/publication",
* "controller"=CreateBookPublication::class,
* "normalization_context"={"groups"={"publication"}},
* }
* })
*/
#[ApiResource(itemOperations: [
'get',
'post_publication' => [
'method' => 'POST',
'path' => '/books/{id}/publication',
'controller' => CreateBookPublication::class,
'normalization_context' => ['groups' => 'publication'],
],
])]
class Book
{
//...
// ...

/**
* @Groups("publication")
*/
#[Groups(['publication'])]
public $isbn;

// ...
Expand Down Expand Up @@ -236,20 +235,18 @@ operation attribute:
use ApiPlatform\Core\Annotation\ApiResource;
use App\Controller\CreateBookPublication;

/**
* @ApiResource(itemOperations={
* "get",
* "post_publication"={
* "method"="POST",
* "path"="/books/{id}/publication",
* "controller"=CreateBookPublication::class,
* "read"=false,
* }
* })
*/
#[ApiResource(itemOperations: [
'get',
'post_publication' => [
'method' => 'POST',
'path' => '/books/{id}/publication',
'controller' => CreateBookPublication::class,
'read' => false,
],
])]
class Book
{
//...
// ...
}
```

Expand Down Expand Up @@ -312,16 +309,14 @@ First, let's create your resource configuration:

use ApiPlatform\Core\Annotation\ApiResource;

/**
* @ApiResource(itemOperations={
* "get",
* "post_publication"={"route_name"="book_post_publication"},
* "book_post_discontinuation",
* })
*/
#[ApiResource(itemOperations: [
'get',
'post_publication' => ['route_name' => 'book_post_publication'],
'book_post_discontinuation',
])]
class Book
{
//...
// ...
}
```

Expand Down Expand Up @@ -367,9 +362,12 @@ and its related route using annotations:
namespace App\Controller;

use App\Entity\Book;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpKernel\Attribute\AsController;
use Symfony\Component\Routing\Annotation\Route;

class CreateBookPublication
#[AsController]
class CreateBookPublication extends AbstractController
{
private $bookPublishingHandler;

Expand All @@ -378,17 +376,15 @@ class CreateBookPublication
$this->bookPublishingHandler = $bookPublishingHandler;
}

/**
* @Route(
* name="book_post_publication",
* path="/books/{id}/publication",
* methods={"POST"},
* defaults={
* "_api_resource_class"=Book::class,
* "_api_item_operation_name"="post_publication"
* }
* )
*/
#[Route(
name: 'book_post_publication',
path: '/books/{id}/publication',
methods: ['POST'],
defaults: [
'_api_resource_class' => Book::class,
'_api_item_operation_name' => 'post_publication',
],
)]
public function __invoke(Book $book): Book
{
$this->bookPublishingHandler->handle($book);
Expand All @@ -412,7 +408,9 @@ namespace App\Controller;

use App\Entity\Book;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpKernel\Attribute\AsController;

#[AsController]
class BookController extends AbstractController
{
public function createPublication(Book $book, BookPublishingHandler $bookPublishingHandler): Book
Expand Down
53 changes: 51 additions & 2 deletions core/data-persisters.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ services:

## Calling multiple DataPersisters

Our DataPersisters are called in chain, once a data persister is supported the chain breaks and API Platform assumes your data is persisted. You can call mutliple data persisters by implementing the `ResumableDataPersisterInterface`:
Our DataPersisters are called in chain, once a data persister is supported the chain breaks and API Platform assumes your data is persisted. You can call multiple data persisters by implementing the `ResumableDataPersisterInterface`:

```php
namespace App\DataPersister;
Expand Down Expand Up @@ -189,4 +189,53 @@ final class BlogPostDataPersister implements ContextAwareDataPersisterInterface,
}
```

This is very useful when using [`Messenger` with API Platform](messenger.md) as you may want to do something asynchronously with the data but still call the default Doctrine data persister.
This is very useful when using [`Messenger` with API Platform](messenger.md) as you may want to do something asynchronously with the data but still call the default Doctrine data persister, for example:
```php
namespace App\DataPersister;

use ApiPlatform\Core\DataPersister\ContextAwareDataPersisterInterface;
use Doctrine\ORM\EntityManagerInterface;
use App\Entity\BlogPost;

final class BlogPostDataPersister implements ContextAwareDataPersisterInterface, ResumableDataPersisterInterface
{
private $entityManager;

public function __construct(EntityManagerInterface $entityManager)
{
$this->entityManager = $entityManager;
}

public function supports($data, array $context = []): bool
{
return $data instanceof BlogPost;
}

public function persist($data, array $context = [])
{
$this->entityManager->persist($data);
$this->entityManager->flush();
}

public function remove($data, array $context = [])
{
$this->entityManager->remove($data);
$this->entityManager->flush();
}

// Once called this data persister will resume to the next one
public function resumable(array $context = []): bool
{
return true;
}
}
```
```yaml
# api/config/services.yaml
services:
# ...
App\DataPersister\BlogPostDataPersister: ~
# Uncomment only if autoconfiguration is disabled
#arguments: ['@App\DataPersister\BlogPostDataPersister.inner']
#tags: [ 'api_platform.data_persister' ]
```
54 changes: 54 additions & 0 deletions core/default-order.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ API Platform Core provides an easy way to override the default order of items in
By default, items in the collection are ordered in ascending (ASC) order by their resource identifier(s). If you want to
customize this order, you must add an `order` attribute on your ApiResource annotation:

[codeSelector]

```php
<?php
// api/src/Entity/Book.php
Expand All @@ -28,9 +30,21 @@ class Book
}
```

```yaml
# api/config/api_platform/resources/Book.yaml
App\Entity\Book:
attributes:
order:
foo: ASC
```

[/codeSelector]

This `order` attribute is used as an array: the key defines the order field, the values defines the direction.
If you only specify the key, `ASC` direction will be used as default. For example, to order by `foo` & `bar`:

[codeSelector]

```php
<?php
// api/src/Entity/Book.php
Expand Down Expand Up @@ -59,8 +73,19 @@ class Book
}
```

```yaml
# api/config/api_platform/resources/Book.yaml
App\Entity\Book:
attributes:
order: ['foo', 'bar']
```

[/codeSelector]

It's also possible to configure the default order on an association property:

[codeSelector]

```php
<?php
// api/src/Entity/Book.php
Expand All @@ -84,8 +109,19 @@ class Book
}
```

```yaml
# api/config/api_platform/resources/Book.yaml
App\Entity\Book:
attributes:
order: ['author.username']
```

[/codeSelector]

Another possibility is to apply the default order for a specific collection operation, which will override the global default order configuration.

[codeSelector]

```php
/**
* collectionOperations={
Expand All @@ -106,3 +142,21 @@ class Book
// ...
}
```

```yaml
# api/config/api_platform/resources/Book.yaml
App\Entity\Book:
get: ~
get_desc_custom:
method: get
path: custom_collection_desc_foos
order:
name: DESC
get_asc_custom:
method: get
path: custom_collection_asc_foos
order:
name: ASC
```

[/codeSelector]
Loading