public function configureDefinition(DependencyInjector $di, $definitionData) { if ($di->hasDefinition()) { $aggregateDef = $di->getDefinition(); if (!$aggregateDef instanceof Definition\AggregateDefinition) { throw new Exception\InvalidArgumentException('In order to configure multiple definitions, the primary definition must not be set, or must be of type AggregateDefintion'); } } /* else { $aggregateDef = $di->createDefinition('Zend\Di\Definition\AggregateDefinition'); $di->setDefinition($aggregateDef); } */ if (isset($definitionData['class'])) { $definition = $di->createDefinition($definitionData['class']); unset($definitionData['class']); if ($definition instanceof Definition\BuilderDefinition) { $definition->createClassesFromArray($definitionData); } else { // @todo other types } } if (isset($aggregateDef)) { $aggregateDef->addDefinition($definition); } else { $di->setDefinition($definition); } }
public function testPassingInvalidDefinitionRaisesException() { $di = new DependencyInjector(); $this->setExpectedException('PHPUnit_Framework_Error'); $di->setDefinition(array('foo')); }