I have an Intranet system in my own bare bones MVC framework that has lots of very unrelated sections to it, each one has it's own Controller/Model/Views. As it's developed it's become apparent that lots of these sections would benefit by being able to interact with each other in certain ways. For instance a random model doing x to be able to speak to the holiday booking system to see if y is off between today and tomorrow. At the moment I've duplicated some code to achieve this, I know this is poor design but as often is the case it was for features that were required immediately - I now want to go back in and clean it up, so that I can sleep at night again.
To implement this my thought is to write an API class for each of the most useful sections where this would apply that would allow models of other sections to use them. Then use it as either:
$holiday = new Holiday();
$holiday->isOff($user_id)->between('0000-00-00','0000-00-01);
or
Holiday::isOff($user_id)->between('0000-00-00','0000-00-01);
Are there any better ways of doing this, as technically the API class itself would duplicate a lot of the models code (unless the model used the API class also?!) what's the status quo of achieving this kind of communication between seemingly unrelated sections of these types of applications?
Aucun commentaire:
Enregistrer un commentaire