Skip to content

Adding full subscriber example #15186

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
Oct 9, 2022
Merged

Conversation

ThomasLandauer
Copy link
Contributor

@ThomasLandauer ThomasLandauer commented Apr 3, 2021

Reason: It's not so easy to figure this out, since the linked Event Subscriber page doesn't show how to subscribe to this specific event.

Questions:

  • The introduction text says "e.g. invalidate some tokens". How can this be done?
  • How can you add a flash message? $this->addFlash() didn't work for me.
  • I'm extending AbstractController to have access to $this->generateUrl() - is this the easiest/best way?

@maxhelias
Copy link
Contributor

I'm extending AbstractController to have access to $this->generateUrl() - is this the easiest/best way?

IMO you don't have to do that but rather inject the url generation service Symfony\Component\Routing\Generator\UrlGeneratorInterface

Reason: It's not so easy to figure this out, since the linked Event Subscriber page doesn't show how to subscribe to this specific event.

Questions:
* The introduction text says "e.g. invalidate some tokens". How can this be done?
* How can you add a flash message? `$this->addFlashMessage()` didn't work for me.
* I'm extending `AbstractController` to have access to `$this->generateUrl()` - is this the easiest/best way?
@wouterj wouterj changed the base branch from 5.2 to 5.4 October 9, 2022 13:24
@wouterj wouterj merged commit 4648d02 into symfony:5.4 Oct 9, 2022
wouterj added a commit that referenced this pull request Oct 9, 2022
@wouterj
Copy link
Member

wouterj commented Oct 9, 2022

Thank you for adding a code example here, @ThomasLandauer! I've just rebased this on top of the rewrite of last year and merged it in.

As for your questions, it's best to look at the AbstractController implementation (addFlash and generateUrl) and inject the correct services (RequestStack and UrlGeneratorInterface).

@ThomasLandauer ThomasLandauer deleted the patch-17 branch October 9, 2022 13:32
wouterj added a commit that referenced this pull request Oct 9, 2022
* 5.4:
  Document new Logstash handler argument
  Example remote ElasticsearchLogstashHandler
  [#15428] Add a bit more detail to bootstrap article
  Fix example code of customization of bootstrapping in test
  [#15186] Update example
  Adding full subscriber example
  [Validator] Add hint for testing custom constraints
wouterj added a commit that referenced this pull request Oct 9, 2022
* 6.0:
  Remove 5.4 versionadded
  Document new Logstash handler argument
  Example remote ElasticsearchLogstashHandler
  [#15428] Add a bit more detail to bootstrap article
  Fix example code of customization of bootstrapping in test
  [#15186] Update example
  Adding full subscriber example
  [Validator] Add hint for testing custom constraints
wouterj added a commit that referenced this pull request Oct 9, 2022
* 6.1:
  Remove 5.4 versionadded
  Document new Logstash handler argument
  Example remote ElasticsearchLogstashHandler
  [#15428] Add a bit more detail to bootstrap article
  Fix example code of customization of bootstrapping in test
  [#15186] Update example
  Adding full subscriber example
  [Validator] Add hint for testing custom constraints
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants