forked from api-platform/core
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(doctrine): doctrine filters like laravel eloquent filters (api-p…
…latform#6775) * feat(doctrine): doctrine filters like laravel eloquent filters * fix: allow multiple validation with :property placeholder * fix: correct escape filter condition * fix: remove duplicated block --------- Co-authored-by: soyuka <soyuka@users.noreply.github.com>
- Loading branch information
1 parent
8697f21
commit 509939d
Showing
42 changed files
with
1,994 additions
and
74 deletions.
There are no files selected for viewing
25 changes: 25 additions & 0 deletions
25
src/Doctrine/Common/Filter/ManagerRegistryAwareInterface.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the API Platform project. | ||
* | ||
* (c) Kévin Dunglas <dunglas@gmail.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace ApiPlatform\Doctrine\Common\Filter; | ||
|
||
use Doctrine\Persistence\ManagerRegistry; | ||
|
||
interface ManagerRegistryAwareInterface | ||
{ | ||
public function hasManagerRegistry(): bool; | ||
|
||
public function getManagerRegistry(): ManagerRegistry; | ||
|
||
public function setManagerRegistry(ManagerRegistry $managerRegistry): void; | ||
} |
38 changes: 38 additions & 0 deletions
38
src/Doctrine/Common/Filter/PropertyPlaceholderOpenApiParameterTrait.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the API Platform project. | ||
* | ||
* (c) Kévin Dunglas <dunglas@gmail.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace ApiPlatform\Doctrine\Common\Filter; | ||
|
||
use ApiPlatform\Metadata\Parameter; | ||
use ApiPlatform\OpenApi\Model\Parameter as OpenApiParameter; | ||
|
||
trait PropertyPlaceholderOpenApiParameterTrait | ||
{ | ||
/** | ||
* @return array<OpenApiParameter>|null | ||
*/ | ||
public function getOpenApiParameters(Parameter $parameter): ?array | ||
{ | ||
if (str_contains($parameter->getKey(), ':property')) { | ||
$parameters = []; | ||
$key = str_replace('[:property]', '', $parameter->getKey()); | ||
foreach (array_keys($parameter->getExtraProperties()['_properties'] ?? []) as $property) { | ||
$parameters[] = new OpenApiParameter(name: \sprintf('%s[%s]', $key, $property), in: 'query'); | ||
} | ||
|
||
return $parameters; | ||
} | ||
|
||
return null; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.