O'Reilly logo

Magento 2 Developer's Guide by Branko Ajzele

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Using the around listener

The around listeners are used when we want to change both the arguments and the returned values of an original method or add some behavior before and after an original method is called.

Looking back at the aroundGetAddToCartUrl listener method definition, you will see that it has four properties assigned in sequence—$subject, $proceed, $product, and $additional.

With the after method listener, the first property is always the $subject property, which contains the instance of the object type being observed and not the return value of the observed method. The second property is always the $proceed property of \Closure. The properties following the $subject and $proceed match the properties of the observed getAddToCartUrl ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required