[eluser]goliatone[/eluser]
Hi there,
Here is the situation: How to relate add-on modules' models with "global" models?
I have this application which uses some general models that reside on the top level modules directory ( application/models).
Then there are different modules ( i.e. pages ) which contains module specific models ( applications/modules/pages/page)
I want to create an advanced DMZ relationship (editor) between page and user such as:
Page:
Code:
class Page extends DataMapper {
$has_one = array(
'editor' => array(
'class' => 'user',
'other_field' => 'edited_page'
)
);
}
User:
Code:
class User extends DataMapper {
$has_many = array(
'edited_page' => array(
'class' => 'page',
'other_field' => 'editor'
)
);
}
How could I manage this dependency in a way that doesn´t break modularity? One benefit of having modules is that you can separate concerns, but since my Page is physically dependent on User by having to type its relationship with Page it breaks the deal.
If i know beforehand what modules i have, and what are they relationships with User, I can hard code them no problem. The issue is with modules that are supposed to be loaded to extend the application as an add-on(Wordpress like plugin).
One way I thought to solve the problem would be the following:
Since all the add-on modules have an install controller that create database tables and stuff like that, I could then edit the
user.php file adding the dependencies of the add-on.
Another approach, more complicated, would be to use a DDBB table containing the all the relationships, and recreate a php file every time the table is modified and in the
user.php include that file.
I'm sure some of you faced the same problem before, what where your solutions? How would you do this?
ps:
Sorry is this issue is addressed somewhere else in the forums or wiki, I did search but found nothing relevant.