server/src/app/Providers/SparqlClientServiceProvider.php
changeset 537 d2e6ee099125
parent 531 48f5380c26d0
equal deleted inserted replaced
536:b64c8c35c67d 537:d2e6ee099125
     1 <?php
     1 <?php
     2 namespace CorpusParole\Providers;
     2 namespace CorpusParole\Providers;
     3 
     3 
     4 use Illuminate\Support\ServiceProvider;
     4 use Illuminate\Support\ServiceProvider;
     5 use CorpusParole\Libraries\Sparql\SparqlClient;
     5 use CorpusParole\Libraries\Sparql\SparqlClient;
       
     6 use CorpusParole\Libraries\Sparql\GuzzleSparqlClient;
     6 
     7 
     7 /**
     8 /**
     8  * Service provider charged to bind repository interfaces to implementations
     9  * Service provider charged to bind repository interfaces to implementations
     9  */
    10  */
    10 class SparqlClientServiceProvider extends ServiceProvider {
    11 class SparqlClientServiceProvider extends ServiceProvider {
    11 
    12 
    12     public function register() {
    13     public function register() {
    13         $this->app->bind(
    14         $this->app->bind(
    14             'CorpusParole\Libraries\Sparql\SparqlClient',
    15             'CorpusParole\Libraries\Sparql\SparqlClient',
    15             function($app) {
    16             function($app) {
    16                 $httpClient = $app->make('GuzzleHttp\Client', [[ 'base_uri' => config('corpusparole.rdf4j_query_url'), 'http_errors' => false]]);
    17                 $httpClient = new \GuzzleHttp\Client([ 'base_uri' => config('corpusparole.rdf4j_query_url'), 'http_errors' => false]);
    17                 // we create another guzzle client to avoid interference with the base_uri parameter
    18                 // we create another guzzle client to avoid interference with the base_uri parameter
    18                 $sparqlClient = $app->make('CorpusParole\Libraries\Sparql\GuzzleSparqlClient', [$app['Guzzle'], config('corpusparole.rdf4j_query_url'), config('corpusparole.rdf4j_update_url')]);
    19                 $sparqlClient = new GuzzleSparqlClient($app['Guzzle'], config('corpusparole.rdf4j_query_url'), config('corpusparole.rdf4j_update_url'));
    19                 return new SparqlClient($httpClient, $sparqlClient);
    20                 return new SparqlClient($httpClient, $sparqlClient);
    20             }
    21             }
    21         );
    22         );
    22     }
    23     }
    23 }
    24 }