Ejemplo n.º 1
0
 private function initializeSources()
 {
     $this->logger->debug('Initialization of sources started');
     $this->sources = [];
     $sources = $this->configurationProvider->getAggregatorsNames();
     $this->logger->debug('Found ' . count($sources) . ' aggregator(s)');
     foreach ($sources as $sourceName) {
         $this->logger->debug("Initializing {$sourceName} aggregator");
         //TODO ConfigurationProvider should be passed to aggregator and than aggregator should configure itself
         $config = $this->configurationProvider->getAggregatorConfiguration($sourceName);
         if ($config === false) {
             throw new ConfigurationException('Failed to configure ' . $sourceName . ' aggregator. Did you defined type for it?');
         }
         $sourceClass = $this->configurationProvider->getAggregatorClassNameByAggregatorName($sourceName);
         if ($sourceClass === false) {
             throw new \RuntimeException("Failed to locate object for {$sourceName} aggregator! (THIS IS A BUG)");
         }
         $this->sources[] = new $sourceClass($this->appConfiguration, $config, $this->logger);
         $this->logger->debug("{$sourceName} aggregator initialized");
     }
     $this->logger->debug('All aggregators ready');
 }
 public function testGetAggregatorClassNameByAggregatorNameProvidesValidClassName()
 {
     $expectedClassName = '\\noFlash\\TorrentGhost\\Aggregator\\RssAggregator';
     $this->assertSame($expectedClassName, $this->subjectUnderTest->getAggregatorClassNameByAggregatorName('AnotherOSTracker'));
 }