Description:
Communicate between modules in MCV architecture like PhP’s Zend Framework.
Solution:
Communication between modules, in MCV architecture should not be done directly by calling the model class, but accessing a service class assigned to the model.
A service class represents the mirror image of the original model class.
Name of class: class ModuleName_Service_ClassName
Parameters: private $_model;
Methods: protected function _getModel()
After this previous requirements the model methods are described, just with function name and return value.
Example:
class Customer_Service_Address {
private $_model;
protected function _getModel() {
$this->_model = new Customer_Model_Address();
return $this->_model;
}public function updatePostcode($postcode) {
return $this->_getModel()->updatePostcode($postcode);
}}