Create a class that implements an interface in Magento
Learn Magento 2 dependency injection using RequestInterface to access URL params in controllers.
Lesson Content
Just like we created the session object with dependency injection, we can do the same to get a request object, which will allow us to get URL params and other items from the web request.
Thereβs a difference here though, using what we just learned about dependency injection and interfaces.
Rather than passing in the Http class, which is the concrete class implementation, we will instead pass in the related interface. This will be the request interface.
Letβs create another private property using the RequestInterface, from Magento\Framework\App, and we will assign the result back...
Join the discussion!
Comments
Want to comment on this lesson?
Enroll in this course to leave comments.