Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Added "How to create an event subscriber" #4538

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

Closed
wants to merge 14 commits into from
Closed

Conversation

beni0888
Copy link
Contributor

I've added the information about how to create an event subscriber to the "How to create an Event listener" cookbook recipe. I think that there isn't a recipe in the cookbook about that and it can be useful.

I've added the information about how to create an event subscriber to the "How to create an Event listener" cookbook recipe.
@@ -1,18 +1,24 @@
.. index::
single: Events; Create listener
single: Events; Create listener, Create subscriber
Copy link
Member

Choose a reason for hiding this comment

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

Does this work? I think you will have so split this into two indexes:

.. index::
    single: Events; Create listener
    single: Events; Create subscriber

I've fixed my previous error in the definition of an index entry.
Creating an Event Listener
--------------------------

The most common way to listen to an event is to register an event listener:
Copy link
Member

Choose a reason for hiding this comment

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

this has to be a double colon (::) in order to enable highlighting for the following code block

@wouterj
Copy link
Member

wouterj commented Nov 29, 2014

Thank you for starting this! We have some detailed documentation about this in the components section, could you please reference that from this article. Some like: 'To learn more about event subscribers, see ...'

a service that will act as an event listener on that event. In this entry,
you will create a service that will act as an Exception Listener, allowing
a service that will act as an event listener on that event. You can do that in two different ways,
creating an Event Listener or an Event Subscriber instead. In this entry,
Copy link
Member

Choose a reason for hiding this comment

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

Here you use "Event Listener" and "Event Subscriber", but in the rest of the article it's "event listener" and "event subscriber". Is there any reason for the capitalization of letters in this case?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You are right, there's no reason to do that, I'm going to fix it, thanks.

@beni0888
Copy link
Contributor Author

It seems like my pull request has been forgotten :/

you will create a service that will act as an Exception Listener, allowing
a service that will act as an event listener on that event. You can do that in two different ways,
creating an event listener or an event subscriber instead. In this entry,
you will see the two ways of creating a service that will act as an exception listener, allowing
Copy link
Member

Choose a reason for hiding this comment

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

Can you please wrap lines after the first word that crosses the 72nd character?

@xabbuh
Copy link
Member

xabbuh commented Dec 22, 2014

@beni0888 Thank you for working on this. Unfortunately, we don't receive notifications when someone pushes new commits on a pull request. Just leave us a message when you add commits next time. :)

@wouterj
Copy link
Member

wouterj commented Feb 20, 2015

ping @beni0888 Can you please update this PR? (If you have no time to do it, feel free to say that too, we'll then finish this PR)

@beni0888
Copy link
Contributor Author

@wouterj yes, I'm sorry I've been quite bussy... I'll try to fix it today :)


Symfony has various events and hooks that can be used to trigger custom
behavior in your application. Those events are thrown by the HttpKernel
component and can be viewed in the :class:`Symfony\\Component\\HttpKernel\\KernelEvents` class.

To hook into an event and add your own custom logic, you have to create
a service that will act as an event listener on that event. In this entry,
you will create a service that will act as an Exception Listener, allowing
a service that will act as an event listener on that event. You can do that in two different ways,
Copy link
Contributor

Choose a reason for hiding this comment

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

service that will listen to that event.

@beni0888
Copy link
Contributor Author

@wouterj I'm very sorry for not to fix the problems in this PR as I promised, but I've been really busy and I haven't been able to do it. However, I keep this task in my mind and I will do it as soon as possible. Sorry.

@javiereguiluz
Copy link
Member

@beni0888 there is no need to apologize at all! This is a volunteer work and we understand that sometimes we face large workloads which prevents us from dedicating time to open source projects.

Feel free to work on this when you can and, if you think you cannot finish it, please tell us and we'll overtake this pull request. Thanks.

@beni0888
Copy link
Contributor Author

@javiereguiluz 👍

@wouterj
Copy link
Member

wouterj commented May 21, 2015

@beni0888 this saturday, we'll be hosting a doc sprint day. Would you like to finish this PR yourself (maybe during the day?) or should we put it on a list so others can finish it?

@beni0888
Copy link
Contributor Author

@wouterj I think I won't be able to work on this PR this saturday and It's opened for too long, so it would be nice if you put it on the list :)

@xabbuh xabbuh added the actionable Clear and specific issues ready for anyone to take them. label May 22, 2015
@javiereguiluz
Copy link
Member

I've finished this PR in a new one: #5377. I cherry-picked @beni0888's commits to not lose the credit for his work. Thanks.

@beni0888
Copy link
Contributor Author

@javiereguiluz Thanks and sorry for not finish it myself

@javiereguiluz
Copy link
Member

@beni0888 no worries! Starting things is always the most important part. Your PR "forced" us to write this cookbook ... and that's great! Thanks.

@wouterj wouterj closed this Jun 10, 2015
weaverryan added a commit that referenced this pull request Oct 14, 2015
…888, javiereguiluz)

This PR was merged into the 2.3 branch.

Discussion
----------

Added a cookbook section about event subscribers

| Q             | A
| ------------- | ---
| Doc fix?      | no
| New docs?     | yes
| Applies to    | all
| Fixed tickets | -

This PR finishes the work made by @beni0888 in #4538.

Commits
-------

b5a82ca Final changes
ba9ec6b Reworded the introduction and other minor fixes
483f029 Added a note about the advantages/drawbacks of listeners/subscribers
e56fed8 Fixed minor issues
c8c8bf8 Reworded the subscriber introduction
36b1d10 Fixed the name of the services file
a444951 Implemented the suggestions made by @xabbuh
9a6dab7 Completed the cookbook about the event subscriber
0184e0f Added a note about the priority meaning in event subscribers
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
actionable Clear and specific issues ready for anyone to take them. Status: Needs Work
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants