Skip to content

Commit 2011fb4

Browse files
committed
di: documented @type as service key for modifications
1 parent dadb2bb commit 2011fb4

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

dependency-injection/cs/services.texy

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -433,8 +433,14 @@ services:
433433
application.application:
434434
create: MyApplication
435435
alteration: true
436-
setup:
437-
- '$onStartup[]' = [@resource, init]
436+
```
437+
438+
Službu nemusíte identifikovat interním názvem, můžete na ni odkázat i jejím typem. Předchozí příklad tak lze zapsat i takto:
439+
440+
```neon
441+
services:
442+
@Nette\Application\Application:
443+
create: MyApplication
438444
```
439445

440446
Při přepisování služby můžeme chtít odstranit původní argumenty, položky setup nebo tagy, k čemuž slouží `reset`:

dependency-injection/en/services.texy

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -433,8 +433,14 @@ services:
433433
application.application:
434434
create: MyApplication
435435
alteration: true
436-
setup:
437-
- '$onStartup[]' = [@resource, init]
436+
```
437+
438+
You don't have to identify a service by its internal name — you can refer to it by type instead. The previous example can also be written as:
439+
440+
```neon
441+
services:
442+
@Nette\Application\Application:
443+
create: MyApplication
438444
```
439445

440446
When modifying a service, we might want to remove original arguments, setup items, or tags, using the `reset` key:

0 commit comments

Comments
 (0)