- Drupal 8 Module Development
- Daniel Sipos
- 236字
- 2021-07-02 15:45:15
What is a service?
A service is an object that gets instantiated by a Service Container and is used to handle operations in a reusable way, for example, performing calculations and interacting with the database, an external API, or any number of things. Moreover, it can take dependencies (other services) and use them to help out. Services are a core part of the dependency injection (DI) principle that is commonly used in modern PHP applications and in Drupal 8.
If you don't have any experience with these concepts, an important thing to note is also that they are globally registered with the service and instantiated only once per request. This means that altering them after you requested them from the container means that they stay altered even if you request them again. In essence, they are singletons. So, you should write your services in such a way that they stay immutable, and most of the data they need to process is either from a dependency or passed in from the client that uses it (and does not affect it).
- Learn ECMAScript(Second Edition)
- Monkey Game Development:Beginner's Guide
- 新手學Visual C# 2008程序設計
- C語言從入門到精通(第4版)
- 微信公眾平臺開發:從零基礎到ThinkPHP5高性能框架實踐
- 基于Swift語言的iOS App 商業實戰教程
- 精通網絡視頻核心開發技術
- SharePoint Development with the SharePoint Framework
- Java Web程序設計任務教程
- Java網絡編程實戰
- Python數據可視化之美:專業圖表繪制指南(全彩)
- 零基礎看圖學ScratchJr:少兒趣味編程(全彩大字版)
- 數據結構:Python語言描述
- Java多線程并發體系實戰(微課視頻版)
- JavaWeb從入門到精通(視頻實戰版)