Skip to content

Commit 38e8e2b

Browse files
committed
Merge pull request #10 from skylying/patch-7
Update ioc-container
2 parents 0f0864a + 4f1b0c9 commit 38e8e2b

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

.vaseman/entries/documentation/start/ioc-container.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Use internal container in controller and Application:
2020
$session = $this->container->get('system.session');
2121
```
2222

23-
Or use `Ioc` static class to get it:
23+
Or use static method in `Ioc` class to get it:
2424

2525
``` php
2626
$container = \Windwalker\Ioc::factory(); // This container is singleton
@@ -36,7 +36,7 @@ $container->set('my.input', $input);
3636
$input = $container->get('my.input');
3737
```
3838

39-
Or directly get it by `Ioc`:
39+
Or get it by `Ioc:get()` statically:
4040

4141
``` php
4242
\Windwalker\Ioc::get('my.input');
@@ -68,7 +68,7 @@ Directly get object from sub container by `Ioc`:
6868

6969
# Lazy Loading
7070

71-
Sometimes we will hope not create object instantly, we can use callback to create object.
71+
Use callback function as input value if we do not want to create object instantly.
7272

7373
``` php
7474
// Set a closure into it
@@ -81,7 +81,7 @@ $container->set('input', function(Container $container)
8181
$input = $container->get('input');
8282
```
8383

84-
But if we use `set()` method to set callback, this object will be recreated when every time we try to get it.
84+
But if we use `set()` method to set callback, this object will be re-created everytime.
8585

8686
# Shared Object (Singleton)
8787

@@ -97,7 +97,7 @@ $container->share('input', function(Container $container)
9797
// Will will always get same instance
9898
$input = $container->get('input');
9999

100-
// The second argument of get() can force create new instance
100+
// The second argument of get() is whether forced to create new instance or not
101101
$newInput = $container->get('input', true);
102102

103103
// Use readable constant
@@ -106,7 +106,7 @@ $newInput = $container->get('input', Container::FORCE_NEW);
106106

107107
# Protect Object
108108

109-
Use `protect()` to prevent others override your important object.
109+
Use `protect()` to prevent others from overriding your important object.
110110

111111
``` php
112112
$container->protect(
@@ -195,7 +195,7 @@ abstract class Ioc extends \Windwalker\Core\Ioc
195195

196196
# Build Object
197197

198-
Container can build an object and auto inject the needed dependency objects.
198+
Container can build an object and automatically inject all the necessary dependencies.
199199

200200
``` php
201201
use Windwalker\IO\Input;
@@ -282,7 +282,7 @@ $flower->name; // sakura
282282

283283
# Container Aware
284284

285-
The `ContainerAwareInterface` help us get and set Container as a system, constructor, we often use it on application or controller classes.
285+
The `ContainerAwareInterface` defines getter & setter of Container as a system, constructor, we often use it on application or controller classes.
286286

287287
``` php
288288
use Windwalker\DI\ContainerAwareInterface;

0 commit comments

Comments
 (0)