feat: add services section
This commit is contained in:
parent
849568f334
commit
73210a5fb6
1 changed files with 48 additions and 0 deletions
48
README.rst
48
README.rst
|
@ -8,6 +8,54 @@ Inspired by https://github.com/PovilasKorop/laravel-tips.
|
||||||
.. contents::
|
.. contents::
|
||||||
:depth: 2
|
:depth: 2
|
||||||
|
|
||||||
|
Services
|
||||||
|
========
|
||||||
|
|
||||||
|
Using a class name as a service name
|
||||||
|
------------------------------------
|
||||||
|
|
||||||
|
Before:
|
||||||
|
|
||||||
|
.. code:: yaml
|
||||||
|
|
||||||
|
# my_module.services.yml
|
||||||
|
|
||||||
|
services:
|
||||||
|
my_module.example_service:
|
||||||
|
class: Drupal\my_module\Service\ExampleService
|
||||||
|
|
||||||
|
After:
|
||||||
|
|
||||||
|
.. code:: yaml
|
||||||
|
|
||||||
|
# my_module.services.yml
|
||||||
|
|
||||||
|
services:
|
||||||
|
Drupal\my_module\Service\ExampleService: []
|
||||||
|
|
||||||
|
Automatically inject dependencies with autowiring
|
||||||
|
-------------------------------------------------
|
||||||
|
|
||||||
|
Before:
|
||||||
|
|
||||||
|
.. code:: yaml
|
||||||
|
|
||||||
|
# my_module.services.yml
|
||||||
|
|
||||||
|
services:
|
||||||
|
Drupal\my_module\Service\ExampleService:
|
||||||
|
arguments: ['@entity_type.manager']
|
||||||
|
|
||||||
|
After:
|
||||||
|
|
||||||
|
.. code:: yaml
|
||||||
|
|
||||||
|
# my_module.services.yml
|
||||||
|
|
||||||
|
services:
|
||||||
|
Drupal\my_module\Service\ExampleService:
|
||||||
|
autowire: true
|
||||||
|
|
||||||
Automated testing
|
Automated testing
|
||||||
=================
|
=================
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue