- 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.
推薦閱讀
- OpenStack Cloud Computing Cookbook(Third Edition)
- Instant Testing with CasperJS
- Deploying Node.js
- Modular Programming with Python
- TypeScript Blueprints
- OpenCV實例精解
- Java編程指南:基礎(chǔ)知識、類庫應(yīng)用及案例設(shè)計
- C語言程序設(shè)計
- C語言程序設(shè)計
- Instant Lucene.NET
- Red Hat Enterprise Linux Troubleshooting Guide
- Java Web從入門到精通(第3版)
- C++ System Programming Cookbook
- 面向?qū)ο蟪绦蛟O(shè)計及C++(第3版)
- SAS編程演義