/** * Define Aura\View and Aura\Html factories and services * * @param Container $di DI Container * * @return void * * @access public * * @SuppressWarnings(PHPMD.ShortVariable) */ public function define(Container $di) { /** * Services */ $di->set('application/domain:postGateway', $di->lazyNew('Application\\Data\\Gateway\\PostSqlite')); /** * Aura.view */ // Aura\Html $di->set('aura/html:factory', $di->lazyNew(HelperLocatorFactory::class)); $di->set('aura/html:helpers', $di->lazyGetCall('aura/html:factory', 'newInstance')); // Aura\View $di->set('aura/view:factory', $di->lazyNew(ViewFactory::class)); $di->set('aura/view:view', $di->lazyGetCall('aura/view:factory', 'newInstance', $di->lazyGet('aura/html:helpers'))); // view files and paths from class $viewsconfig = new \Application\Config\AuraViews(); $views = $viewsconfig->getViews(); /** * Parameters */ // lazy load $di->params['Application\\Domain\\Aura']['payload'] = $di->lazyNew('Aura\\Payload\\Payload'); // binding variables to classes $di->params['Application\\Responder\\AuraViewStaticPage']['views'] = $views; // refactor or drop this $di->params['Application\\Responder\\AuraViewResponder']['views'] = $views; // domains $di->params['Application\\Domain\\Page']['postGateway'] = $di->lazyGet('application/domain:postGateway'); }
public function define(Container $di) { $di->set('http_middlewares', $di->lazyNew('asylgrp\\workbench\\Http\\Middleware\\MiddlewareQueue')); $di->set('http_emitter', $di->lazyNew('Zend\\Diactoros\\Response\\SapiEmitter')); $di->set('http_runner', $di->lazyNew('Relay\\Runner', ['queue' => $di->lazyGetCall('http_middlewares', 'asArray')])); $di->set('http_request', $di->lazy(['Zend\\Diactoros\\ServerRequestFactory', 'fromGlobals'])); $di->set('http_response', $di->lazyNew('Zend\\Diactoros\\Response')); $di->set('event_dispatcher', $di->lazyNew('Symfony\\Component\\EventDispatcher\\EventDispatcher')); $di->types['Symfony\\Component\\EventDispatcher\\EventDispatcherInterface'] = $di->lazyGet('event_dispatcher'); $di->set('contact_storage', $di->lazy(function () use($di) { return new \asylgrp\workbench\Storage\ContactStorage(new \asylgrp\workbench\Storage\Mapper(new \asylgrp\workbench\Storage\JsonFileHandle($di->get('settings')->read('db.contacts')), $di->newInstance('asylgrp\\workbench\\Storage\\Arrayizer\\ContactArrayizer'))); })); $di->types['asylgrp\\workbench\\Storage\\ContactStorage'] = $di->lazyGet('contact_storage'); $di->params['asylgrp\\workbench\\Storage\\ClaimStorage']['file'] = $di->lazyNew('asylgrp\\workbench\\Storage\\JsonFileHandle', [$di->lazyGetCall('settings', 'read', 'db.claims')]); $di->set('claim_storage', $di->lazyNew('asylgrp\\workbench\\Storage\\ClaimStorage')); $di->types['asylgrp\\workbench\\Storage\\ClaimStorage'] = $di->lazyGet('claim_storage'); $di->params['Aura\\Router\\RouterContainer']['basepath'] = $di->lazyGetCall('settings', 'read', 'api.base_path'); $di->set('router_container', $di->lazyNew('Aura\\Router\\RouterContainer')); $di->set('router_map', $di->lazyGetCall('router_container', 'getMap')); $di->set('router_matcher', $di->lazyGetCall('router_container', 'getMatcher')); $di->types['Aura\\Router\\Matcher'] = $di->lazyGet('router_matcher'); $di->set('router_generator', $di->lazyGetCall('router_container', 'getGenerator')); $di->types['Aura\\Router\\Generator'] = $di->lazyGet('router_generator'); }
/** * Define Auth * * @param Container $di DESCRIPTION * * @return mixed * * @access protected * * @SuppressWarnings(PHPMD.ShortVariable) */ protected function defineAuth(Container $di) { $di->params['Aura\\Auth\\AuthFactory']['cookie'] = $di->lazyValue('cookie'); $di->set('aura/auth:factory', $di->lazyNew('Aura\\Auth\\AuthFactory')); if (!$di->has('aura/auth:adapter')) { $di->set('aura/auth:adapter', $di->lazyNew('Aura\\Auth\\Adapter\\NullAdapter')); } $di->set('aura/auth:auth', $di->lazyGetCall('aura/auth:factory', 'newInstance')); $di->set('aura/auth:login', $di->lazyGetCall('aura/auth:factory', 'newLoginService', $di->lazyGet('aura/auth:adapter'))); $di->set('aura/auth:logout', $di->lazyGetCall('aura/auth:factory', 'newLogoutService', $di->lazyGet('aura/auth:adapter'))); $di->set('aura/auth:resume', $di->lazyGetCall('aura/auth:factory', 'newResumeService', $di->lazyGet('aura/auth:adapter'))); }