# Dependency Retriever (woof!)

This package is a tool to make
[dependency injection](https://en.wikipedia.org/wiki/Dependency_injection) and 
class instantiation easier. Its API allows class' dependencies to be discovered 
and injected automatically by the factory.

Retrievers help you inject dependencies, even if you can't or won't from the 
calling code, by retrieving them based on suggestions from the class authors:

```php
use Psr\Log\LoggerInterface;

class Bar {

  /**
   * @suggestedDependency drupalContainerService:logger.channel.form $formLogger
   */
  public function __construct(LoggerInterface $formLogger) {
    // ...
  }

}
```

When used in a system in which Drupal's service container is available, the 
`logger.channel.form` service is a suggested dependency for the `$formLogger` 
parameter. The `drupalContainerService` retriever can retrieve this dependency 
and give it to the factory to be injected during class instantiation.

# Dependency Retriever (woof!)

[![Build Status](https://travis-ci.org/bartfeenstra/dependency-retriever.svg?branch=master)](https://travis-ci.org/bartfeenstra/dependency-retriever)

This package is a tool to make
[dependency injection](https://en.wikipedia.org/wiki/Dependency_injection) and 
class instantiation easier. Its API allows class' dependencies to be discovered 
and injected automatically by the factory.

Retrievers help you inject dependencies, even if you can't or won't from the 
calling code, by retrieving them based on suggestions from the class authors:

```php
use Psr\Log\LoggerInterface;

class Bar {

  /**
   * @suggestedDependency drupalContainerService:logger.channel.form $formLogger
   */
  public function __construct(LoggerInterface $formLogger) {
    // ...
  }

}
```

When used in a system in which Drupal's service container is available, the 
`logger.channel.form` service is a suggested dependency for the `$formLogger` 
parameter. The `drupalContainerService` retriever can retrieve this dependency 
and give it to the factory to be injected during class instantiation.

Add a Travis CI badge.
Add a Travis CI badge.
