-
-
Notifications
You must be signed in to change notification settings - Fork 874
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
574 additions
and
17 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the API Platform project. | ||
* | ||
* (c) Kévin Dunglas <[email protected]> | ||
* | ||
* 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\Tests\Fixtures\TestBundle\ApiResource; | ||
|
||
use ApiPlatform\Doctrine\Odm\Filter\DateFilter as OdmDateFilter; | ||
use ApiPlatform\Doctrine\Odm\State\Options as OdmOptions; | ||
use ApiPlatform\Doctrine\Orm\Filter\DateFilter; | ||
use ApiPlatform\Doctrine\Orm\State\Options; | ||
use ApiPlatform\Metadata\ApiFilter; | ||
use ApiPlatform\Metadata\ApiResource; | ||
use ApiPlatform\Metadata\GetCollection; | ||
use ApiPlatform\Metadata\QueryParameter; | ||
use ApiPlatform\Tests\Fixtures\TestBundle\Document\AgentDocument; | ||
use ApiPlatform\Tests\Fixtures\TestBundle\Entity\Agent; | ||
|
||
#[ApiFilter(DateFilter::class, properties: ['birthday'], alias: 'app_filter_date')] | ||
#[ApiResource( | ||
shortName: 'Agent', | ||
operations: [ | ||
new GetCollection(parameters: [ | ||
'birthday' => new QueryParameter(filter: 'app_filter_date'), | ||
]), | ||
], | ||
stateOptions: new Options(entityClass: Agent::class) | ||
)] | ||
#[ApiFilter(OdmDateFilter::class, properties: ['birthday'], alias: 'app_filter_date_odm')] | ||
#[ApiResource( | ||
shortName: 'AgentDocument', | ||
operations: [ | ||
new GetCollection(parameters: [ | ||
'birthday' => new QueryParameter(filter: 'app_filter_date_odm'), | ||
]), | ||
], | ||
stateOptions: new OdmOptions(documentClass: AgentDocument::class) | ||
)] | ||
class AgentApi | ||
{ | ||
private ?int $id = null; | ||
|
||
private ?string $name = null; | ||
|
||
private ?\DateTimeInterface $birthday = null; | ||
|
||
public function getId(): ?int | ||
{ | ||
return $this->id; | ||
} | ||
|
||
public function setId(?int $id): self | ||
{ | ||
$this->id = $id; | ||
|
||
return $this; | ||
} | ||
|
||
public function getName(): ?string | ||
{ | ||
return $this->name; | ||
} | ||
|
||
public function setName(?string $name): self | ||
{ | ||
$this->name = $name; | ||
|
||
return $this; | ||
} | ||
|
||
public function getBirthday(): ?\DateTimeInterface | ||
{ | ||
return $this->birthday; | ||
} | ||
|
||
public function setBirthday(?\DateTimeInterface $birthday): self | ||
{ | ||
$this->birthday = $birthday; | ||
|
||
return $this; | ||
} | ||
} |
63 changes: 63 additions & 0 deletions
63
tests/Fixtures/TestBundle/ApiResource/Issue6673/MutlipleParameterProvider.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,63 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the API Platform project. | ||
* | ||
* (c) Kévin Dunglas <[email protected]> | ||
* | ||
* 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\Tests\Fixtures\TestBundle\ApiResource\Issue6673; | ||
|
||
use ApiPlatform\Metadata\GetCollection; | ||
use ApiPlatform\Metadata\Operation; | ||
use ApiPlatform\Metadata\Parameter; | ||
use ApiPlatform\Metadata\QueryParameter; | ||
|
||
#[GetCollection( | ||
uriTemplate: 'issue6673_multiple_parameter_provider', | ||
shortName: 'multiple_parameter_provider', | ||
outputFormats: ['json'], | ||
parameters: [ | ||
'a' => new QueryParameter( | ||
provider: [self::class, 'parameterOneProvider'], | ||
), | ||
'b' => new QueryParameter( | ||
provider: [self::class, 'parameterTwoProvider'], | ||
), | ||
], | ||
provider: [self::class, 'provide'] | ||
)] | ||
final class MutlipleParameterProvider | ||
{ | ||
public function __construct(public readonly string $id) | ||
{ | ||
} | ||
|
||
public static function provide(Operation $operation): ?array | ||
{ | ||
return $operation->getNormalizationContext(); | ||
} | ||
|
||
public static function parameterOneProvider(Parameter $parameter, array $parameters = [], array $context = []): ?Operation | ||
{ | ||
$operation = $context['operation']; | ||
$context = $operation->getNormalizationContext() ?? []; | ||
$context['a'] = $parameter->getValue(); | ||
|
||
return $operation->withNormalizationContext($context); | ||
} | ||
|
||
public static function parameterTwoProvider(Parameter $parameter, array $parameters = [], array $context = []): ?Operation | ||
{ | ||
$operation = $context['operation']; | ||
$context = $operation->getNormalizationContext() ?? []; | ||
$context['b'] = $parameter->getValue(); | ||
|
||
return $operation->withNormalizationContext($context); | ||
} | ||
} |
Oops, something went wrong.