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

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.

主站蜘蛛池模板: 探索| 松原市| 中方县| 肥乡县| 双城市| 灵宝市| 玛多县| 博客| 镇江市| 汝阳县| 公安县| 会东县| 苍梧县| 治县。| 泸溪县| 蒙山县| 汨罗市| 宣城市| 固安县| 观塘区| 茂名市| 杭州市| 海口市| 汶上县| 砀山县| 宽甸| 新密市| 黔南| 报价| 崇州市| 新巴尔虎左旗| 太谷县| 安化县| 武威市| 定远县| 余庆县| 庆城县| 翁源县| 宁南县| 潞西市| 张北县|