官术网_书友最值得收藏!

Services and the dependency injection container

Another architecturally important element of Drupal 8 is the Symfony dependency injection component (http://symfony.com/doc/current/components/dependency_injection.html), concretely represented by the service container.

This component is a staple of modern OOP PHP programming and as such has become foundational to Drupal 8. It allows us to create services that can be injected in various places (and receive themselves services as dependencies). They are then used for the heavy business logic of our functionality. Additionally, they are at times also used as an extension point because the service container is able to collect certain services that are marked as serving a specific purpose and use them automatically. In other words, simply by defining a simple service, we can provide our own functionality or even change the existing logic.

We will encounter many services, and we will see how we can declare our own later in this book.

主站蜘蛛池模板: 江门市| 广西| 石台县| 黄浦区| 吴桥县| 宜宾市| 泰和县| 日喀则市| 永川市| 蛟河市| 灵川县| 兴义市| 泰来县| 驻马店市| 昔阳县| 进贤县| 吉安市| 赤壁市| 叙永县| 沈阳市| 永修县| 九江市| 陆川县| 耒阳市| 兰考县| 南平市| 渑池县| 岑巩县| 郧西县| 垦利县| 镇江市| 沐川县| 道孚县| 太康县| 社会| 会同县| 东宁县| 淳化县| 日照市| 武强县| 卓尼县|