Skip to content

Commit 9bb4738

Browse files
committed
lint
1 parent 2e12e24 commit 9bb4738

File tree

9 files changed

+81
-66
lines changed

9 files changed

+81
-66
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,9 @@ jobs:
2424
with:
2525
fetch-depth: 0
2626

27-
- uses: articulate/actions-markdownlint@v1
27+
- uses: DavidAnson/markdownlint-cli2-action@v21
2828
with:
29-
config: .markdownlint.yaml
30-
files: '**/*.md'
31-
ignore: node_modules
32-
version: 0.46.1
29+
globs: '**/*.md'
3330

3431
- uses: actions/cache@v4
3532
with:

.markdownlint.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
MD013:
33
line_length: 400
44
no-inline-html:
5-
allowed_elements: [a, p, img, br, code-selector]
5+
allowed_elements: [a, p, img, br, code-selector, video, source, iframe, h1]
66
MD046:
77
style: fenced
88
MD004:

core/doctrine-filters.md

Lines changed: 46 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,7 @@ class Book {
5656

5757
## Basic Knowledge
5858

59-
Filters are services (see the section on [custom filters](../core/filters.md#creating-custom-filters)), and they can be linked
60-
to a Resource in two ways:
61-
62-
1. Through the resource declaration, as the `filters` attribute.
59+
Filters are services (see the section on [custom filters](../core/filters.md#creating-custom-filters)), the can be linked to an API Platform Operation throuh [parameters](./filters.md):
6360

6461
For example, having a filter service declaration in `services.yaml`:
6562

@@ -72,11 +69,6 @@ services:
7269
tags: ['api_platform.filter']
7370
```
7471
75-
> [!WARNING]
76-
> Its discouraged to use a filter with properties in the dependency injection as it may conflict with how
77-
> `QueryParameter` works. We recommend to use a per-parameter filter or to use the :property placeholder with a defined
78-
> `filterContext` specifying your strategy for a given set of parameters.
79-
8072
We're linking the filter `offer.date_filter` with the resource like this:
8173

8274
```php
@@ -93,6 +85,32 @@ class Offer
9385
}
9486
```
9587

88+
> [!WARNING]
89+
> Its discouraged to use a filter with properties in the dependency injection as it may conflict with how
90+
> `QueryParameter` works. We recommend to use a per-parameter filter or to use the :property placeholder with a defined
91+
> `filterContext` specifying your strategy for a given set of parameters.
92+
93+
Since API platform 4.2 we're allowing singleton objects, indeed a filter now acts on a single parameter associated
94+
with a single scalar value (or a list). You may use the [`:property` placeholder](./filters.md#filtering-multiple-properties-with-property))
95+
96+
```php
97+
<?php
98+
// api/src/ApiResource/Offer.php
99+
namespace App\ApiResource;
100+
101+
#[GetCollection(
102+
parameters: [
103+
'createdAt' => new QueryParameter(
104+
filter: new DateFilter(),
105+
),
106+
],
107+
)]
108+
class Offer
109+
{
110+
// ...
111+
}
112+
```
113+
96114
For MongoDB ODM, all the filters are in the namespace `ApiPlatform\Doctrine\Odm\Filter`. The filter
97115
services all begin with `api_platform.doctrine_mongodb.odm`.
98116

@@ -102,7 +120,7 @@ services all begin with `api_platform.doctrine_mongodb.odm`.
102120
> The SearchFilter is a multi-type filter that may have inconsistencies (eg: you can search a partial date with LIKE)
103121
> we recommend to use type-specific filters such as `PartialSearchFilter` or `DateFilter` instead.
104122

105-
### Built-in new Search Filters since API Platform >= 4.2
123+
### Built-in Search Filters since API Platform >= 4.2
106124

107125
To add some search filters, choose over this new list:
108126

@@ -132,7 +150,7 @@ The search filter supports `exact`, `partial`, `start`, `end`, and `word_start`
132150
- `word_start` strategy uses `LIKE text% OR LIKE % text%` to search for fields that contain words starting with `text`.
133151

134152
Prepend the letter `i` to the filter if you want it to be case insensitive. For example `ipartial` or `iexact`. Note that
135-
this will use the `LOWER` function and **will** impact performance [if there is no proper index](performance.md#search-filter).
153+
this will use the `LOWER` function and will impact performance [as described in the performance documentation](./performance#search-filter).
136154

137155
Case insensitivity may already be enforced at the database level depending on the [collation](https://en.wikipedia.org/wiki/Collation)
138156
used. If you are using MySQL, note that the commonly used `utf8_unicode_ci` collation (and its sibling `utf8mb4_unicode_ci`)
@@ -180,7 +198,7 @@ Syntax: `?property=value`
180198

181199
The value can take any [IRI(Internationalized Resource Identifier)](https://en.wikipedia.org/wiki/Internationalized_Resource_Identifier).
182200

183-
Like other [new search filters](#built-in-new-search-filters-api-platform--42) it can be used on the ApiResource attribute
201+
This filter can be used on the ApiResource attribute
184202
or in the operation attribute, for e.g., the `#GetCollection()` attribute:
185203

186204
```php
@@ -210,7 +228,7 @@ Syntax: `?property=value`
210228

211229
The value can take any scalar value or array of values.
212230

213-
Like other [new search filters](#built-in-new-search-filters-api-platform--42) it can be used on the ApiResource attribute
231+
This filter can be used on the ApiResource attribute
214232
or in the operation attribute, for e.g., the `#GetCollection()` attribute:
215233

216234
```php
@@ -240,7 +258,7 @@ Syntax: `?property=value`
240258

241259
The value can take any scalar value or array of values.
242260

243-
Like other [new search filters](#built-in-new-search-filters-api-platform--42) it can be used on the ApiResource attribute
261+
This filter can be used on the ApiResource attribute
244262
or in the operation attribute, for e.g., the `#GetCollection()` attribute:
245263

246264
```php
@@ -275,7 +293,7 @@ Syntax: `?property=value`
275293

276294
The value can take any scalar value or array of values.
277295

278-
Like other [new search filters](#built-in-new-search-filters-api-platform--42) it can be used on the ApiResource attribute
296+
This filter can be used on the ApiResource attribute
279297
or in the operation attribute, for e.g., the `#GetCollection()` attribute:
280298

281299
```php
@@ -388,7 +406,7 @@ class Offer
388406
```
389407

390408
> [!TIP]
391-
> For other syntaxes, for e.g., if you want to new syntax with the ApiResource attribute take a look [here](#introduction).
409+
> For other syntaxes, for e.g., if you want to new syntax with the ApiResource attribute take a look [in the Introduction section](#introduction).
392410

393411
### Date Filter using the ApiFilter Attribute Syntax (not recommended)
394412

@@ -505,7 +523,7 @@ class Offer
505523
```
506524

507525
> [!TIP]
508-
> For other syntaxes, for e.g., if you want to new syntax with the ApiResource attribute take a look [here](#introduction).
526+
> For other syntaxes, for e.g., if you want to new syntax with the ApiResource attribute take a look [in the Introduction section](#introduction).
509527

510528
## Boolean Filter
511529

@@ -539,7 +557,7 @@ class Offer
539557
```
540558

541559
> [!TIP]
542-
> For other syntaxes, for e.g., if you want to new syntax with the ApiResource attribute take a look [here](#introduction).
560+
> For other syntaxes, for e.g., if you want to new syntax with the ApiResource attribute take a look [in the Introduction section](#introduction).
543561

544562
### Result using the Boolean Filter
545563

@@ -579,7 +597,7 @@ class Offer
579597
```
580598

581599
> [!TIP]
582-
> For other syntaxes, for e.g., if you want to new syntax with the ApiResource attribute take a look [here](#introduction).
600+
> For other syntaxes, for e.g., if you want to new syntax with the ApiResource attribute take a look [in the Introduction section](#introduction).
583601

584602
### Result using the Numeric Filter
585603

@@ -619,7 +637,7 @@ class Offer
619637
```
620638

621639
> [!TIP]
622-
> For other syntaxes, for e.g., if you want to new syntax with the ApiResource attribute take a look [here](#introduction).
640+
> For other syntaxes, for e.g., if you want to new syntax with the ApiResource attribute take a look [in the Introduction section](#introduction).
623641

624642
### Result using the Range Filter
625643

@@ -662,7 +680,7 @@ class Offer
662680
```
663681

664682
> [!TIP]
665-
> For other syntaxes, for e.g., if you want to new syntax with the ApiResource attribute take a look [here](#introduction).
683+
> For other syntaxes, for e.g., if you want to new syntax with the ApiResource attribute take a look [in the Introduction section](#introduction).
666684

667685
### Result using the Exists Filter
668686

@@ -743,7 +761,7 @@ class Offer
743761
After that, you can use it with the following query: `/offers?order[name]=desc&order[id]=asc`.
744762

745763
> [!TIP]
746-
> For other syntaxes, for e.g., if you want to new syntax with the ApiResource attribute take a look [here](#introduction).
764+
> For other syntaxes, for e.g., if you want to new syntax with the ApiResource attribute take a look [in the Introduction section](#introduction).
747765

748766
### Result using the Order Filter
749767

@@ -755,14 +773,14 @@ order with the following query: `/offers?order[name]=desc&order[id]=asc`.
755773
By default, whenever the query does not specify the direction explicitly (e.g.: `/offers?order[name]&order[id]`), filters
756774
will not be applied unless you configure a default order direction to use:
757775

758-
**Basic Strategies**
776+
#### Basic Strategies
759777

760778
| Description | Strategy to set |
761779
|-------------|------------------------------------------------------------------------------------|
762780
| Ascending | `ApiPlatform\Doctrine\Common\Filter\OrderFilterInterface::DIRECTION_DESC` (`DESC`) |
763781
| Descending | `ApiPlatform\Doctrine\Common\Filter\OrderFilterInterface::DIRECTION_ASC` (`ASC`) |
764782

765-
**Other Strategies**
783+
#### Other Strategies
766784

767785
For other sort strategies (about `null` values), please refer to the [Handling Null Values with the Order Filter section](#comparing-with-null-values-using-order-filter).
768786

@@ -1397,8 +1415,8 @@ This allows delegating validation to API Platform, respecting the [SOLID Princip
13971415
>
13981416
> You can see how this works directly in our code components:
13991417
>
1400-
> - The `ParameterValidatorProvider` for **Symfony** can be found [here](https://github.com/api-platform/core/blob/c9692b509d5b641104addbadb349b9bcab83e251/src/Symfony/Validator/State/ParameterValidatorProvider.php).
1401-
> - The `ParameterValidatorProvider` for **Laravel** is located [here](https://github.com/api-platform/core/blob/c9692b509d5b641104addbadb349b9bcab83e251/src/Laravel/State/ParameterValidatorProvider.php).
1418+
> - The `ParameterValidatorProvider` for **Symfony** can be found [in the Symfony ParameterValidatorProvider.php file](https://github.com/api-platform/core/blob/c9692b509d5b641104addbadb349b9bcab83e251/src/Symfony/Validator/State/ParameterValidatorProvider.php).
1419+
> - The `ParameterValidatorProvider` for **Laravel** is located [in the Laravel ParameterValidatorProvider.php file](https://github.com/api-platform/core/blob/c9692b509d5b641104addbadb349b9bcab83e251/src/Laravel/State/ParameterValidatorProvider.php).
14021420
>
14031421
> Additionally, we filter out empty values within our `ParameterExtension` classes. For instance, the **Doctrine ORM**
14041422
> `ParameterExtension` [handles this filtering here](https://github.com/api-platform/core/blob/c9692b509d5b641104addbadb349b9bcab83e251/src/Doctrine/Orm/Extension/ParameterExtension.php#L51C13-L53C14).
@@ -1668,8 +1686,8 @@ This allows delegating validation to API Platform, respecting the [SOLID Princip
16681686
>
16691687
> You can see how this works directly in our code components:
16701688
>
1671-
> - The `ParameterValidatorProvider` for **Symfony** can be found [here](https://github.com/api-platform/core/blob/c9692b509d5b641104addbadb349b9bcab83e251/src/Symfony/Validator/State/ParameterValidatorProvider.php).
1672-
> - The `ParameterValidatorProvider` for **Laravel** is located [here](https://github.com/api-platform/core/blob/c9692b509d5b641104addbadb349b9bcab83e251/src/Laravel/State/ParameterValidatorProvider.php).
1689+
> - The `ParameterValidatorProvider` for **Symfony** can be found [in the Symfony ParameterValidatorProvider.php file](https://github.com/api-platform/core/blob/c9692b509d5b641104addbadb349b9bcab83e251/src/Symfony/Validator/State/ParameterValidatorProvider.php).
1690+
> - The `ParameterValidatorProvider` for **Laravel** is located [in the Laravel ParameterValidatorProvider.php file](https://github.com/api-platform/core/blob/c9692b509d5b641104addbadb349b9bcab83e251/src/Laravel/State/ParameterValidatorProvider.php).
16731691
>
16741692
> Additionally, we filter out empty values within our `ParameterExtension` classes. For instance, the **Doctrine ODM**
16751693
> `ParameterExtension` [handles this filtering here](https://github.com/api-platform/core/blob/c9692b509d5b641104addbadb349b9bcab83e251/src/Doctrine/Odm/Extension/ParameterExtension.php#L50-L52).

core/dto.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ In API Platform, [the general design considerations](design.md) recommended patt
1010

1111
This reference covers three implementation strategies:
1212

13-
* [State Options: Linking a DTO Resource to an Entity for automated CRUD operations.](#1-the-dto-resource-state-options)
14-
* [Automated Mapped Inputs: Using input DTOs with stateOptions for automated Write operations.](#2-automated-mapped-inputs-outputs)
15-
* [Custom Business Logic: Using input DTOs with custom State Processors for specific business actions.](#3-custom-business-logic-custom-processor)
13+
- [State Options: Linking a DTO Resource to an Entity for automated CRUD operations.](#1-the-dto-resource-state-options)
14+
- [Automated Mapped Inputs: Using input DTOs with stateOptions for automated Write operations.](#2-automated-mapped-inputs-and-outputs)
15+
- [Custom Business Logic: Using input DTOs with custom State Processors for specific business actions.](#3-custom-business-logic-custom-processor)
1616

1717
## 1. The DTO Resource (State Options)
1818

@@ -116,9 +116,9 @@ Automated mapping relies on two internal classes: `ApiPlatform\State\Provider\Ob
116116

117117
These classes act as decorators around the standard Provider/Processor chain. They are activated when:
118118

119-
* The Object Mapper component is available.
120-
* `stateOptions` are configured with an `entityClass` (or `documentClass` for ODM).
121-
* The Resource (and Entity for writes) classes have the `#[Map]` attribute.
119+
- The Object Mapper component is available.
120+
- `stateOptions` are configured with an `entityClass` (or `documentClass` for ODM).
121+
- The Resource (and Entity for writes) classes have the `#[Map]` attribute.
122122

123123
#### How it works internally
124124

@@ -130,7 +130,7 @@ The `ObjectMapperProvider` delegates fetching the data to the underlying Doctrin
130130

131131
The `ObjectMapperProcessor` receives the deserialized Input DTO. It uses `$objectMapper->map($inputDto, $entityClass)` to transform the input into an Entity instance. It then delegates to the underlying Doctrine processor (to persist the Entity). Finally, it maps the persisted Entity back to the Output DTO Resource.
132132

133-
## 2. Automated Mapped Inputs & Outputs
133+
## 2. Automated Mapped Inputs and Outputs
134134

135135
Ideally, your read and write models should differ. You might want to expose less data in a collection view (Output DTO) or enforce strict validation during creation/updates (Input DTOs).
136136

core/elasticsearch-filters.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class Book {
5252
}
5353
```
5454

55-
**Further Reading**
55+
## Further Reading
5656

5757
- Consult the documentation on [Per-Parameter Filters (Recommended Method)](../core/filters.md#2-per-parameter-filters-recommended).
5858
- If you are working with a legacy codebase, you can refer to the [documentation for the old syntax (deprecated)](../core/filters.md#1-legacy-filters-searchfilter-etc---not-recommended).

core/filters.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -536,7 +536,7 @@ The `IriConverterParameterProvider` supports the following options in `extraProp
536536

537537
This provider must be enabled before it can be used.
538538

539-
```
539+
```yaml
540540
api_platform:
541541
enable_link_security: true
542542
```
@@ -742,7 +742,7 @@ class User {}
742742
## Parameter Attribute Reference
743743

744744
| Property | Description |
745-
|---|---|
745+
| --- | --- |
746746
| `key` | The name of the parameter (e.g., `name`, `order`). |
747747
| `filter` | The filter service or instance that processes the parameter's value. |
748748
| `provider` | A service that transforms the parameter's value before it's used. |

core/graphql.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -680,7 +680,7 @@ Your custom queries will be available like this:
680680

681681
## Mutations
682682

683-
If you don't know what mutations are yet, the documentation about them is [here](https://graphql.org/learn/queries/#mutations).
683+
If you don't know what mutations are yet, the documentation about them is [in the GraphQL documentation for mutations](https://graphql.org/learn/queries/#mutations).
684684

685685
For each resource, three mutations are available:
686686

laravel/filters.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -153,19 +153,19 @@ Usage Examples
153153

154154
With the `DateFilter` applied, you can now filter dates between 2024-01-01 and 2024-01-31 using these API calls:
155155

156-
**Option 1: Using gte and lte operators**
156+
#### Option 1: Using gte and lte operators
157157

158158
```http
159159
GET /api/your_entities?createdAt[gte]=2024-01-01&createdAt[lte]=2024-01-31
160160
```
161161

162-
**Option 2: Using after and before operators**
162+
#### Option 2: Using after and before operators
163163

164164
```http
165165
GET /api/your_entities?createdAt[after]=2024-01-01&createdAt[before]=2024-01-31
166166
```
167167

168-
**Option 3: Using strictly_after and strictly_before**
168+
#### Option 3: Using strictly_after and strictly_before
169169

170170
```http
171171
GET /api/your_entities?createdAt[strictly_after]=2023-12-31&createdAt[strictly_before]=2024-02-01

0 commit comments

Comments
 (0)