Lithium apps that go beyond CRUD

♀尐吖头ヾ 提交于 2019-12-04 05:26:21
Nervetattoo

One thing you have to remember with Lithium is that theres no production ready release yet (although some sites are using it in production). The main missing feature right now is model relations. With relations in place i assume your question would be partially answered as that is an important brick in the big picture of creating more complex applications. You could check out the x-data branch where the work on relations should be ongoing.

For the second part of writing domain logic the simple answer is "in the model". See this (rather useless) example of extending model functionality for example. Another example to look at is the open source mini application Analogue that is one of the few working open examples of Lithium in use. The Analogue model class shows a slightly more meaty model.

And finally its a matter of connecting the dots between M, V and C. A Lithium controller should mainly delegate jobs over to models, and perhaps restructure the input data if needed. The simple examples of having a Post model, PostsController and views/posts/add,index,etc doesn't mean that you have to merely have Post::all() in there. PostsController::view need to load a set of Comment models probably.

So you will toss a lot of your own code in there, of course! Else it would not be much of an application. But keep the domain logic tied to the model where it is natural.

  • Need to verify that blog post has a unique title? Write a validator.
  • Need to ensure the user has write access to the post? Override the save method and verify it, or filter it.

But I think we need to wait for relations to land and a 1.0 release before we can fully judge how structuring applications in Lithium can be solved best.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!