Last active
January 27, 2016 03:43
-
-
Save kurozumi/7af525bf2a6d31e445b4 to your computer and use it in GitHub Desktop.
【Silex】Amazon Product Adverstising API(AmazonアソシエイトAPI)ライブラリのApai-IO用のサービスプロバイダー
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
* To change this license header, choose License Headers in Project Properties. | |
* To change this template file, choose Tools | Templates | |
* and open the template in the editor. | |
*/ | |
namespace Acme\ServiceProvider; | |
use Pimple\Container; | |
use Pimple\ServiceProviderInterface; | |
use ApaiIO\ApaiIO; | |
use ApaiIO\Configuration\GenericConfiguration; | |
use ApaiIO\ResponseTransformer\XmlToSimpleXmlObject; | |
use ApaiIO\ResponseTransformer\XmlToDomDocument; | |
use ApaiIO\Operations\Lookup; | |
/** | |
* Description of ApiIOServiceProvider | |
* | |
* @author kurozumi | |
*/ | |
class ApaiIOServiceProvider implements ServiceProviderInterface | |
{ | |
public function register(Container $app) | |
{ | |
$app['apaiio.api_key'] = array( | |
"ENDPOINT" => null, | |
"AWS_API_KEY" => null, | |
"AWS_API_SERCERT_KEY" => null, | |
"AWS_ASSOCIATE_TAG" => null | |
); | |
$app['apaiio.config'] = $app->factory(function($app){ | |
$conf = new GenericConfiguration(); | |
$conf | |
->setCountry($app['apaiio.api_key']['ENDPOINT']) | |
->setAccessKey($app['apaiio.api_key']['AWS_API_KEY']) | |
->setSecretKey($app['apaiio.api_key']['AWS_API_SERCERT_KEY']) | |
->setAssociateTag($app['apaiio.api_key']['AWS_ASSOCIATE_TAG']); | |
if (false === empty($app['apaiio.api_key']['REQUEST'])) | |
{ | |
$conf->setRequest($app['apaiio.api_key']['REQUEST']); | |
} | |
if (false === empty($app['apaiio.api_key']['RESPONSE'])) | |
{ | |
$conf->setResponseTransformer($app['apaiio.api_key']['RESPONSE']); | |
} | |
return $conf; | |
}); | |
$app['apaiio'] = $app->factory(function($app) { | |
return new ApaiIO($app['apaiio.config']); | |
}); | |
$app['apaiio.lookup'] = function($app) { | |
return new Lookup; | |
}; | |
$app['apaiio.trans.simplexml'] = function($app) { | |
return new XmlToSimpleXmlObject; | |
}; | |
$app['apaiio.trans.dom'] = function($app) { | |
return new XmlToDomDocument; | |
}; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment