php - How does the view communicate with the model? -
i wondering how view communicates model.
as understand controller directs correct information model.
class controller { public function action() { if(isset($_post) ) { $this->model->somemethod($_post['foo'],$_post['bar']); } } }
the model it's business.
class model { public function somemethod($foo,$bar) { // } }
the view has somehow know how communicate model it's current state. how done?
class view { public function action() { // ask model going on } }
how view know happened , if went correct way. though of getting state of model 'getstate()' method on model. state string view knows doesn't seem right way me. how view know if logged in example? should view know this?
it interesting, @ brief description of mvc pattern in gof's book, or @ original article pattern in smalltalk, see controller controls user interaction view.
view directly subscribed model changes. can have several views same model , each reflects model changes without controller.
a controller attached specific view handle user unput , transform higher level abstraction (i.e. intention update in model, or pass message subview, or else).
in gui, view subscribed model using implementation of observer pattern. in php not make sense, since rendered request (there no shared state between requests), thus, view can query method on model.
Comments
Post a Comment