/** * Get TyrService class to use depending on currently installed Guzzle version. * * @throws NotSupportedException when Guzzle vendor version is not supported. * * @return string */ public static function getTyrServiceClassName() { $guzzleVersion = VersionChecker::vendorGuzzleVersion(); if (5 === $guzzleVersion) { return 'CanalTP\\TyrComponent\\TyrService'; } elseif (3 === $guzzleVersion) { return 'CanalTP\\TyrComponent\\Guzzle3\\TyrService'; } }
/** * {@inheritdoc} */ public function load(array $configs, ContainerBuilder $container) { $configuration = new Configuration(); $config = $this->processConfiguration($configuration, $configs); // Tyr api parameters foreach ($config as $key => $value) { $container->setParameter('canal_tp_tyr.tyr_' . $key, $value); } $container->setDefinition('canal_tp_tyr.api', new Definition(VersionChecker::getTyrServiceClassName(), array('%canal_tp_tyr.tyr_url%', '%canal_tp_tyr.tyr_end_point_id%'))); }
/** * Constructor */ public function __construct() { $tyrServiceClass = VersionChecker::getTyrServiceClassName(); $this->tyrService = new $tyrServiceClass('http://tyr.dev.canaltp.fr/v0/', 1); }
/** * {@InheritDoc} */ protected function checkGuzzleVersion() { VersionChecker::supportsGuzzleVersion(5, get_class($this)); }