Kohana 3 module structure question

daniellemouse

New Member
everybody! I have a new question about Kohana 3, or rather about a module structure. I develop a small module called Textblock. It's about an ordinary page or a small insertion to the site layout (e.g. a greeting or a slogan, company name). It contains both controllers and models. Models inherit Sprig_MPTT. And one feature I'd like to implement is one could be able to call this module like this:\[code\]$textblock = Textblock::get_single(1); //by id$children = Textblock::get_children_of(4); //id of parent\[/code\]and not\[code\]$textblock = Sprig::factory('Textblock')->get_single(1);$children = Sprig::factory('Textblock')->get_children_of(4);\[/code\]Those methods are defined in Model_Textblock class as \[code\]static\[/code\].So, I made a wrapper class \[code\]Textblock\[/code\], that inherits \[code\]Model_Textblock\[/code\]. What if I suddenly want change Sprig to Jelly, for example? Foreground won't change at all. Another advantage, imho, is more clarity for anyone, who wants to use this module (e.g. it could be another programmer in the team).But there's a doubt if I'm on a wrong way... So, the question itself: is the suggested a right way to organize my module? Or it's preferable to keep ordinary \[code\]Sprig::factory('Textblock')\[/code\] where Textblock's functionality is needed, remove additional wrapper class and remove \[code\]static\[/code\]?
 
Back
Top