/** * {@inheritdoc} */ public function build($config, array $options = null) { if (!$this->loader) { $this->loader = new JsonLoader(); } return ServiceBuilder::factory($this->loader->parseJsonFile($config), $options); }
public function testSetBuilder() { $services = new ServiceManager(); $builder = ServiceBuilder::factory(array()); $services->setBuilder('newbuilder', $builder); $this->assertEquals($builder, $services->getBuilder('newbuilder')); }
/** * @return mixed */ public static function getWebserviceClient( ) { $builder = ServiceBuilder::factory( __DIR__ . '/../descriptor.php' ); $wsClient = $builder['learningneedsassessment']; return $wsClient; }
/** * @param bool $useCertificatesWebServices * @return mixed */ public static function getWebserviceClient( $useCertificatesWebServices = false ) { $builder = ServiceBuilder::factory( __DIR__ . '/../descriptor.php' ); $wsClient = $useCertificatesWebServices ? $builder['certificates'] : $builder['learningtracker']; return $wsClient; }
/** * Build the Kinvey API client. * * @return Guzzle\Service\Client */ public function buildKinveyAPIClient() { require __DIR__ . '/Client/Service/APIV2Description.php'; require __DIR__ . '/Client/Service/ServiceBuilder.php'; $client = ServiceBuilder::factory($serviceBuilder)->get('KinveyClient'); $client->setDescription(ServiceDescription::factory($APIV2Description)); return $client; }
public static function factory($config = null) { $default = array('auth_token' => null, 'scheme' => 'http', 'base_url' => '{scheme}://{service}.3taps.com'); $required = array('auth_token'); $config = Collection::fromConfig($config, $default, $required); $services = array('services' => array('abstract_service' => array('params' => array('auth_token' => $config->get('auth_token'), 'base_url' => $config->get('base_url'), 'scheme' => $config->get('scheme'))), 'reference' => array('extends' => 'abstract_service', 'class' => 'Rbaker\\ThreeTaps\\Reference\\ReferenceClient', 'params' => array('service' => 'reference')), 'search' => array('extends' => 'abstract_service', 'class' => 'Rbaker\\ThreeTaps\\Search\\SearchClient', 'params' => array('service' => 'search')), 'polling' => array('extends' => 'abstract_service', 'class' => 'Rbaker\\ThreeTaps\\Polling\\PollingClient', 'params' => array('service' => 'polling')))); return ServiceBuilder::factory($services); }
/** * @return \service\certificates\Client */ public static function getWebserviceClient() { if ( !isset(self::$wsClient) ) { // Guzzle RESTclient $builder = ServiceBuilder::factory(__DIR__ . '/../descriptor.php'); self::$wsClient = $builder['certificates']; } return self::$wsClient; }
public function testServicesCanBeExtendedWithIncludes() { $data = array('services' => array('foo' => array('class' => 'stdClass', 'params' => array('baz' => 'bar')), 'bar' => array('extends' => 'foo', 'params' => array('test' => '123', 'ext' => 'abc')))); $file1 = tempnam(sys_get_temp_dir(), 'service_1') . '.json'; file_put_contents($file1, json_encode($data)); $data = array('includes' => array($file1), 'services' => array('bar' => array('extends' => 'bar', 'params' => array('test' => '456')))); $file2 = tempnam(sys_get_temp_dir(), 'service_2') . '.json'; file_put_contents($file2, json_encode($data)); $builder = ServiceBuilder::factory($file2); unlink($file1); unlink($file2); $this->assertEquals(array('bar' => array('class' => 'stdClass', 'extends' => 'foo', 'params' => array('test' => '456', 'baz' => 'bar', 'ext' => 'abc')), 'foo' => array('class' => 'stdClass', 'params' => array('baz' => 'bar'))), $this->readAttribute($builder, 'builderConfig')); }
public static function createClient($config = array()) { $serviceDescriptionFile = __DIR__ . '/Resources/services.php'; $serviceBuilder = ServiceBuilder::factory($serviceDescriptionFile); $client = $serviceBuilder->get('behave'); if (isset($config['app_token'])) { $tokenPlugin = new TokenAuthPlugin($config['app_token']); $client->addSubscriber($tokenPlugin); } else { //TODO throught good exception exit(1); } return $client; }
public function __construct() { // Guzzle RESTclient $this->builder = ServiceBuilder::factory(__DIR__ . '/../../classes/service/descriptor.php'); $this->client = $this->builder['ldap']; // Logger $filter = new ezcLogFilter(); $filter->severity = ezcLog::ERROR | ezcLog::INFO | ezcLog::WARNING; $this->logger = ezcLog::getInstance(); $logFileName = "ws.log"; if ( SolrSafeOperatorHelper::clusterIni('WebService', 'CountrySpecificLogs', 'merck.ini') == 'enabled' ) { $clusterId = ClusterTool::clusterIdentifier(); $logFileName = "ws_{$clusterId}.log"; } $this->logger->getMapper()->appendRule(new ezcLogFilterRule( $filter, new ezcLogUnixFileWriter( "var/log/", $logFileName, 157286400, 3 ), true ) ); }
/** * PHP 5.3 compatibility services * * @deprecated * * @param Application $app */ private function compat(Application $app) { // Register a Guzzle ServiceBuilder $app['guzzle'] = $app->share(function () use($app) { if (!isset($app['guzzle.services'])) { $builder = new ServiceBuilder(array()); } else { $builder = ServiceBuilder::factory($app['guzzle.services']); } return $builder; }); // Register a simple Guzzle Client object (requires absolute URLs when guzzle.base_url is unset) $app['guzzle.client'] = $app->share(function () use($app) { $client = new ServiceClient($app['guzzle.base_url']); foreach ($app['guzzle.plugins'] as $plugin) { $client->addSubscriber($plugin); } return $client; }); }
/** * {@inheritdoc} * * @return \Guzzle\Service\Builder\ServiceBuilder */ public static function factory($config = null, array $globalParameters = array()) { if ($config instanceof Subscription) { $subscription = $config; if (!isset($subscription['derived_key_salt'])) { throw new \UnexpectedValueException('Derived key salt not found in subscription'); } if (!isset($subscription['heartbeat_data']['search_service_colony'])) { throw new \UnexpectedValueException('Acquia Search hostname not found in subscription'); } if (!isset($subscription['heartbeat_data']['search_cores'])) { throw new \UnexpectedValueException('Index data not found in subscription'); } $derivedKey = new DerivedKey($subscription['derived_key_salt'], $subscription->getKey()); $config = array('services' => array()); foreach ($subscription['heartbeat_data']['search_cores'] as $indexInfo) { $config['services'][$indexInfo['core_id']] = array('class' => 'Acquia\\Search\\AcquiaSearchClient', 'params' => array('base_url' => 'https://' . $indexInfo['balancer'], 'index_id' => $indexInfo['core_id'], 'derived_key' => $derivedKey->generate($indexInfo['core_id']))); } } return parent::factory($config, $globalParameters); }
public function setup() { GuzzleTestCase::setServiceBuilder(\Guzzle\Service\Builder\ServiceBuilder::factory(array('test.twitter' => array('class' => "\\Parkji\\Twuzzle\\OAuth\\Client", 'params' => array('consumerKey' => 'foo', 'consumerSecret' => 'bar'))))); $this->client = $this->getServiceBuilder()->get('test.twitter'); $this->setMockResponse($this->client, 'tokenTest'); }
$class = str_replace('Guzzle\\Openstack\\Tests', '', $class); if ('\\' != DIRECTORY_SEPARATOR) { $class = dirname(__DIR__) . DIRECTORY_SEPARATOR . 'tests' . DIRECTORY_SEPARATOR . 'Guzzle/Openstack/Tests' . DIRECTORY_SEPARATOR . str_replace('\\', DIRECTORY_SEPARATOR, $class) . '.php'; } else { $class = dirname(__DIR__) . DIRECTORY_SEPARATOR . 'tests' . DIRECTORY_SEPARATOR . 'Guzzle\\Openstack\\Tests' . DIRECTORY_SEPARATOR . $class . '.php'; } if (file_exists($class)) { require $class; return true; } } if (0 === strpos($class, 'Guzzle\\Openstack')) { $class = str_replace('Guzzle\\Openstack', '', $class); if ('\\' != DIRECTORY_SEPARATOR) { $class = dirname(__DIR__) . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR . 'Guzzle/Openstack' . DIRECTORY_SEPARATOR . str_replace('\\', DIRECTORY_SEPARATOR, $class) . '.php'; } else { $class = dirname(__DIR__) . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR . 'Guzzle\\Openstack' . DIRECTORY_SEPARATOR . $class . '.php'; } if (file_exists($class)) { require $class; return true; } } return false; }); // Include the composer autoloader $loader = (require_once dirname(__DIR__) . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php'); // Register services with the GuzzleTestCase Guzzle\Tests\GuzzleTestCase::setMockBasePath(__DIR__ . DIRECTORY_SEPARATOR . 'mock'); Guzzle\Tests\GuzzleTestCase::setServiceBuilder(\Guzzle\Service\Builder\ServiceBuilder::factory(array('test.abstract.os' => array('class' => '', 'params' => array('username' => 'admin', 'password' => 'openstack', 'token' => 'authenticationtoken')), 'test.identity' => array('extends' => 'test.abstract.os', 'class' => 'Guzzle.Openstack.Identity.IdentityClient', 'params' => array('base_url' => 'http://192.168.4.100:35357/v2.0/')), 'test.compute' => array('extends' => 'test.abstract.os', 'class' => 'Guzzle.Openstack.Compute.ComputeClient', 'params' => array('base_url' => 'http://192.168.4.100:8774/v2/', 'tenant_id' => 'tenantid')), 'test.storage' => array('extends' => 'test.abstract.os', 'class' => 'Guzzle.Openstack.Storage.StorageClient', 'params' => array('base_url' => 'http://192.168.4.100:8080/v1/', 'tenant_id' => 'tenantid')), 'test.openstack' => array('extends' => 'test.abstract.os', 'class' => 'Guzzle.Openstack.Openstack.OpenstackClient'))));
<?php error_reporting(E_ALL | E_STRICT); // Ensure that composer has installed all dependencies if (!file_exists(dirname(__DIR__) . '/composer.lock')) { die("Dependencies must be installed using composer:\n\nphp composer.phar install --dev\n\n See http://getcomposer.org for help with installing composer\n"); } // Include the composer autoloader $autoloader = (require dirname(__DIR__) . '/vendor/autoload.php'); // Register services with the GuzzleTestCase Guzzle\Tests\GuzzleTestCase::setMockBasePath(__DIR__ . '/mocks'); Guzzle\Tests\GuzzleTestCase::setServiceBuilder(\Guzzle\Service\Builder\ServiceBuilder::factory(array('test' => array('class' => 'Gencoding\\Guzzle\\Encoding\\EncodingClient', 'params' => array('base_url' => 'http://localhost', 'userid' => 'xx', 'userkey' => 'xx')))));
public function testCanAddGlobalParametersToServicesOnLoad() { $builder = ServiceBuilder::factory($this->arrayData, array('username' => 'fred', 'new_value' => 'test')); $data = json_decode($builder->serialize(), true); foreach ($data as $service) { $this->assertEquals('fred', $service['params']['username']); $this->assertEquals('test', $service['params']['new_value']); } }
public function testDescriptionIsCacheable() { $jsonFile = __DIR__ . '/../../TestData/test_service.json'; $adapter = new DoctrineCacheAdapter(new ArrayCache()); $builder = ServiceBuilder::factory($jsonFile, array('cache.adapter' => $adapter)); // Ensure the cache key was set $this->assertTrue($adapter->contains('guzzle' . crc32($jsonFile))); // Grab the service from the cache $this->assertEquals($builder, ServiceBuilder::factory($jsonFile, array('cache.adapter' => $adapter))); }
<?php use Desk\Test\Helper\TestCase; use Guzzle\Service\Builder\ServiceBuilder; ini_set('memory_limit', '256M'); error_reporting(-1); $ds = DIRECTORY_SEPARATOR; $autoloader = dirname(__DIR__) . "{$ds}vendor{$ds}autoload.php"; // Ensure that Composer dependencies have been installed locally if (!file_exists($autoloader)) { die("Dependencies must be installed using Composer:\n\n" . "composer.phar install --dev\n\n" . "See https://github.com/composer/composer/blob/master/README.md " . "for help with installing composer\n"); } // Include the Composer autoloader require_once $autoloader; // Configure Guzzle service builder if (isset($_SERVER['DESK_TEST_CONFIG'])) { $config = $_SERVER['DESK_TEST_CONFIG']; } else { $config = __DIR__ . '/service/mock.json'; } TestCase::setServiceBuilder(ServiceBuilder::factory($config)); TestCase::setTestsBasePath(__DIR__); TestCase::setMockBasePath(__DIR__ . '/mock');
<?php $loader = (require __DIR__ . '/../vendor/autoload.php'); $loader->add('AdrienBrault', __DIR__); Guzzle\Tests\GuzzleTestCase::setMockBasePath(__DIR__ . '/mock'); Guzzle\Tests\GuzzleTestCase::setServiceBuilder(\Guzzle\Service\Builder\ServiceBuilder::factory(array('facebook' => array('class' => 'AdrienBrault\\FacebookClient\\FacebookClient'))));
<?php /** * This file is part of the ImboClient package * * (c) Christer Edvartsen <*****@*****.**> * * For the full copyright and license information, please view the LICENSE file that was * distributed with this source code. */ namespace ImboClientTest; use Guzzle\Tests\GuzzleTestCase, Guzzle\Service\Builder\ServiceBuilder; require __DIR__ . '/../vendor/autoload.php'; // Set a default service builder for the tests $serviceDescription = (require __DIR__ . '/../src/ImboClient/service.php'); GuzzleTestCase::setServiceBuilder(ServiceBuilder::factory($serviceDescription['operations'])); // Set the base path for respones mocks GuzzleTestCase::setMockBasePath(__DIR__ . '/response_mocks');
<?php date_default_timezone_set('America/Los_Angeles'); require __DIR__ . '/../vendor/autoload.php'; if (!file_exists(__DIR__ . '/config.json')) { throw new \RuntimeException('Please create config.json before running the examples.'); } /* * Using the ServiceBuilder is not necessary, * it just simplifies loading configurations for the examples. * @var \Guzzle\Service\Builder\ServiceBuilder */ return \Guzzle\Service\Builder\ServiceBuilder::factory(__DIR__ . '/config.json')->get('phlack');
<?php require_once __DIR__ . '/../vendor/autoload.php'; \Guzzle\Tests\GuzzleTestCase::setServiceBuilder(\Guzzle\Service\Builder\ServiceBuilder::factory(array('test.localbtc.auth' => array('class' => '\\LocalBtc\\Authenticator', 'params' => array('debug' => true)))));
<?php use Guzzle\Tests\GuzzleTestCase; use Guzzle\Service\Builder\ServiceBuilder; if (!file_exists(dirname(__DIR__) . '/composer.lock')) { die("Dependencies must be installed using composer:\n\nphp composer.phar install\n\n" . "See http://getcomposer.org for help with installing composer\n"); } require dirname(__DIR__) . '/vendor/autoload.php'; GuzzleTestCase::setMockBasePath(__DIR__ . '/mock'); GuzzleTestCase::setServiceBuilder(ServiceBuilder::factory(array('ga_measurement_protocol' => array('class' => 'Krizon\\Google\\Analytics\\MeasurementProtocol\\MeasurementProtocolClient', 'params' => array()))));
/** * @return \service\esb\Client */ protected static function getEsbClient() { if (!isset(self::$esbClient)) { $builder = ServiceBuilder::factory(__DIR__ . '/../service/descriptor.php'); self::$esbClient = $builder['esb']; } return self::$esbClient; }
public function testServicesCanBeAddedToBuilderAfterInstantiationAndInjectedIntoServices() { // Grab the cache adapter and remove it from the config $cache = $this->arrayData['cache.adapter']; $data = $this->arrayData; unset($data['cache.adapter']); // Create the builder and add the cache adapter $builder = ServiceBuilder::factory($data); $builder['cache.adapter'] = $cache; $this->assertInstanceOf('Guzzle\\Common\\Cache\\DoctrineCacheAdapter', $builder['service_uses_cache']->getConfig('cache')); }
<?php use Guzzle\Tests\GuzzleTestCase; use Guzzle\Service\Builder\ServiceBuilder; error_reporting(E_ALL | E_STRICT); // Ensure that composer has installed all dependencies if (!file_exists(dirname(__DIR__) . '/composer.lock')) { die("Dependencies must be installed using composer:\n\nphp composer.phar install --dev\n\n" . "See http://getcomposer.org for help with installing composer\n"); } // Include the composer autoloader $autoloader = (require dirname(__DIR__) . '/vendor/autoload.php'); // Set mock directory for Tika command responses. GuzzleTestCase::setMockBasePath(__DIR__ . DIRECTORY_SEPARATOR . 'mock'); // Add the services file to the default service builder GuzzleTestCase::setServiceBuilder(ServiceBuilder::factory(array('base' => array('class' => 'Bangpound\\Tika\\Client'), 'test.tika' => array('extends' => 'base', 'params' => array('base_url' => $_SERVER['TIKA_URL'])), 'test.mock' => array('extends' => 'base', 'params' => array()))));
<?php use Guzzle\Tests\GuzzleTestCase; use Guzzle\Service\Builder\ServiceBuilder; error_reporting(E_ALL | E_STRICT); define('APPLICATION_ENV', 'testing'); // pull in composer autloader require_once __DIR__ . '/../../vendor/autoload.php'; // pull in our test client to interact with the service require_once __DIR__ . '/TestClient.php'; // private key for testing $GLOBALS['key'] = 'fbdce19f94b158e72ae6020cc5126642a9d42d086419c015ad2b6dd429312410'; GuzzleTestCase::setServiceBuilder(ServiceBuilder::factory(array('test.api' => array('class' => 'TestClient', 'params' => array('base_url' => 'http://127.0.0.1/', 'api_id' => 1)))));
/** * @param string $group * * @return \Guzzle\Service\Builder\ServiceBuilder */ public function offsetGet($group) { if (!isset($this[$group])) { // Load builder from file or instantiate an empty one. if ($this->hasConfigFile($group)) { $this[$group] = $this->load($group); } else { $this[$group] = ServiceBuilder::factory(array()); } // Initialize the "removed" flag. $this->removed[$group] = array(); } return parent::offsetGet($group); }
/** * @param string $apiKey * * @return \Guzzle\Service\Builder\ServiceBuilderInterface */ public static function build($apiKey) { self::$apiKey = $apiKey; static::$cachedFactory = new ServiceBuilderLoader(); return parent::factory(__DIR__ . '/Resources/clients.json'); }
<?php include __DIR__ . '/../vendor/autoload.php'; use Guzzle\Service\Builder\ServiceBuilder; use Guzzle\Tests\GuzzleTestCase; $builder = ServiceBuilder::factory(array('test.campbx' => array('class' => '\\Matmar10\\CampBX\\CampBXClient', 'params' => array()), 'test.campbx_auth' => array('class' => '\\Matmar10\\CampBX\\CampBXAuthClient', 'params' => array('username' => 'testuser', 'password' => 'testpassword')))); Guzzle\Tests\GuzzleTestCase::setServiceBuilder($builder);