Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug Fix: DataTransformer returning same class as original should include JSONLD Data #3478

Closed
wants to merge 111 commits into from
Closed

Bug Fix: DataTransformer returning same class as original should include JSONLD Data #3478

wants to merge 111 commits into from

Conversation

silverbackdan
Copy link
Contributor

Q A
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Tickets fixes #3474
License MIT
Doc PR api-platform/docs#...

I'm sorry but I'm very bad with tests so have not written one and do not know where it'd be best placed.

In ApiPlatform\Core\DataTransformer\DataTransformerInterface there is a comment that states that DTOs should be allowed to return the same original object if no transformation is done. This resulted in missing LD data. (No @id, @context etc.).

     /**
     * Transforms the given object to something else, usually another object.
     * This must return the original object if no transformation has been done.
     *
     * @param object $object
     *
     * @return object
     */
    public function transform($object, string $to, array $context = []);

This update checks if the output class is the same as the original, and if so populated the extended metadata in the JsonLd\ItemNormalizer as it would not be added using the JsonLd\ObjectNormalizer

jocel1 and others added 30 commits August 22, 2019 13:45
* Issue #3082: Add and use ContextStamp.

* Issue #3082: Add tests.

* Issue #3157: Correct passing of context.

* Issue #3157: Minor corrections.
* Add defaults configuration

* Suggest defaults in configuration

* Apply changes from code review

* Add deprecation notices for legacy defaults

* Apply @dunglas' suggestions
This makes it more clear this interface can be 'caught'
Make the base exception extend throwable
* 2.5:
  Fix spelling
  Fix removal of illegal characters in schema name for Amazon API Gateway
  Add links to documentation to ApiResource properties
  fix #3189 - JSONAPI pagination ignored when using filter parameter
This will allow IDEs to provide hints/ autocompletion
More Descriptive Input/Output class names
dunglas and others added 28 commits January 13, 2020 17:43
* 2.5:
  Update CHANGELOG.md
  [GraphQL] Better detection of collection types (#3327)
  Add tests for building JSON Schema of non-resource class
  Fix JSON Schema generation for non-resource class
* Subscription support

* Use sha256 hash for generating subscription identifiers

* Update CHANGELOG
…mation-in-contributing

fix outdated pull request template link in contribution guide
…tions

Add specification property field's values restrictions based on validator setting
Co-authored-by: Teoh Han Hui <teohhanhui@gmail.com>
Allow to autoconfigure validation groups generators
Co-Authored-By: Teoh Han Hui <teohhanhui@gmail.com>
Add error code for JsonApi errors.
Co-Authored-By: Teoh Han Hui <teohhanhui@gmail.com>
send Varnish BAN requests with smaller headers
add support for stale-while-revalidate and stale-if-error cache-control extensions
In `ApiPlatform\Core\DataTransformer\DataTransformerInterface` there is a comment that states that DTOs should be allowed to return the same original object if no transformation is done. Ths resulted in missing LD data. (No @id, @context etc.).
```php
     /**
     * Transforms the given object to something else, usually another object.
     * This must return the original object if no transformation has been done.
     *
     * @param object $object
     *
     * @return object
     */
    public function transform($object, string $to, array $context = []);
```
This update checks if the output class is the same as the original, and if so populated the extended metadata in the JsonLd\ItemNormalizer as it would not be added using the JsonLd\ObjectNormalizer
@silverbackdan
Copy link
Contributor Author

Sorry will re-do patch done on the 2.5 branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.