Skip to content

Commit f164a1d

Browse files
PierreRebeilleausoyuka
authored andcommitted
chore: move RamseyUuid bridge to its own component (api-platform#5580)
1 parent 2b25016 commit f164a1d

File tree

13 files changed

+198
-26
lines changed

13 files changed

+198
-26
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,7 @@ jobs:
193193
- OpenApi
194194
- Metadata
195195
- Elasticsearch
196+
- RamseyUuid
196197
fail-fast: false
197198
steps:
198199
- name: Checkout

src/Api/UriVariableTransformerInterface.php

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -13,27 +13,6 @@
1313

1414
namespace ApiPlatform\Api;
1515

16-
use ApiPlatform\Exception\InvalidUriVariableException;
17-
18-
interface UriVariableTransformerInterface
16+
interface UriVariableTransformerInterface extends \ApiPlatform\Metadata\UriVariableTransformerInterface
1917
{
20-
/**
21-
* Transforms the value of a URI variable (identifier) to its type.
22-
*
23-
* @param mixed $value The URI variable value to transform
24-
* @param array $types The guessed type behind the URI variable
25-
* @param array $context Options available to the transformer
26-
*
27-
* @throws InvalidUriVariableException Occurs when the URI variable could not be transformed
28-
*/
29-
public function transform(mixed $value, array $types, array $context = []);
30-
31-
/**
32-
* Checks whether the value of a URI variable can be transformed to its type by this transformer.
33-
*
34-
* @param mixed $value The URI variable value to transform
35-
* @param array $types The types to which the URI variable value should be transformed
36-
* @param array $context Options available to the transformer
37-
*/
38-
public function supportsTransformation(mixed $value, array $types, array $context = []): bool;
3918
}

src/Exception/InvalidUriVariableException.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@
1717
* Identifier is not valid exception.
1818
*
1919
* @author Antoine Bluchet <[email protected]>
20+
*
21+
* @final
2022
*/
21-
final class InvalidUriVariableException extends \Exception implements ExceptionInterface
23+
class InvalidUriVariableException extends \Exception implements ExceptionInterface
2224
{
2325
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the API Platform project.
5+
*
6+
* (c) Kévin Dunglas <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
declare(strict_types=1);
13+
14+
namespace ApiPlatform\Metadata\Exception;
15+
16+
use ApiPlatform\Exception\InvalidUriVariableException as LegacyInvalidUriVariableException;
17+
18+
if (class_exists(LegacyInvalidUriVariableException::class)) {
19+
class InvalidUriVariableException extends LegacyInvalidUriVariableException
20+
{
21+
}
22+
} else {
23+
/**
24+
* Identifier is not valid exception.
25+
*
26+
* @author Antoine Bluchet <[email protected]>
27+
*/
28+
final class InvalidUriVariableException extends \Exception implements ExceptionInterface
29+
{
30+
}
31+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the API Platform project.
5+
*
6+
* (c) Kévin Dunglas <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
declare(strict_types=1);
13+
14+
namespace ApiPlatform\Metadata;
15+
16+
use ApiPlatform\Exception\InvalidUriVariableException;
17+
18+
interface UriVariableTransformerInterface
19+
{
20+
/**
21+
* Transforms the value of a URI variable (identifier) to its type.
22+
*
23+
* @param mixed $value The URI variable value to transform
24+
* @param array $types The guessed type behind the URI variable
25+
* @param array $context Options available to the transformer
26+
*
27+
* @throws InvalidUriVariableException Occurs when the URI variable could not be transformed
28+
*/
29+
public function transform(mixed $value, array $types, array $context = []);
30+
31+
/**
32+
* Checks whether the value of a URI variable can be transformed to its type by this transformer.
33+
*
34+
* @param mixed $value The URI variable value to transform
35+
* @param array $types The types to which the URI variable value should be transformed
36+
* @param array $context Options available to the transformer
37+
*/
38+
public function supportsTransformation(mixed $value, array $types, array $context = []): bool;
39+
}

src/RamseyUuid/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/composer.lock
2+
/vendor
3+
/.phpunit.result.cache

src/RamseyUuid/LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT license
2+
3+
Copyright (c) 2015-present Kévin Dunglas
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is furnished
10+
to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
THE SOFTWARE.

src/RamseyUuid/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# API Platform - RamseyUuid
2+
3+
RamseyUuid component from API Platform
File renamed without changes.

tests/RamseyUuid/UriVariableTransformer/UuidUriVariableTransformerTest.php renamed to src/RamseyUuid/Tests/UriVariableTransformer/UuidUriVariableTransformerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
namespace ApiPlatform\Tests\RamseyUuid\UriVariableTransformer;
1515

16-
use ApiPlatform\Exception\InvalidUriVariableException;
16+
use ApiPlatform\Metadata\Exception\InvalidUriVariableException;
1717
use ApiPlatform\RamseyUuid\UriVariableTransformer\UuidUriVariableTransformer;
1818
use PHPUnit\Framework\TestCase;
1919
use Ramsey\Uuid\Uuid;

0 commit comments

Comments
 (0)