Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
Gappa authored and Milan Felix Šulc committed Aug 22, 2018
1 parent e8fcbfb commit 05eaf5c
Showing 1 changed file with 23 additions and 23 deletions.
46 changes: 23 additions & 23 deletions .docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@

## ResourceExtension

At first, you have to register extension.
First, you have to register the extension.

```yaml
extensions:
autoload: Contributte\DI\Extension\ResourceExtension
```

Secondly, define some resources.
Second, define some resources.

```yaml
autoload:
Expand All @@ -27,9 +27,9 @@ autoload:
paths: [%appDir%/model/services]
```

> It maybe looks familiar to you. You're right idea comes from [Symfony 3.3](http://symfony.com/doc/current/service_container/3.3-di-changes.html#the-new-default-services-yml-file).
> It may look familiar to you. You're right, the idea comes from [Symfony 3.3](http://symfony.com/doc/current/service_container/3.3-di-changes.html#the-new-default-services-yml-file).
That's all, `ResourceExtension` will try to register all non-abstract instantiable classes to container.
That's all, the `ResourceExtension` will try to register all non-abstract instantiable classes to the container.

### Resources

Expand All @@ -47,19 +47,19 @@ autoload:

### Performance

Service loading is triggered only once at dependency injection container compile-time. You should be pretty fast,
almost as [official registering presenter as services](https://api.nette.org/2.4/source-Bridges.ApplicationDI.ApplicationExtension.php.html#121-160).
Service loading is triggered only once at dependency injection container compile-time. It should be pretty fast,
almost as [official registering of presenters as services](https://api.nette.org/2.4/source-Bridges.ApplicationDI.ApplicationExtension.php.html#121-160).

## ContainerAware

This package provide missing `IContainerAware` interface for you Applications.
This package provides the missing `IContainerAware` interface for your applications.

```yaml
extensions:
aware: Contributte\DI\Extension\ContainerAwareExtension
```

From that moment you can use `IContainerAware` interface and let container inject.
From that moment you can use the `IContainerAware` interface and let the container inject.

```php
<?php
Expand All @@ -83,7 +83,7 @@ final class LoggableCachedEventDispatcher implements IContainerAware
}
```

Don't repeat yourself, use `TContainerAware` trait.
Don't repeat yourself, use the `TContainerAware` trait.

```php
<?php
Expand Down Expand Up @@ -128,9 +128,9 @@ $class = $loader->load(function (Compiler $compiler): void {

## InjectValueExtension

This **awesome** extension allow you to inject values directly into public properties.
This **awesome** extension allows you to inject values directly into public properties.

Let's say, we have service like this:
Let's say we have a service like this:

```php
class FooPresenter extends Presenter
Expand All @@ -142,7 +142,7 @@ class FooPresenter extends Presenter
}
```

At first register `InjectValueExtension` under `extensions` key.
First, register `InjectValueExtension` under `extensions` key.

```yaml
extensions:
Expand All @@ -152,9 +152,9 @@ injectValue:
all: on/off
```

By default, extension `inject values` only for services having `inject.value` tag.
You can override it to inject to all services by define `all: on`. Or follow the prefer way
and use Nette\DI decorator.
By default, the extension `injects values` only for services having the `inject.value` tag.
You can override it to inject to all services by defining `all: on`. Or follow the preferred way
and use the Nette\DI decorator.

```yaml
decorator:
Expand All @@ -165,7 +165,7 @@ decorator:
tags: [inject.value]
```

After all, the when the `FooPresenter` in created it will have filled `$bar` property with `<path>/www/baz`. Cool right?
In the end, after creating the `FooPresenter`, the `$bar` property will be filled with `<path>/www/baz`. Cool right?

## PassCompilerExtension

Expand All @@ -186,7 +186,7 @@ final class FoobarExtension extends PassCompilerExtension
}
```

Extending `AbstractPass` define 3 methods:
Extending `AbstractPass` defines 3 methods:

- `loadPassConfiguration`
- `beforePassCompile`
Expand All @@ -209,10 +209,10 @@ class PartAPass extension AbstractPass

## NewExtensionsExtension

From time to time you get into the point when you have a lot of extensions. Some depends on others and reverse.
Therefore comes the need of `NewExtensionsExtension`.
From time to time you get to the point when you have a lot of extensions. Some depend on other and vice-versa.
Therefore the need for `NewExtensionsExtension` arises.

In classic Nette application you will see something like that:
In a classic Nette application you will see something like this:

```yaml
extensions:
Expand All @@ -222,10 +222,10 @@ extensions:
baz2: App\DI\Baz2Extension
```

The `bar` & `baz` require to have `foo` registered. How can resolve it?
The `bar` & `baz` require to have `foo` registered. How to solve this?

At first you have to replace default `extensions` extension, yes, it's name is `extensions`! Change it manually
or via `ConfiguratorHelper` class.
First, you have to replace default `extensions` extension, yes, it's name is `extensions`! Change it manually
or via the `ConfiguratorHelper` class.

**Manual replacement**

Expand Down

0 comments on commit 05eaf5c

Please sign in to comment.