Question

I have some questions about the structure of ZF modules and models.

(I'm talking about ZF 2, because I gave up of ZF 1.11)

To make my question simple to understand, look at the following example: (I create this just to learn ZF2)

Movie Manager DataBase

It's a "movie manager application". In this application I have 3 kind of users:

- visitors: peolple who olny can see the movies in the database.
- members: same as visitors plus insert, update and delete movies.
- administrator: same as members plus insert, update and delete users and other informations as genre, artist, ...

members can't insert nothing more than a new movie, i. e., they can't insert a new genre, neither a new artist.

ok... for this problem, I found this solution:

- create 3 modules: visitor, member, admin;

but I'm not sure if it's the best way of organize de program...

I realize that ZF expects people organize application this way:

- create modules for each funcionallity;
- create roles for each kind of user;

so, my questions are:

1. My solution is right or wrong?
2. If my solution is right, how can I organize my application?
3. How can I organize my models, to be visible to more than one module?
- I think a should create a model "movie" somewhere if "inserts, updates, deletes, and selects"
then a module "visitor" could only use a "select" while a module "member" could use all the funcionallities. Am I right?

4. If my solution is not right, how can I organize my application?
5. How should be my modules?

I really stuck with this problem. A couldn't find answers anywhere... If someone have a little application like this one and you don't mind to share, I'll be glad.

if I'm not clear at my questions, please ask!

Thank you for your help.

Was it helpful?

Solution

What is see here is a database model and therefore the main question for me is how to manage the data. In a MVC pattern you manage data with models. As much as I can tell here your question should not be related or limited to ZF2. Like in earlier versions you should have models to managed the database and data tables.

The modules will handle the application aspect. When you have a solid model for the data (people, genre, users, movies) you can create dozens of modules accessing the models. Hence you can have lots and lots of modules for different purposes but always the same model.

You can have a module that only handles user management, one that only manages (add/update) movies and another that only list (read) movies, etc.

OTHER TIPS

I think you could do most of this in one ZF2 module, maybe called "MovieManager". Movie and Person could be models (i.e. base classes and database tables) within the MovieManager module's namespace.

User could be a separate module, for handling user authentication and access control. You might take a look at the work that Evan Coury has done on a reusable ZF2 user module: https://github.com/Zf-Commons/ZfcUser Or you could keep it simple and put the User model inside your MovieManager module as well.

I would use Zend_Acl to define what operations a given User is allowed to perform. Or you could do that more simply by having a basic "role" property in the User class and checking for authorized roles in your MovieManager controllers.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top