- Drupal 8 Module Development
- Daniel Sipos
- 123字
- 2021-07-02 15:45:15
Services
I don't like the Controller making the decision on how to greet my users, first of all, because Controllers need to stay lean. I want my users to be greeted a bit more dynamically, depending on the time of day, and that will increase the complexity. Second of all, maybe I will want this greeting to be done elsewhere also (as, it turns out, I will do), and there is no way I am copying and pasting this logic somewhere else, nor am I going to misuse the Controller just to be able to call that method. The solution? We delegate the logic of constructing the greeting to a service and use that service in our Controller to simply output the greeting.
推薦閱讀
- C++面向對象程序設計(第三版)
- C++ Primer習題集(第5版)
- 程序員修煉之道:程序設計入門30講
- 自己動手寫搜索引擎
- WordPress Plugin Development Cookbook(Second Edition)
- HTML5 and CSS3 Transition,Transformation,and Animation
- PhpStorm Cookbook
- 編寫高質量代碼:改善Objective-C程序的61個建議
- OpenStack Networking Essentials
- Mastering Gephi Network Visualization
- 30天學通C#項目案例開發
- 虛擬現實建模與編程(SketchUp+OSG開發技術)
- Getting Started with hapi.js
- Oracle SOA Suite 12c Administrator's Guide
- Swift Essentials(Second Edition)