Video Lesson: Create a class that implements an interface in Magento

Create a class that implements an interface in Magento

This is premium content

Only available to enrolled or University students.
Join today to unlock all lessons in this course.

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...

Premium content

Enroll to unlock the full content and all course materials.

Maggie

Hey, I'm Maggie! πŸ‘‹

Ask me anything.

Want to chat with Maggie?

Enroll in this course for AI tutor access.

Comments

Join the discussion!

Comments

Want to comment on this lesson?

Enroll in this course to leave comments.