/** * Sets up the locator based on the configuration provided * * @param AppContext $application * @return void */ protected function setupLocator(AppContext $application) { $di = new Di(); $di->instanceManager()->addTypePreference('Zend\\Di\\Locator', $di); $config = new DiConfiguration($this->config->di); $config->configure($di); $application->setLocator($di); }
public function defineDependencies() { $definition = new Definition\AggregateDefinition; $this->_di = new DependencyInjector; $this->_di->setDefinition($definition); $config = new Configuration($this->_config->di); $config->configure($this->_di); $this->_di->getDefinition()->addDefinition(new Definition\RuntimeDefinition); }
public function defineDependencies() { $definition = new Definition\AggregateDefinition(); $this->di = new DependencyInjector(); $this->di->setDefinition($definition); $config = new Configuration($this->config->di); $config->configure($this->di); $this->di->getDefinition()->addDefinition(new Definition\RuntimeDefinition()); \edp\Mvc\ActionController::$di = $this->di; }
/** * Sets up the locator based on the configuration provided * * @param AppContext $application * @return void */ protected function setupLocator(AppContext $application) { $di = new Di(); $di->instanceManager()->addTypePreference('Zend\\Di\\Locator', $di); // Default configuration for common MVC classes $diConfig = new DiConfiguration(array('definition' => array('class' => array('Zend\\Mvc\\Router\\RouteStack' => array('instantiator' => array('Zend\\Mvc\\Router\\Http\\TreeRouteStack', 'factory')), 'Zend\\Mvc\\Router\\Http\\TreeRouteStack' => array('instantiator' => array('Zend\\Mvc\\Router\\Http\\TreeRouteStack', 'factory')), 'Zend\\Mvc\\View\\DefaultRenderingStrategy' => array('setLayoutTemplate' => array('layoutTemplate' => array('required' => false, 'type' => false))), 'Zend\\Mvc\\View\\ExceptionStrategy' => array('setDisplayExceptions' => array('displayExceptions' => array('required' => false, 'type' => false)), 'setExceptionTemplate' => array('exceptionTemplate' => array('required' => false, 'type' => false))), 'Zend\\Mvc\\View\\RouteNotFoundStrategy' => array('setDisplayNotFoundReason' => array('displayNotFoundReason' => array('required' => false, 'type' => false)), 'setNotFoundTemplate' => array('notFoundTemplate' => array('required' => false, 'type' => false))), 'Zend\\View\\HelperBroker' => array('setClassLoader' => array('required' => true, 'loader' => array('type' => 'Zend\\View\\HelperLoader', 'required' => true))), 'Zend\\View\\HelperLoader' => array('registerPlugins' => array('map' => array('type' => false, 'required' => false))), 'Zend\\View\\Renderer\\PhpRenderer' => array('setBroker' => array('required' => true, 'broker' => array('type' => 'Zend\\View\\HelperBroker', 'required' => true)), 'setCanRenderTrees' => array('required' => false, 'renderTrees' => array('type' => false, 'required' => true)), 'setResolver' => array('required' => false, 'resolver' => array('type' => 'Zend\\View\\Resolver', 'required' => true))), 'Zend\\View\\Resolver\\AggregateResolver' => array('attach' => array('resolver' => array('required' => false, 'type' => 'Zend\\View\\Resolver'))), 'Zend\\View\\Resolver\\TemplatePathStack' => array('setDefaultSuffix' => array('defaultSuffix' => array('required' => false, 'type' => false)), 'setPaths' => array('paths' => array('required' => false, 'type' => false))), 'Zend\\View\\Strategy\\PhpRendererStrategy' => array('setContentPlaceholders' => array('contentPlaceholders' => array('required' => false, 'type' => false))))))); $diConfig->configure($di); $config = new DiConfiguration($this->config->di); $config->configure($di); $application->setLocator($di); }
/** * Provide a configuration object to configure this instance * * @param Configuration $config * @return void */ public function configure(Configuration $config) { $config->configure($this); }
/** * @group nullargs */ public function testNullArgumentsResultInEmptyMethodParameterList() { $this->markTestIncomplete('Null arguments are currently unsupported'); $opt = new Builder\PhpClass(); $opt->setName('ZendTest\Di\TestAsset\OptionalArg'); $optCtor = new Builder\InjectionMethod(); $optCtor->setName('__construct') ->addParameter('param', null); $optInject = new Builder\InjectionMethod(); $optInject->setName('inject') ->addParameter('param1', null) ->addParameter('param2', null); $opt->addInjectionMethod($optCtor) ->addInjectionMethod($optInject); $def = new Definition(); $def->addClass($opt); $this->di->setDefinition($def); $cfg = new Configuration(array( 'instance' => array( 'alias' => array('optional' => 'ZendTest\Di\TestAsset\OptionalArg'), ), 'properties' => array( 'ZendTest\Di\TestAsset\OptionalArg' => array( 'param' => null, 'param1' => null, 'param2' => null, ), ), )); $cfg->configure($this->di); $builder = new ContainerGenerator($this->di); $builder->setContainerClass('Container'); $codeGen = $builder->getCodeGenerator(); $classBody = $codeGen->generate(); $this->assertNotContains('NULL)', $classBody, $classBody); }