Skip to content

Commit f0c6735

Browse files
committed
fix: lint
1 parent cf24ec5 commit f0c6735

File tree

2 files changed

+36
-36
lines changed

2 files changed

+36
-36
lines changed

core/doctrine-filters.md

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
# Doctrine ORM and MongoDB ODM Filters
22

3+
## Introduction
4+
35
For further documentation on filters (including for Eloquent and Elasticsearch), please see the [Filters documentation](filters.md).
46

57
> [!WARNING]
68
> For maximum flexibility and to ensure future compatibility, it is strongly recommended to configure your filters via
7-
> the parameters attribute using `QueryParameter`. The legacy method using the `ApiFilter` attribute is **deprecated** and
9+
> the parameters attribute using `QueryParameter`. The legacy method using the `ApiFilter` attribute is **deprecated** and
810
> will be **removed** in version **5.0**.
911
1012
The modern way to declare filters is to associate them directly with an operation's parameters. This allows for more
@@ -32,7 +34,7 @@ class Book {
3234
}
3335
```
3436
> [!TIP]
35-
> This filter can be also defined directly on a specific operation like `#[GetCollection(...)])` for finer
37+
> This filter can be also defined directly on a specific operation like `#[GetCollection(...)])` for finer
3638
> control, like the following code:
3739
3840
```php
@@ -179,7 +181,7 @@ services all begin with `api_platform.doctrine_mongodb.odm`.
179181
### Built-in new Search Filters (API Platform >= 4.2)
180182

181183
To add some search filters, choose over this new list:
182-
- [IriFilter](#iri-filter) (filter on IRIs)
184+
- [IriFilter](#iri-filter) (filter on IRIs)
183185
- [ExactFilter](#exact-filter) (filter with exact value)
184186
- [PartialSearchFilter](#partial-search-filter) (filter using a `LIKE %value%``)
185187
- [FreeTextQueryFilter](#free-text-query-filter) (allows you to apply multiple filters to multiple properties of a resource at the same time, using a single parameter in the URL)
@@ -313,7 +315,7 @@ The iri filter allows filtering a resource using IRIs.
313315

314316
Syntax: `?property=value`
315317

316-
The value can take any [IRI(Internationalized Resource Identifier) ](https://en.wikipedia.org/wiki/Internationalized_Resource_Identifier).
318+
The value can take any [IRI(Internationalized Resource Identifier)](https://en.wikipedia.org/wiki/Internationalized_Resource_Identifier).
317319

318320
Like other [new search filters](#built-in-new-search-filters-api-platform--42) it can be used on the ApiResource attribute
319321
or in the operation attribute, for e.g., the `#GetCollection()` attribute:
@@ -486,7 +488,7 @@ Given that the endpoint is `/chickens`, you can filter chickens by name with the
486488
This request will return all chickens where:
487489

488490
- the `name` is exactly "FR123456"
489-
- OR
491+
- OR
490492
- the `ean` is exactly "FR123456".
491493

492494
## Date Filter
@@ -1402,7 +1404,7 @@ Advantages of the new approach:
14021404
- Clarity and Code Quality: The logic is more direct and decoupled.
14031405
- Tooling: A make command is available to generate all the boilerplate code.
14041406

1405-
#### Generating the Filter Skeleton
1407+
#### Generating the Filter ORM Skeleton
14061408

14071409
To get started, API Platform includes a very handy make command to generate the basic structure of an ORM filter:
14081410

@@ -1495,10 +1497,8 @@ class MonthFilter implements FilterInterface
14951497
}
14961498
```
14971499

1498-
Now that the filter is created, it must be associated with an API resource. We use the `#[QueryParameter]` attribute on
1499-
a `GetCollection` operation for this. For other synthax please refer to
1500-
1501-
[//]: # (TODO: add link to synthax)
1500+
Now that the filter is created, it must be associated with an API resource. We use the `#[QueryParameter]` attribute on
1501+
a `GetCollection` operation for this. For other syntax please refer to the [documentation](#introduction).
15021502

15031503
```php
15041504
<?php
@@ -1512,9 +1512,9 @@ use App\Filters\MonthFilter;
15121512
15131513
#[GetCollection(
15141514
parameters: [
1515-
'createdAtMonth' => new QueryParameter(
1516-
filter: new MonthFilter(),
1517-
property: 'createdAt'
1515+
'createdAtMonth' => new QueryParameter(
1516+
filter: new MonthFilter(),
1517+
property: 'createdAt'
15181518
),
15191519
]
15201520
)]
@@ -1527,9 +1527,9 @@ class Invoice
15271527
And that's it! ✅ Your filter is operational. A request like `GET /invoices?createdAtMonth=7` will now correctly return
15281528
the invoices from July!
15291529

1530-
#### Adding Custom Filter Validation And A Better Typing
1530+
#### Adding Custom Filter ORM Validation And A Better Typing
15311531

1532-
Currently, our filter accepts any value, like `createdAtMonth=99` or `createdAtMonth=foo`, which could cause errors.
1532+
Currently, our filter accepts any value, like `createdAtMonth=99` or `createdAtMonth=foo`, which could cause errors.
15331533
To validate inputs and ensure the correct type, we can implement the `JsonSchemaFilterInterface`.
15341534

15351535
This allows delegating validation to API Platform, respecting the [SOLID Principles](https://en.wikipedia.org/wiki/SOLID).
@@ -1550,8 +1550,8 @@ final class MonthFilter implements FilterInterface, JsonSchemaFilterInterface
15501550
public function getSchema(Parameter $parameter): array
15511551
{
15521552
return [
1553-
'type' => 'integer',
1554-
1553+
'type' => 'integer',
1554+
15551555
// <=> Symfony\Component\Validator\Constraints\Range
15561556
'minimum' => 1,
15571557
'maximum' => 12,
@@ -1560,14 +1560,14 @@ final class MonthFilter implements FilterInterface, JsonSchemaFilterInterface
15601560
}
15611561
```
15621562

1563-
With this code, under the hood, API Platform has added a Symfony Range constraint (https://symfony.com/doc/current/reference/constraints/Range.html)
1563+
With this code, under the hood, API Platform has added a [Symfony Range constraint](https://symfony.com/doc/current/reference/constraints/Range.html)
15641564
that only accepts values between `1` and `12` (inclusive), which is what we want. In addition, we map the value to an integer,
15651565
which allows us to reject other types and directly return an integer in our filter when we retrieve the value with
15661566
`$monthValue = $parameter->getValue();`.
15671567

1568-
### Documenting the Filter (OpenAPI)
1568+
### Documenting the ORM Filter (OpenAPI)
15691569

1570-
#### The Simple Method (for scalar types)
1570+
#### The Simple Method (for scalar types) On A Custom ORM Filter
15711571

15721572
If your filter expects a simple type (`int`, `string`, `bool`, or arrays of these types), the quickest way is to use the
15731573
`OpenApiFilterTrait`.
@@ -1593,7 +1593,7 @@ final class MonthFilter implements FilterInterface, JsonSchemaFilterInterface, O
15931593

15941594
That's all! The trait takes care of generating the corresponding OpenAPI documentation. 🚀
15951595

1596-
#### The Custom Method to Documenting the Filter (OpenAPI)
1596+
#### The Custom Method to Documenting the ORM Filter (OpenAPI)
15971597

15981598
If your filter expects more complex data (an object, a specific format), you must implement the `getOpenApiParameters`
15991599
method manually.
@@ -1854,7 +1854,7 @@ Advantages of the new approach:
18541854
- Clarity and Code Quality: The logic is more direct and decoupled.
18551855
- Tooling: A make command is available to generate all the boilerplate code.
18561856

1857-
#### Generating the Filter Skeleton
1857+
#### Generating the Filter ODM Skeleton
18581858

18591859
To get started, API Platform includes a very handy make command to generate the basic structure of an ODM filter:
18601860

@@ -1901,7 +1901,7 @@ class MonthFilter implements FilterInterface
19011901
}
19021902
}
19031903
```
1904-
#### Implementing a Custom Filter
1904+
#### Implementing a Custom ODM Filter
19051905

19061906
Let's create a concrete filter that allows fetching entities based on the month of a date field (e.g., `createdAt`).
19071907

@@ -1962,9 +1962,9 @@ use App\Filters\MonthFilter;
19621962
19631963
#[GetCollection(
19641964
parameters: [
1965-
'createdAtMonth' => new QueryParameter(
1966-
filter: new MonthFilter(),
1967-
property: 'createdAt'
1965+
'createdAtMonth' => new QueryParameter(
1966+
filter: new MonthFilter(),
1967+
property: 'createdAt'
19681968
),
19691969
]
19701970
)]
@@ -1977,7 +1977,7 @@ class Invoice
19771977
And that's it! ✅ Your filter is operational. A request like `GET /invoices?createdAtMonth=7` will now correctly return
19781978
the invoices from July!
19791979

1980-
#### Adding Custom Filter Validation And A Better Typing
1980+
#### Adding Custom Filter ODM Validation And A Better Typing
19811981

19821982
Currently, our filter accepts any value, like `createdAtMonth=99` or `createdAtMonth=foo`, which could cause errors.
19831983
To validate inputs and ensure the correct type, we can implement the `JsonSchemaFilterInterface`.
@@ -2000,8 +2000,8 @@ final class MonthFilter implements FilterInterface, JsonSchemaFilterInterface
20002000
public function getSchema(Parameter $parameter): array
20012001
{
20022002
return [
2003-
'type' => 'integer',
2004-
2003+
'type' => 'integer',
2004+
20052005
// <=> Symfony\Component\Validator\Constraints\Range
20062006
'minimum' => 1,
20072007
'maximum' => 12,
@@ -2010,14 +2010,14 @@ final class MonthFilter implements FilterInterface, JsonSchemaFilterInterface
20102010
}
20112011
```
20122012

2013-
With this code, under the hood, API Platform has added a Symfony Range constraint (https://symfony.com/doc/current/reference/constraints/Range.html)
2013+
With this code, under the hood, API Platform has added a [Symfony Range constraint](https://symfony.com/doc/current/reference/constraints/Range.html)
20142014
that only accepts values between `1` and `12` (inclusive), which is what we want. In addition, we map the value to an integer,
20152015
which allows us to reject other types and directly return an integer in our filter when we retrieve the value with
20162016
`$monthValue = $parameter->getValue();`.
20172017

2018-
### Documenting the Filter (OpenAPI)
2018+
### Documenting the ODM Filter (OpenAPI)
20192019

2020-
#### The Simple Method (for scalar types)
2020+
#### The Simple Method (for scalar types) On A Custom ODM Filter
20212021

20222022
If your filter expects a simple type (`int`, `string`, `bool`, or arrays of these types), the quickest way is to use the
20232023
`OpenApiFilterTrait`.
@@ -2043,7 +2043,7 @@ final class MonthFilter implements FilterInterface, JsonSchemaFilterInterface, O
20432043

20442044
That's all! The trait takes care of generating the corresponding OpenAPI documentation. 🚀
20452045

2046-
#### The Custom Method to Documenting the Filter (OpenAPI)
2046+
#### The Custom Method to Documenting the Filter (OpenAPI) On A Custom ODM Filter
20472047

20482048
If your filter expects more complex data (an object, a specific format), you must implement the `getOpenApiParameters`
20492049
method manually.

laravel/filters.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ Given that the collection endpoint is `/books`, you can filter the serialization
284284

285285
### Creating Custom Filters (API Platform >= 4.2)
286286

287-
#### Generating the Filter Skeleton
287+
#### Generating the Laravel Eloquent Filter Skeleton
288288

289289
To get started, API Platform includes a very handy make command to generate the basic structure of an Laravel Eloquent filter:
290290

@@ -327,7 +327,7 @@ final class MonthFilter implements FilterInterface
327327
}
328328
```
329329

330-
#### Implementing a Custom Filter
330+
#### Implementing a Custom Laravel Eloquent Filter
331331

332332
Let's create a concrete filter that allows fetching entities based on the month of a date field (e.g., `createdAt`).
333333

@@ -360,7 +360,7 @@ final class MonthFilter implements FilterInterface
360360
}
361361
}
362362
```
363-
363+
364364
We can now use it in our resources and model like other filters, for example, as follows:
365365
```php
366366
<?php

0 commit comments

Comments
 (0)