server/src/app/Providers/SparqlClientServiceProvider.php
author ymh <ymh.work@gmail.com>
Mon, 12 Jun 2017 14:53:59 +0200
changeset 537 d2e6ee099125
parent 531 48f5380c26d0
permissions -rw-r--r--
upgrade ember + laravel + make everything work

<?php
namespace CorpusParole\Providers;

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

/**
 * 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 = new \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 = new GuzzleSparqlClient($app['Guzzle'], config('corpusparole.rdf4j_query_url'), config('corpusparole.rdf4j_update_url'));
                return new SparqlClient($httpClient, $sparqlClient);
            }
        );
    }
}