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

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.

主站蜘蛛池模板: 富阳市| 观塘区| 马鞍山市| 万年县| 上犹县| 射洪县| 达孜县| 南郑县| 丰顺县| 哈密市| 云安县| 无棣县| 柘荣县| 马山县| 永昌县| 镇远县| 繁昌县| 西林县| 丰镇市| 涞水县| 延津县| 大关县| 福泉市| 新河县| 兴国县| 公主岭市| 凯里市| 宜兰市| 商南县| 秀山| 天镇县| 调兵山市| 白玉县| 名山县| 平顶山市| 远安县| 博罗县| 象山县| 云林县| 西贡区| 缙云县|