server/src/app/Providers/SparqlClientServiceProvider.php
author ymh <ymh.work@gmail.com>
Fri, 09 Jun 2017 15:22:02 +0200
changeset 531 48f5380c26d0
parent 405 f239c8c5bb94
child 537 d2e6ee099125
permissions -rw-r--r--
Replace EasyRdf http loading with guzzle to solve proxy problems

<?php
namespace CorpusParole\Providers;

use Illuminate\Support\ServiceProvider;
use CorpusParole\Libraries\Sparql\SparqlClient;

/**
 * Service provider charged to bind repository interfaces to implementations
 */
class SparqlClientServiceProvider extends ServiceProvider {

    public function register() {
        $this->app->bind(
            'CorpusParole\Libraries\Sparql\SparqlClient',
            function($app) {
                $httpClient = $app->make('GuzzleHttp\Client', [[ 'base_uri' => config('corpusparole.rdf4j_query_url'), 'http_errors' => false]]);
                // we create another guzzle client to avoid interference with the base_uri parameter
                $sparqlClient = $app->make('CorpusParole\Libraries\Sparql\GuzzleSparqlClient', [$app['Guzzle'], config('corpusparole.rdf4j_query_url'), config('corpusparole.rdf4j_update_url')]);
                return new SparqlClient($httpClient, $sparqlClient);
            }
        );
    }
}