/** * @return void */ public function setUp() { $iniReader = new Ini(); $config = new Config($iniReader->fromFile('../../../local/config/vufind/config.ini')); $this->url = $config->get('Index')->get('url') . '/' . $config->get('Index')->get('default_core'); $this->urlAdmin = $config->get('Index')->get('url') . '/admin'; }
/** * @param String $string * * @return String * @author Fabian Köstring */ private function convert(string $string) { if (!$this->config->offsetExists('chars')) { return $string; } $chars = $this->config->get('chars')->toArray(); $from = array_keys($chars); $to = array_values($chars); return preg_replace($from, $to, $string); }
/** * Gets the config for given command key * * @param string $commandKey * @return Config */ protected function getCommandConfig($commandKey) { if (isset($this->configsPerCommandKey[$commandKey])) { return $this->configsPerCommandKey[$commandKey]; } $config = new Config($this->config->get('default')->toArray(), true); if ($this->config->__isset($commandKey)) { $commandConfig = $this->config->get($commandKey); $config->merge($commandConfig); } $this->configsPerCommandKey[$commandKey] = $config; return $config; }
/** * @param Config $helpers * @throws BadMethodCallException */ private function generateViewHelpers(Config $helpers) { foreach ($this->helperConfig as $helper => $config) { if (!$helpers->get($helper)) { continue; } $helperProxy = false; if (isset($config['proxy']) && $this->viewHelperManager->has($config['proxy'])) { $helperProxy = $this->viewHelperManager->get($config['proxy']); } $viewHelper = $this->viewHelperManager->get($helper); $instructions = $helpers[$helper]->toArray(); $sortedInstructions = $this->sort($instructions); foreach ($sortedInstructions as $id => $instruction) { if ($this->isRemoved($instruction)) { continue; } $mergedInstruction = ArrayUtils::merge($config, (array) $instruction); if ($this->isDebug() && isset($mergedInstruction['debug'])) { $mergedInstruction[$mergedInstruction['debug']]['data-layout-id'] = $id; } $method = isset($mergedInstruction['method']) ? $mergedInstruction['method'] : '__invoke'; $args = $this->filterArgs($mergedInstruction); if (method_exists($viewHelper, $method)) { $this->invokeArgs($viewHelper, $method, $args); } elseif (false !== $helperProxy && method_exists($helperProxy, $method)) { $this->invokeArgs($helperProxy, $method, $args); } else { throw new BadMethodCallException(sprintf('Call to undefined helper method %s::%s()', get_class($viewHelper), $method)); } } } }
/** * @param Config $specs * @return boolean */ private function isRemoved(Config $specs) { if ($remove = $specs->get('remove')) { return filter_var($remove, FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE); } return false; }
/** * Get target to be used for the client's IP range + sub domain * * @param String $overrideIP Simulate request from given * instead of detecting real IP * @param String $overrideHost Simulate request from given * instead of detecting from real URL * * @return Boolean Target detected or not? */ public function detectTarget($overrideIP = '', $overrideHost = '') { $this->targetKey = false; // Key of detected target config $this->targetApiId = false; $this->targetApiKey = false; $targetKeys = explode(',', $this->config->get('TargetsProxy')->get('targetKeys' . $this->searchClass)); // Check whether the current IP address matches against any of the // configured targets' IP / sub domain patterns $ipAddress = !empty($overrideIP) ? $overrideIP : $this->getClientIpV4(); if (empty($overrideHost)) { $url = $this->getClientUrl(); } else { $url = new \Zend\Uri\Http(); $url->setHost($overrideHost); } $IpMatcher = new IpMatcher(); $UrlMatcher = new UrlMatcher(); foreach ($targetKeys as $targetKey) { $isMatchingIP = false; $isMatchingUrl = false; /** * Config * * @var \Zend\Config\Config $targetConfig */ $targetConfig = $this->config->get($targetKey); $patternsIP = ''; $patternsURL = ''; // Check match of IP address if any pattern configured. // If match is found, set corresponding keys and continue matching if ($targetConfig->offsetExists('patterns_ip')) { $patternsIP = $targetConfig->get('patterns_ip'); if (!empty($patternsIP)) { $targetPatternsIp = explode(',', $patternsIP); $isMatchingIP = $IpMatcher->isMatching($ipAddress, $targetPatternsIp); if ($isMatchingIP === true) { $this->_setConfigKeys($targetKey); } } } // Check match of URL hostname if any pattern configured. // If match is found, set corresponding keys and exit immediately if ($targetConfig->offsetExists('patterns_url')) { $patternsURL = $targetConfig->get('patterns_url'); if (!empty($patternsURL)) { $targetPatternsUrl = explode(',', $patternsURL); $isMatchingUrl = $UrlMatcher->isMatching($url->getHost(), $targetPatternsUrl); if ($isMatchingUrl === true) { $this->_setConfigKeys($targetKey); return true; } } } } return $this->targetKey != "" ? true : false; }
/** * Whether the request is allowed * * @return boolean */ public function allowRequest() { if ($this->config->get('circuitBreaker')->get('forceOpen')) { return false; } if ($this->config->get('circuitBreaker')->get('forceClosed')) { return true; } return !$this->isOpen() || $this->allowSingleTest(); }
/** * Get list items from config * * @param String $configKey * @param Boolean $toLower * @param Boolean $trim * @param String $delimiter * @return String[] */ protected function getConfigList($configKey, $trim = true, $delimiter = ',') { $data = array(); if ($this->config->offsetExists($configKey)) { $configValue = $this->config->get($configKey); $data = explode($delimiter, $configValue); if ($trim) { $data = array_map('trim', $data); } } return $data; }
/** * Get command metrics instance by command key for given command config * * @param string $commandKey * @param Config $commandConfig * @return CommandMetrics */ public function get($commandKey, Config $commandConfig) { if (!isset($this->commandMetricsByCommand[$commandKey])) { $metricsConfig = $commandConfig->get('metrics'); $statisticalWindow = $metricsConfig->get('rollingStatisticalWindowInMilliseconds'); $windowBuckets = $metricsConfig->get('rollingStatisticalWindowBuckets'); $snapshotInterval = $metricsConfig->get('healthSnapshotIntervalInMilliseconds'); $counter = new MetricsCounter($commandKey, $this->stateStorage, $statisticalWindow, $windowBuckets); $this->commandMetricsByCommand[$commandKey] = new CommandMetrics($counter, $snapshotInterval); } return $this->commandMetricsByCommand[$commandKey]; }
/** * Get circuit breaker instance by command key for given command config * * @param string $commandKey * @param Config $commandConfig * @param CommandMetrics $metrics * @return CircuitBreakerInterface */ public function get($commandKey, Config $commandConfig, CommandMetrics $metrics) { if (!isset($this->circuitBreakersByCommand[$commandKey])) { $circuitBreakerConfig = $commandConfig->get('circuitBreaker'); if ($circuitBreakerConfig->get('enabled')) { $this->circuitBreakersByCommand[$commandKey] = new CircuitBreaker($commandKey, $metrics, $commandConfig, $this->stateStorage); } else { $this->circuitBreakersByCommand[$commandKey] = new NoOpCircuitBreaker(); } } return $this->circuitBreakersByCommand[$commandKey]; }
/** * Initialize networks from config * */ protected function initNetworks() { $networkNames = array('Aleph', 'Virtua'); foreach ($networkNames as $networkName) { $configName = ucfirst($networkName) . 'Networks'; /** @var Config $networkConfigs */ $networkConfigs = $this->configHoldings->get($configName); foreach ($networkConfigs as $networkCode => $networkConfig) { list($domain, $library) = explode(',', $networkConfig, 2); $this->networks[$networkCode] = array('domain' => $domain, 'library' => $library, 'type' => $networkName); } } }
/** * Set a global config * * @param \Zend\Config\Config $config */ public static function setConfig(\Zend\Config\Config $config) { self::$_config = $config; if (null !== ($broker = $config->get('adapter_broker'))) { self::setAdapterBroker($broker); } if (null !== ($broker = $config->get('scrolling_style_broker'))) { self::setScrollingStyleBroker($broker); } $scrollingStyle = $config->get('scrolling_style'); if ($scrollingStyle != null) { self::setDefaultScrollingStyle($scrollingStyle); } }
public function testZF1417_DefaultValues() { $config = new Config($this->all); $value = $config->get('notthere', 'default'); $this->assertTrue($value === 'default'); $this->assertTrue($config->notThere === null); }
/** * Set options * * @param Config $options Options */ protected function setOptions(Config $options) { if ($options->offsetExists('name')) { $this->setName($options->get('name')); } if ($options->offsetExists('description')) { $this->setDescription($options->get('description')); } if ($options->offsetExists('fields')) { $this->setFields($options->get('fields')); } }
public function toArray(array $opts = null) { if (empty($opts)) { $opts = array(); } $config = new Config($opts); if ($config->get('strings-only')) { $array = array('id' => $this->getId(), 'neighborhood_name' => $this->getNeighborhood()->getName(), 'datetime_added' => $this->getDateTimeAdded()); } else { $hydrator = new \Zend\Stdlib\Hydrator\ClassMethods(); $array = $hydrator->extract($this); unset($array['iterator_class']); unset($array['iterator']); unset($array['flags']); unset($array['array_copy']); unset($array['polygon']); unset($array['whathood_user']); // for geojson, we want to merge the polygon $array = array_merge($array, $this->polygonToGeoJsonArray($this->polygon)); if ($this->getNeighborhood() != null) { $array['neighborhood'] = $this->getNeighborhood()->toArray(); } if ($this->getWhathoodUser() != null) { $array['user'] = $this->getWhathoodUser()->toArray(); } } return $array; }
/** * Set a global config * * @param \Zend\Config\Config $config */ public static function setConfig(\Zend\Config\Config $config) { self::$_config = $config; $adapterPaths = $config->get('adapterpaths'); if ($adapterPaths != null) { self::addAdapterPrefixPaths($adapterPaths->adapterpath->toArray()); } $prefixPaths = $config->get('prefixpaths'); if ($prefixPaths != null) { self::addScrollingStylePrefixPaths($prefixPaths->prefixpath->toArray()); } $scrollingStyle = $config->get('scrollingstyle'); if ($scrollingStyle != null) { self::setDefaultScrollingStyle($scrollingStyle); } }
/** * Test Bootstrapper * * @copyright Copyright (c) 2012 WebPT, INC */ date_default_timezone_set('UTC'); error_reporting(E_ALL | E_STRICT); defined('APPLICATION_PATH') || define('APPLICATION_PATH', realpath(__DIR__ . '/../..')); chdir(APPLICATION_PATH); require_once __DIR__ . "/../../vendor/autoload.php"; // special import for the module class as it doesn't appear to namespace structure require_once __DIR__ . '/../../Module.php'; use EMRCore\Config\Application as ApplicationConfig; use Zend\Config\Config as ZendConfig; use Zend\Config\Processor\Token; // Core global config. $moduleConfig = new ZendConfig(include __DIR__ . '/../../vendor/WebPT/EMRCore/src/EMRCore/Config/config/global.php', true); // Module config. $module = new DeskModule\Module(); $moduleConfig->merge(new ZendConfig($module->getConfig())); // Integration global config. $moduleConfig->merge(new ZendConfig(include __DIR__ . '/config/global.php')); // Integration local config. if (file_exists(__DIR__ . '/config/local.php') == true) { $localTestConfig = new ZendConfig(include __DIR__ . '/config/local.php', true); $moduleConfig->merge($localTestConfig); } $processor = new Token($moduleConfig->get('tokens')); $processor->process($moduleConfig); ApplicationConfig::getInstance()->setConfiguration($moduleConfig->toArray(), false);
public function testNoParams() { $config = array(Zend\Cloud\StorageService\Factory::STORAGE_ADAPTER_KEY => $this->_config->get(Zend\Cloud\StorageService\Factory::STORAGE_ADAPTER_KEY)); $this->setExpectedException('Zend\\Cloud\\StorageService\\Exception'); $s = Zend\Cloud\StorageService\Factory::getAdapter($config); }
/** * @param Config\Config $config * * @return bool * @author Fabian Köstring */ private function elasticsearchCreateType($class, Config\Config $config) { try { $properties = []; foreach ($config->get('mapping') as $elasticsearchProperty => $classAttribute) { $propertyColumnAnnotation = $this->getPropertyColumnAnnotation($class, $classAttribute); $properties[$elasticsearchProperty] = ['type' => $propertyColumnAnnotation->type]; } $params = ['index' => $config->get('index'), 'body' => ['mappings' => [$config->get('type') => ['_source' => ['enabled' => true], 'properties' => $properties]]]]; //echo "<pre>"; //print_r($params); //echo "</pre>"; //die(); $response = $this->elasticsearchClient->indices()->create($params); return true; } catch (\Exception $e) { // @todo - Hier müssen genauere Fehlermeldungen rausgehauen werden. Was fehlt denn? Return false die('elasticsearchCreateType is failing. Maybe missing Parameter.'); } return false; }
/** * Adds reference to the command to the current request log */ private function recordExecutedCommand() { if ($this->requestLog && $this->config->get('requestLog')->get('enabled')) { $this->requestLog->addExecutedCommand($this); } }
/** * * @return array */ public function getConnectionParameters() { return $this->connectionParameters->get('params'); }
/** * @return void */ public function setUp() { $iniReader = new Ini(); $config = new Config($iniReader->fromFile('../../../local/config/vufind/config.ini')); $this->connector = new Connector($config->get('Summon')->get('apiId'), $config->get('Summon')->get('apiKey')); }