Open ashsmith opened 7 years ago
We should follow best practises set out by Magento by using data models to access our blog posts.
I'm going to implement the following
Ashsmith\Blog\Api\Data\PostInterface
Ashsmith\Blog\Api\PostRepositoryInterface
Ashsmith\Blog\Model\PostRepository
Ashsmith\Blog\Model\Data\Post
Then modify Ashsmith\Blog\Model\Post so that it no longer uses the interface, and has the method getDataModel.
Ashsmith\Blog\Model\Post
getDataModel
PostRepositoryInterface should define the following methods:
PostRepositoryInterface
getById($postId)
getList(\Magento\Framework\Api\SearchCriteriaInterface $searchCriteria)
delete(\Ashsmith\Blog\Api\Data\PostInterface $post)
deleteById($postId)
Any reference to loading the collections, or the original Post model directly will be switched out for the PostRepository.
We should follow best practises set out by Magento by using data models to access our blog posts.
I'm going to implement the following
Ashsmith\Blog\Api\Data\PostInterface
(this already exists)Ashsmith\Blog\Api\PostRepositoryInterface
Ashsmith\Blog\Model\PostRepository
Ashsmith\Blog\Model\Data\Post
Then modify
Ashsmith\Blog\Model\Post
so that it no longer uses the interface, and has the methodgetDataModel
.PostRepositoryInterface
should define the following methods:getById($postId)
getList(\Magento\Framework\Api\SearchCriteriaInterface $searchCriteria)
delete(\Ashsmith\Blog\Api\Data\PostInterface $post)
deleteById($postId)
Any reference to loading the collections, or the original Post model directly will be switched out for the PostRepository.