/** * 指定名のプラグインを取得する * * @param string $name * @return Midngiht\Crawler\PluginInterface **/ public function getPlugin($name) { $result = $this->ifEnablePlugin($name); if (!$result) { throw new \Exception('有効化されたプラグインではありません'); } $container = new Container(new CrawlerPluginFactory()); return $container->get($name); }
/** * テスト用ページをクロールする * * @return void **/ private function _crawlTestPages() { $crawler = new Crawler(); $manager = new PluginManager(); $container = new Container(new CrawlerPluginTestDataFactory()); foreach ($manager->getEnablePluginNames() as $plugin_name) { $plugin = $manager->getPlugin($plugin_name); $plugin->setTestData($container->get($plugin_name)); $crawler->setPlugin($plugin); $entry_data = $crawler->crawl(); $this->crawl_data = array_merge($this->crawl_data, $entry_data); } $entry_manager = new EntryManager(); $this->crawl_data = $entry_manager->format($this->crawl_data); }
/** * テストデータプラグインを取得して配列で返す * * @return AbstractTestData **/ private function _getTestDataPlugin() { $container = new Container(new CrawlerPluginTestDataFactory()); return $container->get($this->params[1]); }
/** * @return void **/ public function setUp() { $container = new Container(new CrawlerPluginTestDataFactory()); $this->test_data = $container->get('EroAnime'); }