Skip to content

Commit cf98bba

Browse files
committed
di: documented @type as service key for modifications
1 parent f02b326 commit cf98bba

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

dependency-injection/cs/services.texy

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,14 @@ services:
437437
- '$onStartup[]' = [@resource, init]
438438
```
439439

440+
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:
441+
442+
```neon
443+
services:
444+
@Nette\Application\Application:
445+
create: MyApplication
446+
```
447+
440448
Při přepisování služby můžeme chtít odstranit původní argumenty, položky setup nebo tagy, k čemuž slouží `reset`:
441449

442450
```neon

dependency-injection/en/services.texy

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,14 @@ services:
437437
- '$onStartup[]' = [@resource, init]
438438
```
439439

440+
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:
441+
442+
```neon
443+
services:
444+
@Nette\Application\Application:
445+
create: MyApplication
446+
```
447+
440448
When modifying a service, we might want to remove original arguments, setup items, or tags, using the `reset` key:
441449

442450
```neon

0 commit comments

Comments
 (0)