/**
  * Reduce aliases
  *
  * @param  string $name
  * @return string
  */
 protected function reduceAlias($name)
 {
     $aliases = $this->dumper->getAliases();
     if (isset($aliases[$name])) {
         return $this->reduceAlias($aliases[$name]);
     }
     return $name;
 }
Beispiel #2
0
 /**
  * Verifies that instances that cannot be built because of missing parameters in config will be ignored
  */
 public function testWillIgnoreInstancesWithMissingParameters()
 {
     $di = new Di();
     $dumper = new Dumper($di);
     $definitions = $dumper->getInjectedDefinitions(__NAMESPACE__ . '\\TestAsset\\DumperTestDummyInstanceWithDefinitions');
     $this->assertCount(0, $definitions);
 }
Beispiel #3
0
 /**
  * @param $config
  * @param null|Di $di
  * @return string
  */
 protected function getDiDefinitions($config, Di $di = null)
 {
     ErrorHandler::start();
     if ($arrayDefinitions = (include $config['ocra_di_compiler']['compiled_di_definitions_filename'])) {
         ErrorHandler::stop();
         return $config['ocra_di_compiler']['compiled_di_definitions_filename'];
     }
     ErrorHandler::stop();
     if (!$di) {
         $di = new Di();
         if (isset($config['di'])) {
             $diConfig = new DiConfig($config['di']);
             $diConfig->configure($di);
         }
     }
     $dumper = new Dumper($di);
     $definitionsCompiler = new ClassListCompilerDefinition();
     $definitionsCompiler->addClassesToProcess($dumper->getAllClasses());
     $definitionsCompiler->compile();
     $fileGenerator = new FileGenerator();
     $fileGenerator->setFilename($config['ocra_di_compiler']['compiled_di_definitions_filename']);
     $fileGenerator->setBody('return ' . var_export($definitionsCompiler->toArrayDefinition()->toArray(), true) . ';');
     $fileGenerator->write();
     return $config['ocra_di_compiler']['compiled_di_definitions_filename'];
 }