Skip to content

Commit 55bdcbf

Browse files
committed
Readme.md - Add example to access Enabler in Nette
1 parent 78ba2e7 commit 55bdcbf

File tree

1 file changed

+28
-2
lines changed

1 file changed

+28
-2
lines changed

README.md

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,9 @@ $debugMode = $detector->isDebugMode(); // boolean
2828
```
2929
where `$tempDir` is required absolute path to temporary directory.
3030

31-
It returns `$debudMode` = `true` when is detected Debug environment or manually switched.
31+
It returns `$debugMode` = `true` when is detected Debug environment or manually switched.
3232

3333
### Using with Nette
34-
3534
In `\App\Bootstrap` class use package like this example:
3635
```php
3736
$tempDir = __DIR__ . '/../temp';
@@ -79,6 +78,33 @@ $enabler->activate(true);
7978
- `$enabler->activate(false)` - force to Debug Mode turn off,
8079
- `$enabler->deactivate(false)` - reset back to automatically detection by environment.
8180

81+
### Using with Nette
82+
Debug Mode Enabler (unlike Debug Mode Detector) can be simply served through DI Container with configuration in `config.neon`:
83+
```yaml
84+
services:
85+
- Redbitcz\DebugMode\DebugModeEnabler(%tempDir%)
86+
```
87+
88+
At most cases this example is creates second instance of `DebugModeEnabler` class because first one is already created
89+
internally with `DebugModeDetector` instance in `Bootstrap`.
90+
91+
To re-use already exists instance you can inject it to DI Container:
92+
```php
93+
$tempDir = __DIR__ . '/../temp';
94+
$debugModeDetector = new \Redbitcz\DebugMode\DebugModeDetector($tempDir);
95+
96+
$configurator = new Configurator();
97+
$configurator->setDebugMode($debugModeDetector->isDebugMode());
98+
$configurator->addServices(['debugModeEnabler' => $debugModeDetector->getEnabler()]);
99+
```
100+
101+
Don't forget let it know to DI Container with service declaration in `config.neon`:
102+
```yaml
103+
services:
104+
debugModeEnabler:
105+
type: Redbitcz\DebugMode\DebugModeEnabler
106+
```
107+
82108
License
83109
-------
84110
The MIT License (MIT)

0 commit comments

Comments
 (0)