示例#1
0
文件: Hydrate.php 项目: lebris/karma
 private function warnForUnvaluedVariables(Hydrator $processor)
 {
     $unvaluedVariables = $processor->getUnvaluedVariables();
     if (!empty($unvaluedVariables)) {
         $logger = $this->app['logger'];
         $logger->warning(sprintf('Missing values for variables : %s (TODO markers found)', implode(', ', $unvaluedVariables)));
     }
 }
示例#2
0
 public function testTarget()
 {
     $this->write('a.php-dist', '<%var%>');
     $this->write('b.php', '<%var%>');
     $reader = new InMemoryReader(['var:dev' => 'test']);
     $hydrator = new Hydrator($this->sourceFs, $this->targetFs, $reader, new Finder($this->sourceFs), new NullProvider());
     $hydrator->allowNonDistFilesOverwrite();
     $hydrator->hydrate('dev');
     $this->assertTrue($this->targetFs->has('a.php'));
     $this->assertSame('test', $this->targetFs->read('a.php'));
     $this->assertTrue($this->targetFs->has('b.php'));
     $this->assertSame('test', $this->targetFs->read('b.php'));
 }
示例#3
0
 private function initializeServices()
 {
     $this['logger'] = $this->share(function ($c) {
         return new \Psr\Log\NullLogger();
     });
     $this['formatter.provider'] = $this->share(function ($c) {
         return new ProfileProvider($c['profile']);
     });
     $this['hydrator'] = function ($c) {
         $hydrator = new Hydrator($c['sources.fileSystem'], $c['configuration'], $c['finder'], $c['formatter.provider']);
         $hydrator->setLogger($c['logger'])->setSuffix($c['distFiles.suffix']);
         return $hydrator;
     };
     $this['generator.nameTranslator'] = $this->share(function ($c) {
         $translator = new FilePrefixTranslator();
         $translator->changeMasterFile($c['configuration.masterFile']);
         return $translator;
     });
     $this['generator.variableProvider'] = function ($c) {
         $provider = new VariableProvider($c['parser'], $c['configuration.masterFile']);
         $profile = $c['profile'];
         $options = $profile->getGeneratorOptions();
         if (!isset($options['translator']) || $options['translator'] === 'prefix') {
             $provider->setNameTranslator($c['generator.nameTranslator']);
         }
         return $provider;
     };
     $this['configurationFilesGenerator'] = $this->share(function ($c) {
         return new YamlGenerator($c['sources.fileSystem'], $c['configuration'], $c['generator.variableProvider']);
     });
 }