예제 #1
0
 protected function configure()
 {
     $defaultUser = $this->appConfig->get('defaults.user');
     $defaultDatabase = $this->appConfig->get('defaults.database');
     $defaultWiki = $this->appConfig->get('defaults.wiki');
     $defaultRepo = $this->appConfig->get('defaults.repo');
     $this->addOption('user', null, $defaultUser === null ? InputOption::VALUE_REQUIRED : InputOption::VALUE_OPTIONAL, 'The configured user to use', $defaultUser)->addOption('database', null, $defaultUser === null ? InputOption::VALUE_REQUIRED : InputOption::VALUE_OPTIONAL, 'The configured database to use', $defaultDatabase)->addOption('wiki', null, $defaultWiki === null ? InputOption::VALUE_REQUIRED : InputOption::VALUE_OPTIONAL, 'The client wiki to use', $defaultWiki)->addOption('repo', null, $defaultRepo === null ? InputOption::VALUE_REQUIRED : InputOption::VALUE_OPTIONAL, 'The repo wiki to use', $defaultRepo);
     $this->wikibaseExecutor->configure($this);
 }
예제 #2
0
 /**
  * @param string $wiki
  * @param string $user
  * @return MediawikiApi
  * @throws RuntimeException
  */
 public function getMediawikiApi($wiki = null, $user = null)
 {
     $wiki = $this->input->getOption($wiki ?: 'wiki');
     $wikiDetails = $this->appConfig->get('wikis.' . $wiki);
     if ($wikiDetails === null) {
         throw new RuntimeException("Wiki {$wiki} not found in config");
     }
     $api = new MediawikiApi($wikiDetails['url']);
     $loggedIn = $api->login($this->getApiUser($user));
     if (!$loggedIn) {
         throw new RuntimeException('Failed to login');
     }
     return $api;
 }