What are correct methods to implement in a repository?
-
21-03-2021 - |
Question
What methods is a repository required to implement?
The documentation (https://devdocs.magento.com/guides/v2.3/extension-dev-guide/service-contracts/design-patterns.html) states that you need to implement save(), get(), getList(), delete() and deleteById(). But I often see example in Magento core that use different variations such as getById() instead of just get(). Or use completely different methods.
Is there a standard? Any tutorials that could be recommended?
Solution
You know all there is to know
save(), get(), getList(), delete(), deleteById()
Remember these are simply php classes and like any other can be customised to suit your needs
But generally if you start with those you know that your code is consistent.
Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange