本文整理汇总了PHP中Nette\DI\Config\Helpers类的典型用法代码示例。如果您正苦于以下问题:PHP Helpers类的具体用法?PHP Helpers怎么用?PHP Helpers使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Helpers类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: loadConfiguration
public function loadConfiguration()
{
$builder = $this->getContainerBuilder();
$config = $this->getConfig();
if (isset($config['server']) || isset($config['certificate'])) {
$config = array('default' => $config);
}
if (empty($config)) {
throw new \Exception('Please configure the APNs extensions.');
}
foreach ($config as $name => $conf) {
if (!is_array($conf) || empty($conf['certificate'])) {
throw new \Exception('Please configure the APNs extensions.');
}
$conf = Nette\DI\Config\Helpers::merge($conf, $this->defaults);
if ($conf['environment'] == 1 || $conf['environment'] === 'production') {
$conf['environment'] = 1;
} else {
$conf['environment'] = 0;
}
$this->processProvider($name, $conf);
$this->processFeedback($name, $conf);
}
$builder->addDefinition($this->prefix('registry'))->setClass('Nemec\\Apns\\Registry', array($this->configuredProviders, $this->configuredFeedbacks, $builder->parameters[$this->name]['defaultProvider'], $builder->parameters[$this->name]['defaultFeedback']));
}
开发者ID:petrnemec,项目名称:nette-apns,代码行数:25,代码来源:ApnsExtension.php
示例2: getAssets
/**
* @param array $resources
* @param bool $minify
* @param string $baseDir
* @throws AssetsException
* @return array
*/
public function getAssets(array $resources, $minify, $baseDir)
{
$config = [];
$return = [];
foreach ($resources as $resource) {
$contents = file_get_contents($resource);
$decompiled = Strings::endsWith($resource, '.json') ? json_decode($contents, TRUE) : Neon::decode($contents);
$config = \Nette\DI\Config\Helpers::merge($config, $decompiled);
}
foreach ($config as $moduleArray) {
foreach ($moduleArray as $type => $typeArray) {
if (!isset(self::$supportTypes[$type])) {
throw new AssetsException("Found section '{$type}', but expected one of " . implode(', ', array_keys(self::$supportTypes)));
}
foreach ($typeArray as $minified => $assets) {
if ($minify) {
$return[$type][$minified] = TRUE;
continue;
}
foreach ((array) $assets as $row) {
if (strpos($row, '*') !== FALSE) {
/** @var \SplFileInfo $file */
foreach (Finder::findFiles(basename($row))->in($baseDir . '/' . dirname($row)) as $file) {
$return[$type][$minified][] = dirname($row) . '/' . $file->getBasename();
}
} else {
$return[$type][$minified][] = $row;
}
}
}
}
}
return $return;
}
开发者ID:webchemistry,项目名称:assets,代码行数:41,代码来源:AssetsExtension.php
示例3: getConfig
/**
* Returns extension configuration.
* @param array default unexpanded values.
* @return array
*/
public function getConfig(array $defaults = NULL)
{
$config = $this->compiler->getConfig();
$config = isset($config[$this->name]) ? $config[$this->name] : array();
unset($config['services'], $config['factories']);
return Config\Helpers::merge($config, $this->compiler->getContainerBuilder()->expand($defaults));
}
开发者ID:petrparolek,项目名称:web_cms,代码行数:12,代码来源:CompilerExtension.php
示例4: addAutoloadConfig
/**
* @param string $path
* @param string $find
* @param int $depth
*/
public function addAutoloadConfig($path, $find = 'config.neon', $depth = -1)
{
// Development
if (!$this->cacheConfig && $this->isDevelopment()) {
foreach (Finder::find($find)->from($path)->limitDepth($depth) as $file) {
$this->addConfig((string) $file);
}
return;
}
// Production
$directory = $this->parameters['tempDir'] . '/cache/configs';
$cachePath = $directory . '/' . Strings::webalize(str_replace(dirname($this->parameters['appDir']), '', $path)) . '.neon';
if (file_exists($cachePath)) {
$this->addConfig($cachePath);
return;
}
$encoder = new Encoder();
$decoder = new Decoder();
@mkdir($directory);
$content = [];
foreach (Finder::find($find)->from($path)->limitDepth($depth) as $file) {
$content = Helpers::merge($content, $decoder->decode(file_get_contents($file)));
}
file_put_contents($cachePath, $encoder->encode($content));
$this->addConfig($cachePath);
}
开发者ID:ThunboltCMS,项目名称:configuration,代码行数:31,代码来源:Configuration.php
示例5: loadConfiguration
public function loadConfiguration()
{
$builder = $this->getContainerBuilder();
$config = $this->getConfig($this->defaults + $this->elasticaDefaults);
if (empty($config['connections'])) {
$config['connections']['default'] = Config\Helpers::merge(array_intersect_key($config, $this->connectionDefaults), $builder->expand($this->connectionDefaults));
} else {
foreach ($config['connections'] as $name => $connectionConfig) {
$config['connections'][$name] = Config\Helpers::merge($connectionConfig, $builder->expand($this->connectionDefaults));
}
}
// replace curl string options with their CURLOPT_ constant values
foreach ($config['connections'] as $name => $connectionConfig) {
$curlOptions = array();
foreach ($connectionConfig['config']['curl'] as $option => $value) {
if (!defined($constant = 'CURLOPT_' . strtoupper($option))) {
throw new Nette\InvalidArgumentException('There is no constant "' . $constant . '", therefore "' . $option . '" cannot be set.');
}
$curlOptions[constant($constant)] = $value;
}
$config['connections'][$name]['config']['curl'] = $curlOptions;
}
$elasticaConfig = array_intersect_key($config, $this->elasticaDefaults);
$elastica = $builder->addDefinition($this->prefix('elastica'))->setClass('Kdyby\\ElasticSearch\\Client', array($elasticaConfig));
if ($config['debugger']) {
$builder->addDefinition($this->prefix('panel'))->setClass('Kdyby\\ElasticSearch\\Diagnostics\\Panel');
$elastica->addSetup($this->prefix('@panel') . '::register', array('@self'));
}
}
开发者ID:EaredSeal,项目名称:ElasticSearch,代码行数:29,代码来源:SearchExtension.php
示例6: loadNativeSessionHandler
protected function loadNativeSessionHandler(array $session)
{
$builder = $this->getContainerBuilder();
$params = array_intersect_key($session, array_flip(array('weight', 'timeout', 'database', 'prefix', 'auth', 'persistent')));
if (substr($session['host'], 0, 1) === '/') {
$savePath = $session['host'];
} else {
$savePath = sprintf('tcp://%s:%d', $session['host'], $session['port']);
}
if (!$params['persistent']) {
unset($params['persistent']);
}
if (!$params['auth']) {
unset($params['auth']);
}
$options = array('saveHandler' => 'redis', 'savePath' => $savePath . ($params ? '?' . http_build_query($params, '', '&') : ''));
foreach ($builder->getDefinition('session')->setup as $statement) {
if ($statement->entity === 'setOptions') {
$statement->arguments[0] = Nette\DI\Config\Helpers::merge($options, $statement->arguments[0]);
unset($options);
break;
}
}
if (isset($options)) {
$builder->getDefinition('session')->addSetup('setOptions', array($options));
}
}
开发者ID:VasekPurchart,项目名称:khanovaskola-v3,代码行数:27,代码来源:RedisExtension.php
示例7: loadConfiguration
/**
* Processes configuration data. Intended to be overridden by descendant.
*
* @throws \Exception
*/
public function loadConfiguration()
{
$builder = $this->getContainerBuilder();
$values = Nette\DI\Config\Helpers::merge($this->getConfig(), $this->defaults);
$config = Nette\DI\Helpers::expand($values['paramsSettings'], $builder->parameters);
unset($values['paramsSettings']);
$db = NULL;
if ($config['database'] !== FALSE) {
$databaseClass = strpos($config['database'], '\\') ? $config['database'] : 'WebChemistry\\Parameters\\Database\\' . $config['database'];
if (!class_exists($databaseClass)) {
throw new \Exception("Class '{$databaseClass}' does not exist.");
}
$db = $builder->addDefinition($this->prefix('database'))->setClass('WebChemistry\\Parameters\\IDatabase')->setFactory($databaseClass);
if ($config['database'] === 'Doctrine') {
$implements = class_implements($config['entity']);
if (array_search('WebChemistry\\Parameters\\IEntity', $implements) === FALSE) {
throw new ConfigurationException("Class '{$config['entity']}' must implements WebChemistry\\Parameters\\IEntity.");
}
$db->addSetup('setEntity', [$config['entity']]);
}
}
$builder->addDefinition($this->prefix('provider'))->setClass('WebChemistry\\Parameters\\Provider', [$values, $config['cache'], $db]);
if ($config['bar'] && class_exists('Tracy\\Debugger')) {
$builder->addDefinition($this->prefix('bar'))->setClass('WebChemistry\\Parameters\\Bar\\Debug', [(bool) $db]);
}
}
开发者ID:webchemistry,项目名称:parameters,代码行数:31,代码来源:ParametersExtension.php
示例8: buildClient
/**
* @param string $name
* @param array $config
* @return Nette\DI\ServiceDefinition
*/
protected function buildClient($name, $config)
{
$builder = $this->getContainerBuilder();
$defaultConfig = $this->getConfig($this->clientDefaults);
if ($parentName = Config\Helpers::takeParent($config)) {
Nette\Utils\Validators::assertField($this->configuredClients, $parentName, 'array', "parent configuration '%', are you sure it's defined?");
$defaultConfig = Config\Helpers::merge($this->configuredClients[$parentName], $defaultConfig);
}
$config = Config\Helpers::merge($config, $defaultConfig);
$config = array_intersect_key(self::fixClientConfig($config), $this->clientDefaults);
$client = $builder->addDefinition($clientName = $this->prefix(($name ? $name . '_' : '') . 'client'))->setClass('Kdyby\\Redis\\RedisClient', array('host' => $config['host'], 'port' => $config['port'], 'database' => $config['database'], 'timeout' => $config['timeout'], 'auth' => $config['auth'], 'persistent' => $config['persistent']));
if (empty($builder->parameters[$this->name]['defaultClient'])) {
$builder->parameters[$this->name]['defaultClient'] = $clientName;
$this->configuredClients['default'] = $config;
$builder->addDefinition($this->prefix('default_client'))->setClass('Kdyby\\Redis\\RedisClient')->setFactory('@' . $clientName)->setAutowired(FALSE);
} else {
$client->setAutowired(FALSE);
}
$this->configuredClients[$name] = $config;
$client->addSetup('setupLockDuration', array($config['lockDuration'], $config['lockAcquireTimeout']));
$client->addSetup('setConnectionAttempts', array($config['connectionAttempts']));
$client->addTag('redis.client');
if (array_key_exists('debugger', $config) && $config['debugger']) {
$builder->addDefinition($panelName = $clientName . '.panel')->setClass('Kdyby\\Redis\\Diagnostics\\Panel')->setFactory('Kdyby\\Redis\\Diagnostics\\Panel::register')->addSetup('$renderPanel', array($config['debugger'] !== self::PANEL_COUNT_MODE))->addSetup('$name', array($name ?: 'default'));
$client->addSetup('setPanel', array('@' . $panelName));
}
return $client;
}
开发者ID:HotelQuickly,项目名称:Redis,代码行数:33,代码来源:RedisExtension.php
示例9: generateConfig
/**
* @return array
*/
protected function generateConfig()
{
$config = array();
$loader = $this->createLoader();
foreach ($this->configFiles as $info) {
$config = Config\Helpers::merge($loader->load($info[0], $info[1]), $config);
}
$this->dependencies = array_merge($this->dependencies, $loader->getDependencies());
return Config\Helpers::merge($config, $this->config);
}
开发者ID:petrparolek,项目名称:web_cms,代码行数:13,代码来源:ContainerFactory.php
示例10: getMappingConfig
/**
* @return array
* @throws \Librette\Application\PresenterFactory\InvalidStateException
*/
protected function getMappingConfig()
{
$globalConfig = $this->compiler->getConfig();
if (isset($globalConfig['nette']['application']['mapping']) && isset($globalConfig[$this->name]['mapping'])) {
throw new InvalidStateException("You cannot use both nette.application.mapping and {$this->name}.mapping config section, choose one.");
}
$userConfig = isset($globalConfig[$this->name]['mapping']) ? $globalConfig[$this->name]['mapping'] : (isset($globalConfig['nette']['application']['mapping']) ? $globalConfig['nette']['application']['mapping'] : []);
$config = Nette\DI\Config\Helpers::merge($userConfig, $this->defaults['mapping']);
return $config;
}
开发者ID:librette,项目名称:presenter-factory,代码行数:14,代码来源:PresenterFactoryExtension.php
示例11: getConfig
/**
* @return array
*/
public function getConfig(array $defaults = NULL, $expand = TRUE)
{
$config = parent::getConfig($defaults, $expand);
// ignoredAnnotations
$globalConfig = $this->compiler->getConfig();
if (!empty($globalConfig['doctrine']['ignoredAnnotations'])) {
trigger_error("Section 'doctrine: ignoredAnnotations:' is deprecated, please use '{$this->name}: ignore:' ", E_USER_DEPRECATED);
$config = Nette\DI\Config\Helpers::merge($config, array('ignore' => $globalConfig['doctrine']['ignoredAnnotations']));
}
return $this->compiler->getContainerBuilder()->expand($config);
}
开发者ID:peterkrejci,项目名称:music-collection,代码行数:14,代码来源:AnnotationsExtension.php
示例12: dump
/**
* Generates configuration in NEON format.
* @return string
*/
public function dump(array $data)
{
$tmp = array();
foreach ($data as $name => $secData) {
if ($parent = Helpers::takeParent($secData)) {
$name .= ' ' . self::INHERITING_SEPARATOR . ' ' . $parent;
}
$tmp[$name] = $secData;
}
return "# generated by Nette\n\n" . Neon\Neon::encode($tmp, Neon\Neon::BLOCK);
}
开发者ID:re1la2pse,项目名称:GromesProjekt,代码行数:15,代码来源:NeonAdapter.php
示例13: validateConfig
/**
* Checks whether $config contains only $expected items and returns combined array.
* @return array
* @throws Nette\InvalidStateException
*/
public function validateConfig(array $expected, array $config = NULL, $name = NULL)
{
if (func_num_args() === 1) {
return $this->config = $this->validateConfig($expected, $this->config);
}
if ($extra = array_diff_key((array) $config, $expected)) {
$name = $name ?: $this->name;
$extra = implode(", {$name}.", array_keys($extra));
throw new Nette\InvalidStateException("Unknown configuration option {$name}.{$extra}.");
}
return Config\Helpers::merge($config, $expected);
}
开发者ID:h4kuna,项目名称:di,代码行数:17,代码来源:CompilerExtension.php
示例14: mergeIncludedFiles
/**
* @param array $data
* @param string $includeKeyword
* @return array
*/
private function mergeIncludedFiles($data, $filename, $includeKeyword)
{
if (isset($data[$includeKeyword])) {
foreach ($data[$includeKeyword] as $include) {
$includeFile = dirname($filename) . DIRECTORY_SEPARATOR . $include;
$includeData = $this->parse($includeFile);
$data = Helpers::merge($includeData, $data);
}
unset($data[$includeKeyword]);
}
return $data;
}
开发者ID:enumag,项目名称:DoctrineFixtures,代码行数:17,代码来源:NeonParser.php
示例15: validateConfig
/**
* Checks whether $config contains only $expected items and returns combined array.
* @return array
* @throws Nette\InvalidStateException
*/
public function validateConfig(array $expected, array $config = NULL, $name = NULL)
{
if (func_num_args() === 1) {
return $this->config = $this->validateConfig($expected, $this->config);
}
if ($extra = array_diff_key((array) $config, $expected)) {
$name = $name ?: $this->name;
$hint = Nette\Utils\ObjectMixin::getSuggestion(array_keys($expected), key($extra));
$extra = $hint ? key($extra) : implode(", {$name}.", array_keys($extra));
throw new Nette\InvalidStateException("Unknown configuration option {$name}.{$extra}" . ($hint ? ", did you mean {$name}.{$hint}?" : '.'));
}
return Config\Helpers::merge($config, $expected);
}
开发者ID:Northys,项目名称:di,代码行数:18,代码来源:CompilerExtension.php
示例16: dump
/**
* Generates configuration in NEON format.
* @return string
*/
public function dump(array $data)
{
$tmp = array();
foreach ($data as $name => $secData) {
if ($parent = Helpers::takeParent($secData)) {
$name .= ' ' . self::INHERITING_SEPARATOR . ' ' . $parent;
}
$tmp[$name] = $secData;
}
array_walk_recursive($tmp, function (&$val) {
if ($val instanceof Statement) {
$val = NeonAdapter::statementToEntity($val);
}
});
return "# generated by Nette\n\n" . Neon\Neon::encode($tmp, Neon\Neon::BLOCK);
}
开发者ID:norik16,项目名称:TripMap,代码行数:20,代码来源:NeonAdapter.php
示例17: loadConfiguration
public function loadConfiguration()
{
$builder = $this->getContainerBuilder();
$config = $this->getConfig($this->getDefaultConfig());
$builder->addDefinition($this->prefix('cssNamingConvention'))->setFactory('WebLoader\\DefaultOutputNamingConvention::createCssConvention');
$builder->addDefinition($this->prefix('jsNamingConvention'))->setFactory('WebLoader\\DefaultOutputNamingConvention::createJsConvention');
$builder->parameters['webloader'] = $config;
$loaderFactoryTempPaths = array();
foreach (array('css', 'js') as $type) {
foreach ($config[$type] as $name => $wlConfig) {
$wlConfig = Helpers::merge($wlConfig, $config[$type . 'Defaults']);
$this->addWebLoader($builder, $type . ucfirst($name), $wlConfig);
$loaderFactoryTempPaths[strtolower($name)] = $wlConfig['tempPath'];
}
}
$builder->addDefinition($this->prefix('factory'))->setClass('WebLoader\\Nette\\LoaderFactory', array($loaderFactoryTempPaths));
}
开发者ID:jfilla,项目名称:WebLoader,代码行数:17,代码来源:Extension.php
示例18: loadConfiguration
public function loadConfiguration()
{
$builder = $this->getContainerBuilder();
$config = $this->getConfig($this->defaults + $this->elasticaDefaults);
if (empty($config['connections'])) {
$config['connections']['default'] = Config\Helpers::merge(array_intersect_key($config, $this->connectionDefaults), $builder->expand($this->connectionDefaults));
} else {
foreach ($config['connection'] as $name => $connectionConfig) {
$config['connections'][$name] = Config\Helpers::merge($connectionConfig, $builder->expand($this->connectionDefaults));
}
}
$elasticaConfig = array_intersect_key($config, $this->elasticaDefaults);
$elastica = $builder->addDefinition($this->prefix('elastica'))->setClass('Kdyby\\ElasticSearch\\Client', array($elasticaConfig));
if ($config['debugger']) {
$builder->addDefinition($this->prefix('panel'))->setClass('Kdyby\\ElasticSearch\\Diagnostics\\Panel');
$elastica->addSetup($this->prefix('@panel') . '::register', array('@self'));
}
}
开发者ID:BianoCZ,项目名称:ElasticSearch,代码行数:18,代码来源:SearchExtension.php
示例19: loadConfiguration
public function loadConfiguration()
{
$this->listeners = [];
$this->allowedManagerSetup = [];
$builder = $this->getContainerBuilder();
$config = $this->getConfig($this->defaults);
$userConfig = $this->getConfig();
if (!array_key_exists('debugger', $userConfig)) {
if (in_array(php_sapi_name(), ['cli', 'phpdbg'], TRUE)) {
$config['debugger'] = FALSE;
// disable by default in CLI
} elseif (!$config['debugger']) {
$config['debugger'] = self::PANEL_COUNT_MODE;
}
}
$evm = $builder->addDefinition($this->prefix('manager'))->setClass('Kdyby\\Events\\EventManager');
if ($config['debugger']) {
$defaults = ['dispatchTree' => FALSE, 'dispatchLog' => TRUE, 'events' => TRUE, 'listeners' => FALSE];
if (is_array($config['debugger'])) {
$config['debugger'] = Nette\DI\Config\Helpers::merge($config['debugger'], $defaults);
} else {
$config['debugger'] = $config['debugger'] !== self::PANEL_COUNT_MODE;
}
$evm->addSetup('Kdyby\\Events\\Diagnostics\\Panel::register(?, ?)->renderPanel = ?', ['@self', '@container', $config['debugger']]);
}
if ($config['exceptionHandler'] !== NULL) {
$evm->addSetup('setExceptionHandler', $this->filterArgs($config['exceptionHandler']));
}
Nette\Utils\Validators::assertField($config, 'subscribers', 'array');
foreach ($config['subscribers'] as $i => $subscriber) {
$def = $builder->addDefinition($this->prefix('subscriber.' . $i));
$def->setFactory(Nette\DI\Compiler::filterArguments([is_string($subscriber) ? new Nette\DI\Statement($subscriber) : $subscriber])[0]);
list($subscriberClass) = (array) $builder->normalizeEntity($def->getEntity());
if (class_exists($subscriberClass)) {
$def->setClass($subscriberClass);
}
$def->setAutowired(FALSE);
$def->addTag(self::SUBSCRIBER_TAG);
}
if (class_exists('Symfony\\Component\\EventDispatcher\\Event')) {
$builder->addDefinition($this->prefix('symfonyProxy'))->setClass('Symfony\\Component\\EventDispatcher\\EventDispatcherInterface')->setFactory('Kdyby\\Events\\SymfonyDispatcher');
}
$this->loadedConfig = $config;
}
开发者ID:LidskaSila,项目名称:kdyby-events,代码行数:44,代码来源:EventsExtension.php
示例20: loadConfiguration
public function loadConfiguration()
{
$builder = $this->getContainerBuilder();
$config = $this->getConfig();
if (isset($config['apiKey'])) {
$config = array('default' => $config);
}
if (empty($config)) {
throw new \Exception('Please configure the GCM extensions.');
}
foreach ($config as $name => $conf) {
if (!is_array($conf) || empty($conf['apiKey'])) {
throw new \Exception('Please configure the GCM extensions.');
}
$conf = Nette\DI\Config\Helpers::merge($conf, $this->defaults);
$this->processProvider($name, $conf);
}
$builder->addDefinition($this->prefix('registry'))->setClass('Nemec\\Gcm\\Registry', array($this->configuredProviders, $builder->parameters[$this->name]['defaultProvider']));
}
开发者ID:petrnemec,项目名称:nette-gcm,代码行数:19,代码来源:GcmExtension.php
注:本文中的Nette\DI\Config\Helpers类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论