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

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.

主站蜘蛛池模板: 磐安县| 龙陵县| 湖州市| 漯河市| 柳州市| 清涧县| 来宾市| 罗甸县| 贵南县| 大化| 台南市| 衡阳县| 寿宁县| 东乌珠穆沁旗| 泌阳县| 会同县| 尉犁县| 阿克苏市| 蓝山县| 文化| 衡南县| 仪征市| 江都市| 平罗县| 如皋市| 衡南县| 齐齐哈尔市| 沙坪坝区| 岐山县| 喀什市| 达孜县| 衡阳市| 闽侯县| 巴林左旗| 军事| 富裕县| 洱源县| 德庆县| 肇州县| 共和县| 朝阳区|