/** * Run all jobs in the queue. This only works if the MediaWiki installation has $wgJobRunRate * set to greater than zero. * @todo This and TestEnvironment::getJobQueueLength() should probably not live here. * @return void */ public function runJobs() { $reqestProps = ['meta' => 'siteinfo', 'siprop' => 'general']; $siteInfoRequest = new SimpleRequest('query', $reqestProps); $out = $this->getApi()->getRequest($siteInfoRequest); $mainPageUrl = $out['query']['general']['base']; while ($this->getJobQueueLength($this->getApi()) > 0) { $cf = new ClientFactory(); $cf->getClient()->get($mainPageUrl); } }
public function initServices() { $clientFactory = new ClientFactory(array('middleware' => array(EffectiveUrlMiddleware::middleware()), 'user-agent' => 'Addwiki - Wikidata Referencer')); $guzzleClient = $clientFactory->getClient(); $this->wmFactoryFactory = new WikimediaMediawikiFactoryFactory($clientFactory); $this->microDataExtractor = new MicroDataExtractor(); $this->sparqlQueryRunner = new SparqlQueryRunner($guzzleClient); $this->externalLinkClient = $guzzleClient; $this->wikibaseApi = new MediawikiApi('https://www.wikidata.org/w/api.php', $guzzleClient); $this->wikibaseFactory = new WikibaseFactory($this->wikibaseApi, new DataValueDeserializer(array('boolean' => 'DataValues\\BooleanValue', 'number' => 'DataValues\\NumberValue', 'string' => 'DataValues\\StringValue', 'unknown' => 'DataValues\\UnknownValue', 'globecoordinate' => 'DataValues\\Geo\\Values\\GlobeCoordinateValue', 'monolingualtext' => 'DataValues\\MonolingualTextValue', 'multilingualtext' => 'DataValues\\MultilingualTextValue', 'quantity' => 'DataValues\\QuantityValue', 'time' => 'DataValues\\TimeValue', 'wikibase-entityid' => 'Wikibase\\DataModel\\Entity\\EntityIdValue')), new DataValueSerializer()); $mapper = new WikidataToSchemaMapper(); $this->instanceMap = $mapper->getInstanceMap(); $this->referencerMap = $mapper->getReferencerMap($this->wikibaseFactory, $this->sparqlQueryRunner); }
/** * @return ClientInterface */ private function getClient() { if ($this->client === null) { $clientFactory = new ClientFactory(); $clientFactory->setLogger($this->logger); $this->client = $clientFactory->getClient(); } return $this->client; }
public function __construct(ClientFactory $clientFactory) { $this->client = $clientFactory->getClient(); }