I've been following article on Models and Resources here. According to my understanding, Magento2 uses service contract to provide model access to 3rd parties.
Here I'm interested in Data interface PostInterface.php which contains all constants and gettters/setter methods defined. Ex:
const POST_ID = 'post_id';
const URL_KEY = 'url_key';
public function getId();
public function getUrlKey();
public function setUrlKey($url_key);
Now these methods are also defined in the model Model/Post.php. Ex:
public function getUrlKey()
{
return $this->getData(self::URL_KEY);
}
Questions:
- If a model request is made from 3rd party, it will hit interfaces function & interfaces function will model's function?
- Is it necessary to use interfaces here if my modules doesn't uses or isn't needed by any 3rd party?
- How these functions interact with each other internally? Is there any case where I can use interface function
getUrlKey(), instead of model'sgetUrlKey()function, if I'm developing another module in Magento itself?