2017 © Pedro Peláez
 

library aura-di-ext

Aura.Di Vocabulary Extension

image

lapaz/aura-di-ext

Aura.Di Vocabulary Extension

  • Thursday, June 8, 2017
  • by tanakahisateru
  • Repository
  • 1 Watchers
  • 0 Stars
  • 78 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 0 % Grown

The README.md

Aura.Di Vocabulary Extension

Build Status, (*1)

  • Optionally ->modifiedBy() and ->modifiedByScript() enabled after $di->lazyNew() and $di->newFactory().
  • New method ->newLocator() to create pure callable object that returns the service.
  • Optional parameter $params = [] added to ->lazyRequire() and lazyInclude().

(newLocator() is simply non lazy version of lazyGet().), (*2)

Unlike ContainerConfig::modify(), every modification is called on demand at the 1st time of ->get()., (*3)

Before

$di->set('routerContainer', $di->lazy(function () use ($di) {
    $routerContainer = $di->newInstance(\Aura\Router\RouterContainer::class, [], [
        'setLoggerFactory' => function () use ($di) {
            return $di->get('logger');
        },
        // Don't use ->lazyGet() because the returned lazy object would be evaluated before injection.
    ]);

    $map = $routerContainer->getMap();
    $map->get('index', '/');
    // ...

    return $routerContainer;
));

After

$dix = ContainerExtension::createFrom($di);

$di->set('routerContainer', $dix->lazyNew(\Aura\Router\RouterContainer::class, [], [
    'setLoggerFactory' => $dix->newLocator('logger'),
])->modifiedBy(function ($routerContainer) {
    $map = $routerContainer->getMap();
    $map->get('index', '/');
    // ...
));

Require/Include

$dix = ContainerExtension::createFrom($di);

$di->params[\Aura\Dispatcher\Dispatcher::class]['objects'] = $dix->lazyRequire(__DIR__ . '/objects.php', [
    'di' => $di,
    // 'anotherConfig' => ...
]);

You can use $di in objects.php to return configured lazy instances., (*4)

The Versions

08/06 2017

dev-master

9999999-dev

Aura.Di Vocabulary Extension

  Sources   Download

MIT

The Requires

 

The Development Requires

08/06 2017

0.2.0

0.2.0.0

Aura.Di Vocabulary Extension

  Sources   Download

MIT

The Requires

 

The Development Requires

26/05 2017

0.1.0

0.1.0.0

Aura.Di Vocabulary Extension

  Sources   Download

MIT

The Requires

 

The Development Requires