public static function createResponseTransformer(ConfigurationInterface $configuration) { $class = $configuration->getResponseTransformer(); $factoryCallback = $configuration->getResponseTransformerFactory(); if (true === is_object($class) && $class instanceof ResponseTransformerInterface) { return self::applyCallback($factoryCallback, $class); } if (true === is_string($class) && true === array_key_exists($class, self::$responseTransformerObjects)) { return self::applyCallback($factoryCallback, self::$responseTransformerObjects[$class]); } try { $reflectionClass = new \ReflectionClass($class); } catch (\ReflectionException $e) { throw new \InvalidArgumentException(sprintf("Responsetransformerclass not found: %s", $class)); } if ($reflectionClass->implementsInterface('\\Clchang\\AliexApi\\ResponseTransformerInterface')) { $responseTransformer = new $class(); return self::$responseTransformerObjects[$class] = self::applyCallback($factoryCallback, $responseTransformer); } throw new \LogicException(sprintf("Responsetransformerclass does not implements the ResponseTransformerInterface: %s", $class)); }
/** * Apply converter on request based on the given configuration. * * @param Request $request * @param ConfigurationInterface $configuration */ protected function applyConverter(Request $request, $configuration) { $value = $request->attributes->get($configuration->getName()); $className = $configuration->getClass(); // If the value is already an instance of the class we are trying to convert it into // we should continue as no convertion is required if (is_object($value) && $value instanceof $className) { return; } if ($converterName = $configuration->getConverter()) { if (!isset($this->namedConverters[$converterName])) { throw new \RuntimeException(sprintf("No converter named '%s' found for conversion of parameter '%s'.", $converterName, $configuration->getName())); } $converter = $this->namedConverters[$converterName]; if (!$converter->supports($configuration)) { throw new \RuntimeException(sprintf("Converter '%s' does not support conversion of parameter '%s'.", $converterName, $configuration->getName())); } $converter->apply($request, $configuration); return; } foreach ($this->all() as $converter) { if ($converter->supports($configuration)) { if ($converter->apply($request, $configuration)) { return; } } } }
/** * Processes an array of configurations. * * @param ConfigurationInterface $configuration The configuration class * @param array $configs An array of configuration items to process * * @return array The processed configuration */ public function processConfiguration(ConfigurationInterface $configuration, array $configs) { return $this->process($configuration->getConfigTreeBuilder()->buildTree(), $configs); }
public function dump(ConfigurationInterface $configuration) { return $this->dumpNode($configuration->getConfigTreeBuilder()->buildTree()); }
/** * @covers \Nia\Configuration\Reader\Json\JsonStringConfiguration::getSectionsNames */ public function testGetSectionsNames() { $expected = ['database', 'environment']; $this->assertEquals($expected, $this->configuration->getSectionsNames()); }
/** * @param ConfigurationInterface $configuration */ public function __construct(ConfigurationInterface $configuration = null) { if ($configuration) { $configuration->configureServiceManager($this); } }
/** * If no channel is set, try to fill it from configuration data. * * @param FACTFinder\Util\Parameters $parameters The parameters object to * check. */ protected function ensureChannelParameter($parameters) { if ((!isset($parameters['channel']) || $parameters['channel'] == '') && $this->configuration->getChannel() != '') { $parameters['channel'] = $this->configuration->getChannel(); } }
/** * Normalises the input for the command by merging input with configuration. * * @param InputInterface $input * @param ConfigurationInterface $config * @return RepositoryInterface */ private function prepareRepository($input, $config) { return new Repository(['name' => $input->getArgument('name'), 'description' => $this->getOption($input, 'description', ''), 'private' => $this->getOption($input, 'private', true), 'account' => $this->getOption($input, 'account', $config->get('account')), 'type' => $this->getOption($input, 'type', $config->get('type')), 'service' => $this->getOption($input, 'service', $config->get('service')), 'username' => $this->getOption($input, 'username', $config->get('username')), 'password' => $this->getOption($input, 'password', $config->get('password'))]); }
/** * Normalises the input for the command by merging input with configuration. * * @param InputInterface $input * @param ConfigurationInterface $config * @return RepositoryInterface */ private function prepareRepository($input, $config) { $repo = explode('/', $input->getArgument('name')); return new Repository(['name' => $repo[1], 'description' => $this->getOption($input, 'description', ''), 'private' => $this->getOption($input, 'private', true), 'account' => isset($repo[0]) ? $repo[0] : $config->get('account')]); }
/** * Ensures that the passed parameters object has a "channel" parameter by * adding one if necessary. * @param Parameters $parameters Parameters to be modifier. */ protected function ensureChannelParameter($parameters) { if (!isset($parameters['channel']) || strlen($parameters['channel']) == 0) { $parameters['channel'] = $this->configuration->getChannel(); } }