[development] is drupal a MVC stuff
Pierre Rineau
pierre.rineau at makina-corpus.com
Fri Dec 11 17:03:01 UTC 2009
On Fri, 2009-12-11 at 10:40 -0600, larry at garfieldtech.com wrote:
> The defining attribute of MVC is, IMO, that the View component has
> direct access to the Model component using an observer relationship,
> without going through a separate Controller.
>
> hook_page_alter() is in no way a direct observer relationship between
> the View component and the Model component. *_alter hooks are a
> pipes-and-filter approach, or, arguably, visitor pattern.
>
> Drupal is very much not an MVC design. It's not true PAC either, but I
> have and do argue that it is closer to PAC than MVC.
>
> Someone needs to correct the Wikipedia page, which is simply wrong in
> this regard.
>
> --Larry Garfield
If you want to stick to strict MVC definition, yes Drupal is not, but in
the most software I saw or developed with until now, not anyone had a
real MVC implementation.
In MVC, this Controller -> Model -> View (data flow)
In Drupal, data flow is:
- Controller (menu router) -> Model (menu callback, module code)
(direct association)
- Model (indirect association through the theme() calls) -> View
- View -> Controller (indirect association, through user clicks)
This is an incomplete and simple (without the observer/observable
pattern) implementation, but I think it does sticks to MVC pattern.
This is an opinion, I think it can be discussed.
Hook system is a different pattern used for different goals, mostly used
to alter data (it does not alter the behavior I described upper, except
maybe in some really weird cases).
Pierre.
Event if observer pattern is not really here, I think it sticks to MVC
pattern.
More information about the development
mailing list