Skip to content

New "_api_persist" request attribute to skip the WriteListener #2072

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

Merged
merged 1 commit into from
Jul 6, 2018

Conversation

dunglas
Copy link
Member

@dunglas dunglas commented Jul 5, 2018

Q A
Bug fix? no
New feature? yes
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets n/a
License MIT
Doc PR api-platform/docs#523

Add a new _api_persist flag to skip the WriteListener. See also https://stackoverflow.com/q/51147945/1352334 for the use case.

@dunglas dunglas merged commit 808a453 into api-platform:master Jul 6, 2018
@dunglas dunglas deleted the persist-attr branch July 6, 2018 17:34
@walva
Copy link
Contributor

walva commented May 3, 2021

Thanks, very helpful ! I used it today. It was a bit hard to find in the documentation, I end up looking outside, that's why I end up here. For those who are looking for the related page in the documentation, here is the link: https://api-platform.com/docs/core/events/

Example of usage:

#[ApiResource(
  itemOperations: [
      "workflow_transition" => [
          "method"                  => "PUT",
          "path"                    => "/entity/{id}/{workflow}/{transition}",
          "controller"              => ApplyWorkflowTransition::class,
          "input"                   => ApplyTransitionAction::class,
          "defaults"                 => [
              "_api_persist" => false,
          ],
          'denormalization_context' => [
              'groups' => ['workflow', self::DENORMALIZATION_CONTEXT],
          ],
          'normalization_context'   => [
              'groups' => ['workflow', self::DENORMALIZATION_CONTEXT],
          ],
      ]
   ]
)

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