Working with service layers/contracts

A service layer/contract is a fixed interface to get and store data without knowing the underlying layer. It is possible to swap the way the data is stored without changing the service layer.

A service layer consists of three interface types:

  • Data interface: A data interface is a read-only presentation of a record, and therefore, this type of interface only has getters to represent a data record.
  • Repository interface: A repository interface gives access to read and write (and delete) data. Every repository interface has the following methods:
    • getList: This returns a list of records based on the (optionally) provided search parameters
    • get: This loads the data from the database and returns a data interface for the ...

Get Magento 2 - Build World-Class online stores now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.