Sunday, April 22, 2012

Understanding MVC Architecture

My question is - Is it a better MVC architecture to have a 1 to 1
relationship for a controller to access the model and the view, or since
in a case where all relationships stem from a single model - just make
the one controller have all the actions, but pull data from the related
models needed together to then send to a view.

Here is some code to help illustrate what I am talking about. ( I
removed a lot of configuration details, because it is not relevant for
the architecture discussion)

Organization Model
     $hasMany = array('OrganizationRole', 'Address', 'MemberRelationship');
     $belongsTo = array('User');

OrganizationRole Model
     $hasMany = array('OrganizationPermission', 'MemberRelationship');
     $belongsTo = array('Organization');

MemberRelationship Model
     $belongsTo = array('Organization', 'User', 'MembershipLevel',
'OrganizationRole');

OrganizationPermission Model
    $belongsTo = array('OrganizationRole');

User Model
     $hasMany = array('Organization', 'MemberRelationship', 'Address');


So, as you can see, everything is related to Organization either
directly or indirectly.  So, I am thinking of adding actions to
OrganizationsController to do things like viewMembers, editMembers,
deleteMembers, viewRoles, editRoles, assignRoles, etc
rather than putting calling view, edit, delete actions in
MemberRelationshipsController and OrganizationRolesControllers.

Any thoughts? Opinions? Suggestions?

Thanks,
Bill


View this message in context: Understanding MVC Architecture
Sent from the CakePHP mailing list archive at Nabble.com.

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.
 
 
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

No comments: