本文整理汇总了PHP中Symfony\Component\Config\Definition\Exception\InvalidConfigurationException类的典型用法代码示例。如果您正苦于以下问题:PHP InvalidConfigurationException类的具体用法?PHP InvalidConfigurationException怎么用?PHP InvalidConfigurationException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了InvalidConfigurationException类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: mergeValues
/**
* @interitdoc
*/
protected function mergeValues($leftSide, $rightSide)
{
if (false === $rightSide) {
// if this is still false after the last config has been merged the
// finalization pass will take care of removing this key entirely
return false;
}
if (false === $leftSide || !$this->performDeepMerging) {
return $rightSide;
}
foreach ($rightSide as $k => $v) {
// no conflict
if (!array_key_exists($k, $leftSide)) {
if (!$this->allowNewKeys) {
$ex = new InvalidConfigurationException(sprintf('You are not allowed to define new elements for path "%s". ' . 'Please define all elements for this path in one config file. ' . 'If you are trying to overwrite an element, make sure you redefine it ' . 'with the same name.', $this->getPath()));
$ex->setPath($this->getPath());
throw $ex;
}
$leftSide[$k] = $v;
continue;
}
// nothing to merge here
if (!is_array($v)) {
continue;
}
if (!isset($this->children[$k])) {
$this->children[$k] = new DynamicArrayNode($k);
}
$leftSide[$k] = $this->children[$k]->merge($leftSide[$k], $v);
}
return $leftSide;
}
示例2: getConfigTreeBuilder
public function getConfigTreeBuilder()
{
$tb = new TreeBuilder();
$tb->root('jms_i18n_routing')->fixXmlConfig('host')->validate()->always()->then(function ($v) {
if ($v['hosts']) {
foreach ($v['locales'] as $locale) {
if (!isset($v['hosts'][$locale])) {
$ex = new InvalidConfigurationException(sprintf('Invalid configuration at path "jms_i18n_routing.hosts": You must set a host for locale "%s".', $locale));
$ex->setPath('jms_i18n_routing.hosts');
throw $ex;
}
}
}
if (!in_array($v['default_locale'], $v['locales'], true)) {
$ex = new InvalidConfigurationException('Invalid configuration at path "jms_i18n_routing.default_locale": The default locale must be one of the configured locales.');
$ex->setPath('jms_i18n_routing.default_locale');
throw $ex;
}
return $v;
})->end()->children()->scalarNode('default_locale')->isRequired()->end()->arrayNode('locales')->beforeNormalization()->ifString()->then(function ($v) {
return preg_split('/\\s*,\\s*/', $v);
})->end()->requiresAtLeastOneElement()->prototype('scalar')->end()->end()->scalarNode('catalogue')->defaultValue('routes')->end()->scalarNode('strategy')->defaultValue('custom')->validate()->ifNotInArray(array('prefix', 'prefix_except_default', 'custom'))->thenInvalid('Must be one of the following: prefix, prefix_except_default, or custom (default)')->end()->end()->booleanNode('prefix_with_locale')->defaultFalse()->end()->booleanNode('omit_prefix_when_default')->defaultTrue()->end()->arrayNode('hosts')->validate()->always()->then(function ($v) {
if (count($v) !== count(array_flip($v))) {
throw new \Exception('Every locale must map to a different host. You cannot have multiple locales map to the same host.');
}
return $v;
})->end()->useAttributeAsKey('locale')->prototype('scalar')->end()->end()->end()->end();
return $tb;
}
示例3: validateConfiguration
/**
* @param array $config
* @throws InvalidConfigurationException
*/
private function validateConfiguration($config)
{
$exception = null;
if (0 === count($config['domains'])) {
$exception = new InvalidConfigurationException('You must provide at least one domain in configuration in "tga_lets_encrypt.domains".');
$exception->setPath('tga_lets_encrypt.domains');
throw $exception;
}
if ($config['logs_directory'] && !file_exists($config['logs_directory'])) {
$exception = new InvalidConfigurationException(sprintf('Logs directory "%s" (configured in "tga_lets_encrypt.logs_directory") does not exist.', $config['logs_directory']));
$exception->setPath('tga_lets_encrypt.logs_directory');
throw $exception;
}
if (!filter_var($config['recovery_email'], FILTER_VALIDATE_EMAIL)) {
$exception = new InvalidConfigurationException(sprintf('Recovery email "%s" (configured in "tga_lets_encrypt.recovery_email") is not a valid email.', $config['recovery_email']));
$exception->setPath('tga_lets_encrypt.recovery_email');
throw $exception;
}
if ($config['monitoring']['email']['enabled']) {
foreach ($config['monitoring']['email']['to'] as $toEmail) {
if (!filter_var($toEmail, FILTER_VALIDATE_EMAIL)) {
$exception = new InvalidConfigurationException(sprintf('Email monitoring recipient email "%s" (configured in "tga_lets_encrypt.monitoring.email.to") ' . 'is not a valid email.', $toEmail));
$exception->setPath('tga_lets_encrypt.monitoring.email.to');
throw $exception;
}
}
}
}
示例4: getConfigTreeBuilder
public function getConfigTreeBuilder()
{
$tb = new TreeBuilder();
$tb->root('jms_i18n_routing')->fixXmlConfig('host')->validate()->always()->then(function ($v) {
if ($v['hosts']) {
foreach ($v['locales'] as $locale) {
if (!isset($v['hosts'][$locale])) {
$ex = new InvalidConfigurationException(sprintf('Invalid configuration at path "jms_i18n_routing.hosts": You must set a host for locale "%s".', $locale));
$ex->setPath('jms_i18n_routing.hosts');
throw $ex;
}
}
}
if (!in_array($v['default_locale'], $v['locales'], true)) {
$ex = new InvalidConfigurationException('Invalid configuration at path "jms_i18n_routing.default_locale": The default locale must be one of the configured locales.');
$ex->setPath('jms_i18n_routing.default_locale');
throw $ex;
}
return $v;
})->end()->beforeNormalization()->always()->then(function ($v) {
if (isset($v['use_cookie'])) {
$v['cookie']['enabled'] = $v['use_cookie'];
unset($v['use_cookie']);
}
return $v;
})->end()->children()->scalarNode('default_locale')->isRequired()->end()->arrayNode('locales_in_domain')->beforeNormalization()->ifString()->then(function ($v) {
return preg_split('/\\s*,\\s*/', $v);
})->end()->requiresAtLeastOneElement()->prototype('scalar')->end()->end()->arrayNode('locales')->beforeNormalization()->ifString()->then(function ($v) {
return preg_split('/\\s*,\\s*/', $v);
})->end()->requiresAtLeastOneElement()->prototype('scalar')->end()->end()->scalarNode('catalogue')->defaultValue('routes')->end()->scalarNode('strategy')->defaultValue('custom')->validate()->ifNotInArray(array('prefix', 'prefix_except_default', 'custom', 'cutom_with_locales_in_one_domain'))->thenInvalid('Must be one of the following: prefix, prefix_except_default, custom (default), or cutom_with_locales_in_one_domain')->end()->end()->booleanNode('prefix_with_locale')->defaultFalse()->end()->booleanNode('omit_prefix_when_default')->defaultTrue()->end()->arrayNode('hosts')->useAttributeAsKey('locale')->prototype('scalar')->end()->end()->booleanNode('redirect_to_host')->defaultTrue()->end()->booleanNode('use_cookie')->defaultTrue()->info('DEPRECATED! Please use: cookie.enabled')->end()->arrayNode('cookie')->addDefaultsIfNotSet()->children()->booleanNode('enabled')->defaultTrue()->end()->scalarNode('name')->defaultValue('hl')->cannotBeEmpty()->end()->scalarNode('lifetime')->defaultValue(31536000)->end()->scalarNode('path')->defaultNull('/')->end()->scalarNode('domain')->defaultNull('')->end()->booleanNode('secure')->defaultFalse()->end()->booleanNode('httponly')->defaultFalse()->end()->end()->end()->end()->end();
return $tb;
}
示例5: resolve
/**
* Can Create, modify each node of configuration to resolve information
*
* @param array $configuration
* @return array resolved configuration
*/
public function resolve(array $configuration)
{
//Entities
foreach ($configuration['entities'] as $name => &$entity) {
foreach ($entity['properties'] as $propertyName => &$property) {
if (true === array_key_exists('cardinality', $property)) {
$baseCardinality = $property['cardinality'];
$cardinality = str_replace('*', 'N', $baseCardinality);
$cardinality = strtoupper($cardinality);
$result = [];
$flag = preg_match("#\\(?([01N]).{0,2}([01N])\\)?#", $cardinality, $result);
if ($flag !== 1) {
$ex = new InvalidConfigurationException('can not resolve syntax : ' . $baseCardinality);
$ex->setPath('entities.properties.' . $propertyName . '.cardinality');
throw $ex;
}
if (true === is_numeric($result[1]) && 0 === (int) $result[1] && true === is_numeric($result[2]) && 0 === (int) $result[2]) {
$ex = new InvalidConfigurationException('Cardinality 0.0 has no sense');
$ex->setPath('entities.properties.' . $propertyName . '.cardinality');
throw $ex;
}
$property['cardinality'] = $result[1] . '.' . $result[2];
}
}
unset($property);
}
unset($entity);
return $configuration;
}
示例6: finalizeValue
/**
* {@inheritdoc}
*/
protected function finalizeValue($value)
{
if (!$this->allowEmptyValue && empty($value)) {
$ex = new InvalidConfigurationException(sprintf('The path "%s" cannot contain an empty value, but got %s.', $this->getPath(), json_encode($value)));
$ex->setPath($this->getPath());
throw $ex;
}
return $value;
}
示例7: finalizeValue
protected function finalizeValue($value)
{
$value = parent::finalizeValue($value);
if (!in_array($value, $this->values, true)) {
$ex = new InvalidConfigurationException(sprintf('The value %s is not allowed for path "%s". Permissible values: %s', json_encode($value), $this->getPath(), implode(', ', array_map('json_encode', $this->values))));
$ex->setPath($this->getPath());
throw $ex;
}
return $value;
}
示例8: finalizeValue
/**
* {@inheritdoc}
*/
protected function finalizeValue($value)
{
foreach ($this->requiredKeys as $requiredKey) {
if (!array_key_exists($requiredKey, $value)) {
$msg = sprintf('The key "%s" at path "%s" must be configured.', $requiredKey, $this->getPath());
$ex = new InvalidConfigurationException($msg);
$ex->setPath($this->getPath());
throw $ex;
}
}
return parent::finalizeValue($value);
}
示例9: getConfigTreeBuilder
/**
* {@inheritDoc}
*/
public function getConfigTreeBuilder()
{
$treeBuilder = new TreeBuilder();
$rootNode = $treeBuilder->root('sli_ext_js_integration');
// Here you should define the parameters that are allowed to
// configure your bundle. See the documentation linked above for
// more information on that topic.
$rootNode->children()->scalarNode('extensibility_method')->defaultValue('bundle')->validate()->ifNotInArray(self::$VALID_EXTENSIBILITY_METHODS)->then(function () {
$e = new InvalidConfigurationException('Invalid value for "extensibility_mechanism" is given');
$e->setPath('sli_ext_js_integration/extensibility_mechanism');
throw $e;
})->end()->end()->end();
return $treeBuilder;
}
示例10: setConfig
/**
* Set the config options.
*
* @param array $config
* @param Symfony\Component\DependencyInjection\ContainerBuilder $container
*/
protected function setConfig($config, $container)
{
foreach (array('publisher_id', 'targets', 'div_class') as $attribute) {
if (isset($config[$attribute])) {
if ($attribute == 'targets') {
if (!is_array($config[$attribute])) {
$ex = new InvalidConfigurationException('Configuration for nodrew_dfp.targets must be an array.');
$ex->setPath('nodrew_dfp.targets');
throw $ex;
}
}
$container->setParameter('nodrew.dfp.' . $attribute, $config[$attribute]);
}
}
}
示例11: finalizeValue
/**
* {@inheritdoc}
*/
protected function finalizeValue($value)
{
$value = parent::finalizeValue($value);
$errorMsg = null;
if (isset($this->min) && $value < $this->min) {
$errorMsg = sprintf('The value %s is too small for path "%s". Should be greater than or equal to %s', $value, $this->getPath(), $this->min);
}
if (isset($this->max) && $value > $this->max) {
$errorMsg = sprintf('The value %s is too big for path "%s". Should be less than or equal to %s', $value, $this->getPath(), $this->max);
}
if (isset($errorMsg)) {
$ex = new InvalidConfigurationException($errorMsg);
$ex->setPath($this->getPath());
throw $ex;
}
return $value;
}
示例12: mergeValues
/**
* Merges values together.
*
* @param mixed $leftSide The left side to merge.
* @param mixed $rightSide The right side to merge.
*
* @return mixed The merged values
*
* @throws InvalidConfigurationException
* @throws \RuntimeException
*/
protected function mergeValues($leftSide, $rightSide)
{
if (false === $rightSide) {
// if this is still false after the last config has been merged the
// finalization pass will take care of removing this key entirely
return false;
}
if (false === $leftSide || !$this->performDeepMerging) {
return $rightSide;
}
foreach ($rightSide as $k => $v) {
// prototype, and key is irrelevant, so simply append the element
if (null === $this->keyAttribute) {
$leftSide[] = $v;
continue;
}
// no conflict
if (!array_key_exists($k, $leftSide)) {
if (!$this->allowNewKeys) {
$ex = new InvalidConfigurationException(sprintf('You are not allowed to define new elements for path "%s". ' . 'Please define all elements for this path in one config file.', $this->getPath()));
$ex->setPath($this->getPath());
throw $ex;
}
$leftSide[$k] = $v;
continue;
}
$this->prototype->setName($k);
$leftSide[$k] = $this->prototype->merge($leftSide[$k], $v);
}
return $leftSide;
}
示例13: mergeValues
protected function mergeValues($leftSide, $rightSide)
{
if (false === $rightSide) {
return false;
}
if (false === $leftSide || !$this->performDeepMerging) {
return $rightSide;
}
foreach ($rightSide as $k => $v) {
if (!array_key_exists($k, $leftSide)) {
if (!$this->allowNewKeys) {
$ex = new InvalidConfigurationException(sprintf('You are not allowed to define new elements for path "%s". ' . 'Please define all elements for this path in one config file. ' . 'If you are trying to overwrite an element, make sure you redefine it ' . 'with the same name.', $this->getPath()));
$ex->setPath($this->getPath());
throw $ex;
}
$leftSide[$k] = $v;
continue;
}
if (!isset($this->children[$k])) {
throw new \RuntimeException('merge() expects a normalized config array.');
}
$leftSide[$k] = $this->children[$k]->merge($leftSide[$k], $v);
}
return $leftSide;
}
示例14: mergeValues
protected function mergeValues($leftSide, $rightSide)
{
if (false === $rightSide) {
return false;
}
if (false === $leftSide || !$this->performDeepMerging) {
return $rightSide;
}
foreach ($rightSide as $k => $v) {
if (null === $this->keyAttribute) {
$leftSide[] = $v;
continue;
}
if (!array_key_exists($k, $leftSide)) {
if (!$this->allowNewKeys) {
$ex = new InvalidConfigurationException(sprintf('You are not allowed to define new elements for path "%s". ' . 'Please define all elements for this path in one config file.', $this->getPath()));
$ex->setPath($this->getPath());
throw $ex;
}
$leftSide[$k] = $v;
continue;
}
$this->prototype->setName($k);
$leftSide[$k] = $this->prototype->merge($leftSide[$k], $v);
}
return $leftSide;
}