public function __construct(ApiMain $main, $name, Config $config)
 {
     parent::__construct($main, $name);
     $this->veConfig = $config;
     $this->serviceClient = new VirtualRESTServiceClient(new MultiHttpClient(array()));
     $this->serviceClient->mount('/restbase/', $this->getVRSObject());
 }
 public function __construct(ApiMain $main, $name)
 {
     global $wgContentTranslationParsoid;
     parent::__construct($main, $name);
     $this->serviceClient = new VirtualRESTServiceClient(new MultiHttpClient(array()));
     $parsoidConfig = $wgContentTranslationParsoid;
     $this->serviceClient->mount('/parsoid/', new ParsoidVirtualRESTService(array('URL' => $parsoidConfig['url'], 'prefix' => $parsoidConfig['prefix'], 'timeout' => $parsoidConfig['timeout'])));
 }
Example #3
0
    return \ObjectCache::newWANCacheFromParams($params);
}, 'LocalServerObjectCache' => function (MediaWikiServices $services) {
    $mainConfig = $services->getMainConfig();
    if (function_exists('apc_fetch')) {
        $id = 'apc';
    } elseif (function_exists('apcu_fetch')) {
        $id = 'apcu';
    } elseif (function_exists('xcache_get') && wfIniGetBool('xcache.var_size')) {
        $id = 'xcache';
    } elseif (function_exists('wincache_ucache_get')) {
        $id = 'wincache';
    } else {
        $id = CACHE_NONE;
    }
    if (!isset($mainConfig->get('ObjectCaches')[$id])) {
        throw new UnexpectedValueException("Cache type \"{$id}\" is not present in \$wgObjectCaches.");
    }
    return \ObjectCache::newFromParams($mainConfig->get('ObjectCaches')[$id]);
}, 'VirtualRESTServiceClient' => function (MediaWikiServices $services) {
    $config = $services->getMainConfig()->get('VirtualRestConfig');
    $vrsClient = new VirtualRESTServiceClient(new MultiHttpClient([]));
    foreach ($config['paths'] as $prefix => $serviceConfig) {
        $class = $serviceConfig['class'];
        // Merge in the global defaults
        $constructArg = isset($serviceConfig['options']) ? $serviceConfig['options'] : [];
        $constructArg += $config['global'];
        // Make the VRS service available at the mount point
        $vrsClient->mount($prefix, ['class' => $class, 'config' => $constructArg]);
    }
    return $vrsClient;
}];