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

iri based on value from persister #2283

Closed
wants to merge 1 commit into from
Closed

iri based on value from persister #2283

wants to merge 1 commit into from

Conversation

wesol05
Copy link

@wesol05 wesol05 commented Oct 27, 2018

Q A
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets -
License MIT
Doc PR -

When using custom data persister, we don't pass id, but we want to somehow retrieve it. Unfortunately, returned object (with set id, is not taking under consideration when iri is set).

Example data persister:

public function persist($data)
    {
        $core = $this->transformer->toCore($data);

        $this->entityManager->persist($core);
        $this->entityManager->flush();

        return $this->transformer->toHttp($core);
    }

Copy link
Member

@dunglas dunglas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch! Can you just fix the test please?

@@ -59,7 +59,8 @@ public function onKernelView(GetResponseForControllerResultEvent $event)
@trigger_error(sprintf('Returning void from %s::persist() is deprecated since API Platform 2.3 and will not be supported in API Platform 3, an object should always be returned.', DataPersisterInterface::class), E_USER_DEPRECATED);
}

$event->setControllerResult($persistResult ?? $controllerResult);
$controllerResult = $persistResult ?? $controllerResult;
$event->setControllerResult($controllerResult);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change has a open discussion here: #2235 (comment) and I believe it breaks a feature (see WriteListenerTest::testOnKernelViewWithControllerResultAndPersistWithImmutableResource, the resource isn't immutable anymore?) ?

@flug
Copy link
Contributor

flug commented Nov 14, 2019

@wesol05 Up is this pull request still valid?

@soyuka soyuka closed this Nov 15, 2019
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.

4 participants