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
89 changed files
with
3,469 additions
and
92 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
Feature: Resource attributes | ||
In order to use the Resource attribute | ||
As a developer | ||
I should be able to fetch data from a state provider | ||
|
||
@php8 | ||
@!mysql | ||
@!mongodb | ||
Scenario: Retrieve a Resource collection | ||
When I add "Content-Type" header equal to "application/ld+json" | ||
And I send a "GET" request to "/attribute_resources" | ||
Then the response status code should be 200 | ||
And the response should be in JSON | ||
And the header "Content-Type" should be equal to "application/ld+json; charset=utf-8" | ||
And the JSON should be equal to: | ||
""" | ||
{ | ||
"@context": "/contexts/AttributeResources", | ||
"@id": "/attribute_resources", | ||
"@type": "hydra:Collection", | ||
"hydra:member": [ | ||
{ | ||
"@id": "/attribute_resources/1", | ||
"@type": "AttributeResource", | ||
"identifier": 1, | ||
"name": "Foo" | ||
}, | ||
{ | ||
"@id": "/attribute_resources/2", | ||
"@type": "AttributeResource", | ||
"identifier": 2, | ||
"name": "Bar" | ||
} | ||
] | ||
} | ||
""" | ||
|
||
@php8 | ||
@!mysql | ||
@!mongodb | ||
Scenario: Retrieve the first resource | ||
When I add "Content-Type" header equal to "application/ld+json" | ||
And I send a "GET" request to "/attribute_resources/1" | ||
Then the response status code should be 200 | ||
And the response should be in JSON | ||
And the header "Content-Type" should be equal to "application/ld+json; charset=utf-8" | ||
And the JSON should be equal to: | ||
""" | ||
{ | ||
"@context": "/contexts/AttributeResource", | ||
"@id": "/attribute_resources/1", | ||
"@type": "AttributeResource", | ||
"identifier": 1, | ||
"name": "Foo" | ||
} | ||
""" | ||
|
||
@php8 | ||
@!mysql | ||
@!mongodb | ||
Scenario: Retrieve the aliased resource | ||
When I add "Content-Type" header equal to "application/ld+json" | ||
And I send a "GET" request to "/dummy/1/attribute_resources/2" | ||
Then the response status code should be 200 | ||
And the response should be in JSON | ||
And the header "Content-Type" should be equal to "application/ld+json; charset=utf-8" | ||
And the JSON should be equal to: | ||
""" | ||
{ | ||
"@context": "/contexts/AttributeResource", | ||
"@id": "/dummy/1/attribute_resources/2", | ||
"@type": "AttributeResource", | ||
"identifier": 2, | ||
"dummy": "/dummies/1", | ||
"name": "Foo" | ||
} | ||
""" | ||
|
||
@php8 | ||
@!mysql | ||
@!mongodb | ||
Scenario: Patch the aliased resource | ||
When I add "Content-Type" header equal to "application/merge-patch+json" | ||
And I send a "PATCH" request to "/dummy/1/attribute_resources/2" with body: | ||
""" | ||
{"name": "Patched"} | ||
""" | ||
Then the response status code should be 200 | ||
And the response should be in JSON | ||
And the header "Content-Type" should be equal to "application/ld+json; charset=utf-8" | ||
And the JSON should be equal to: | ||
""" | ||
{ | ||
"@context": "/contexts/AttributeResource", | ||
"@id": "/dummy/1/attribute_resources/2", | ||
"@type": "AttributeResource", | ||
"identifier": 2, | ||
"dummy": "/dummies/1", | ||
"name": "Patched" | ||
} | ||
""" |
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,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\Core\Api; | ||
|
||
use ApiPlatform\Core\Exception\RuntimeException; | ||
|
||
/** | ||
* Extracts identifiers for a given Resource according to the retrieved Metadata. | ||
* | ||
* @author Antoine Bluchet <soyuka@gmail.com> | ||
*/ | ||
interface ContextAwareIdentifiersExtractorInterface extends IdentifiersExtractorInterface | ||
{ | ||
/** | ||
* Finds identifiers from a Resource class. | ||
*/ | ||
public function getIdentifiersFromResourceClass(string $resourceClass): array; | ||
|
||
/** | ||
* Finds identifiers from an Item (object). | ||
* | ||
* @param object $item | ||
* | ||
* @throws RuntimeException | ||
*/ | ||
public function getIdentifiersFromItem($item, array $context = []): array; | ||
} |
Oops, something went wrong.