コード例 #1
0
ファイル: Discogsitem.php プロジェクト: daskleinesys/slimpd
 public function fetch()
 {
     if ($this->getExtid() < 1 || !$this->getType()) {
         return FALSE;
     }
     $item = $this->getInstanceByAttributes(['extid' => $this->getExtid(), 'type' => $this->getType()]);
     if ($item !== NULL) {
         $this->setResponse($item->getResponse());
         return;
     }
     $app = \Slim\Slim::getInstance();
     $client = \Discogs\ClientFactory::factory(['defaults' => ['headers' => ['User-Agent' => $app->config['discogsapi']['useragent']]]]);
     $getter = 'get' . ucfirst($this->getType());
     $response = $client->{$getter}(['id' => $this->getExtid()]);
     $this->setTstamp(time());
     $this->setResponse(serialize($response));
     $this->insert();
 }
コード例 #2
0
ファイル: ClientTest.php プロジェクト: ricbra/php-discogs-api
 protected function createClient($mock, History $history)
 {
     $path = sprintf('%s/../../fixtures/%s', __DIR__, $mock);
     $client = ClientFactory::factory();
     $httpClient = $client->getHttpClient();
     $mock = new Mock([$path]);
     $httpClient->getEmitter()->attach($mock);
     $httpClient->getEmitter()->attach($history);
     return $client;
 }
コード例 #3
0
 public function testFactoryWithCustomUserAgent()
 {
     $client = ClientFactory::factory(['defaults' => ['headers' => ['User-Agent' => 'test']]]);
     $default = ['User-Agent' => 'test'];
     $this->assertSame($default, $client->getHttpClient()->getDefaultOption('headers'));
 }