本文整理汇总了PHP中Zend\Config\Config::get方法的典型用法代码示例。如果您正苦于以下问题:PHP Config::get方法的具体用法?PHP Config::get怎么用?PHP Config::get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend\Config\Config
的用法示例。
在下文中一共展示了Config::get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setUp
/**
* @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';
}
示例2: convert
/**
* @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);
}
示例3: getCommandConfig
/**
* 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;
}
示例4: generateViewHelpers
/**
* @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));
}
}
}
}
示例5: isRemoved
/**
* @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;
}
示例6: detectTarget
/**
* 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;
}
示例7: allowRequest
/**
* 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();
}
示例8: getConfigList
/**
* 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;
}
示例9: get
/**
* 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];
}
示例10: get
/**
* 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];
}
示例11: initNetworks
/**
* 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);
}
}
}
示例12: setConfig
/**
* 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);
}
}
示例13: testZF1417_DefaultValues
public function testZF1417_DefaultValues()
{
$config = new Config($this->all);
$value = $config->get('notthere', 'default');
$this->assertTrue($value === 'default');
$this->assertTrue($config->notThere === null);
}
示例14: setOptions
/**
* 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'));
}
}
示例15: toArray
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;
}