Search
Ninja Application structure, part 2
To give a somewhat better understanding on how the classes (controllers and models respectively) are related to each other I will here show some (really simple) architecture sketches.<br /><br /><span style="font-weight:bold;">Controllers</span><br /><a target="_blank" rel="nofollow" onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_cu2YE9iTvlY/SdYA4MVywjI/AAAAAAAABPo/BkuFyrbLrj4/s1600-h/mvc_controller.png"><img style="float:right; margin:0 0 10px 10px;cursor:pointer; cursor:hand;width: 400px; height: 292px;" src="http://3.bp.blogspot.com/_cu2YE9iTvlY/SdYA4MVywjI/AAAAAAAABPo/BkuFyrbLrj4/s400/mvc_controller.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5320440975170126386" /></a>This shows how the base controllers are connected: Our Ninja controller extends the kohana base controller and is in charge of creating translation (gettext) object instances, database connection, session etc. Extending this we have default which doesn't require any login or anything - a typical start page and login controller.<br /><br />As you might have guessed, the Authenticated_Controller takes care of authenticating users (more on this in some later post). All controllers that should require an authenticated user, should extend this class as does the tac controller in the sketch above.<br /><br /><span style="font-weight:bold;">Models</span><br /><a target="_blank" rel="nofollow" onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_cu2YE9iTvlY/SdYBedLAr0I/AAAAAAAABPw/88kqgdiOb98/s1600-h/mvc_model.png"><img style="float:right; margin:0 0 10px 10px;cursor:pointer; cursor:hand;width: 305px; height: 231px;" src="http://2.bp.blogspot.com/_cu2YE9iTvlY/SdYBedLAr0I/AAAAAAAABPw/88kqgdiOb98/s400/mvc_model.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5320441632523333442" /></a>Here we also have a base Ninja class - the Ninja Model which also makes sure that application specific variables and objects are present.<br />All Ninja models should consequently extend this model.<br /><br />This is brief overview of how the Ninja classes should be extended in order to save us from writing things several times and to be sure that we preserve the basic functionality. Hopefully it has given anyone interested a slightly better understanding.<br /><br />Once again - this is to be considered a draft and is subject to change.<div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9144504490896973295-1309994171035037201?l=ninja4nagios.blogspot.com'/></div>