2017 © Pedro Peláez
 

library dependency-retriever

image

bartfeenstra/dependency-retriever

  • Friday, March 25, 2016
  • by bartfeenstra
  • Repository
  • 1 Watchers
  • 2 Stars
  • 38 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 10 Versions
  • 0 % Grown

The README.md

Dependency Retriever (woof!)

Build Status, (*1)

This package is a tool to make dependency injection and class instantiation easier. Its API allows class' dependencies to be discovered and injected automatically by the factory., (*2)

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:, (*3)

use Psr\Log\LoggerInterface;

class Bar {

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

}

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., (*4)

$factory = new SimpleFactory(new AnnotatedFinder(), new DrupalContainerServiceRetriever());
$bar = $factory->instantiate(Bar::class, [
  'severity' => LogLevel::WARNING,
]);

In this example, Bar is instantiated using an overridden dependency (value) for $severity, but AnnotatedFinder, and the hypothetical DrupalContainerServiceRetriever provide the factory with a dependency for $formLogger based on Bar's @suggestedDependency annotation., (*5)

The Versions

25/03 2016

dev-master

9999999-dev

  Sources   Download

MIT

The Requires

  • php ~5.6 || ~7.0

 

The Development Requires

25/03 2016

0.4.3

0.4.3.0

  Sources   Download

MIT

The Requires

  • php ~5.6 || ~7.0

 

The Development Requires

19/03 2016

0.4.2

0.4.2.0

  Sources   Download

MIT

The Requires

  • php ~5.6 || ~7.0

 

The Development Requires

17/03 2016

0.4.1

0.4.1.0

  Sources   Download

MIT

The Requires

  • php ~5.6 || ~7.0

 

The Development Requires

17/03 2016

0.4.0

0.4.0.0

  Sources   Download

MIT

The Requires

  • php ~5.6 || ~7.0

 

The Development Requires

15/03 2016

0.3.2

0.3.2.0

  Sources   Download

MIT

The Requires

  • php ~5.6 || ~7.0

 

The Development Requires

15/03 2016

0.3.1

0.3.1.0

  Sources   Download

MIT

The Requires

  • php ~5.6 || ~7.0

 

The Development Requires

15/03 2016

0.3.0

0.3.0.0

  Sources   Download

MIT

The Requires

  • php ~5.6 || ~7.0

 

The Development Requires

09/03 2016

0.2.0

0.2.0.0

  Sources   Download

MIT

The Requires

  • php ~5.6 || ~7.0

 

The Development Requires

06/03 2016

0.1.0

0.1.0.0

  Sources   Download

MIT