MVC is a really good example, but sometimes it’s very boring to put everything into controller methods. The controller is constantly growing, and it takes time to get rid of thousands of lines of code. Some people strongly recommend placing as much as possible in Model, but I prefer to keep the model clean (I did not put controllers in the model).
The idea is to put each Controller action in its own class ...
class Post_Add {}
class Post_Remove {}
class Post_View {}
All code that is common to all action classes that we put in class Post_Parentand pass it to the instance in the action constructor.
So, the calling action will look like ...
$parent = new Post_Parent();
$action = new Post_Add($parent);
$action->run();
So what do we have?
- ,
,
vars, , .
- (
Post_Parent)
.
ACL ..
? ?
.