News Feed
Sections




News Archive
Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Kevin Schroeder:
Using events in Magento 2
January 07, 2014 @ 11:16:37

For the Magento 2 users out there, Kevin Schroeder has posted a guide that could be helpful in your work - using events, specifically how to add an observer on a pre-dispatch controller event.

With the minimal research I have done on Magento 2 recently the only thing I am apprehensive about is the invocation chain. Its purpose is to open the doors wide open to where you can hook your application in. [...] In terms of declaring an observer a lot has changed, and it's for the better. [...] Now instead of silently overwriting the value you will get an error such as "Duplicate key-sequence ['controller_action_predispatch'] in unique identity-constraint 'uniqueEventName'" if your observer has a duplicate name.

He includes the XML configuration you'll need to add a "Hello World" observer to the pre-dispatch controller event (that includes an "instance" path) and the code for the simple class' structure. He example just appends the string "Hello World" to whatever is being sent as a response. He also shows how to trigger them in the application via the event manager instance injected as a part of the observer creation.

0 comments voice your opinion now!
#magento2 #event #tutorial #observer #predispatch #eventmanager

Link: http://www.eschrade.com/page/using-events-in-magento-2/

blog comments powered by Disqus

Similar Posts

Kevin Schroeder: Using events in Magento 2

Kevin Schroeder: Using events in Magento 2

Kevin Schroeder: Using events in Magento 2

Kevin Schroeder: Using events in Magento 2

Kevin Schroeder: Using events in Magento 2


Community Events





Don't see your event here?
Let us know!


library application threedevsandamaybe configure code bugfix podcast developer interview project list api introduction language framework laravel release wordpress community series

All content copyright, 2014 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework