Create a repository interface in Magento
Learn how to create a Magento PostRepositoryInterface with save getById deleteById CRUD methods and Swagger ready docblocks.
Lesson Content
We now want to create an interface that our repository can implement. Remember that repository interfaces lay out a public API that is dependable and that others can rely on. It’s completely up to you what you define in your repository interface — you can define 1 function in this interface, or 100! It’s completely up to you.
It is standard convention to define at least save and getById functions. Again, we don’t have to create these! But it is also good to follow conventions, and names that others expect to see.
Our data interfaces will go into the Api directory. This signals that...
Join the discussion!
Comments
Want to comment on this lesson?
Enroll in this course to leave comments.