initial commit
This commit is contained in:
10
core/vendor/symfony/config/Symfony/Component/Config/CHANGELOG.md
vendored
Normal file
10
core/vendor/symfony/config/Symfony/Component/Config/CHANGELOG.md
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
CHANGELOG
|
||||
=========
|
||||
|
||||
2.1.0
|
||||
-----
|
||||
|
||||
* added a way to add documentation on configuration
|
||||
* implemented `Serializable` on resources
|
||||
* LoaderResolverInterface is now used instead of LoaderResolver for type
|
||||
hinting
|
||||
117
core/vendor/symfony/config/Symfony/Component/Config/ConfigCache.php
vendored
Normal file
117
core/vendor/symfony/config/Symfony/Component/Config/ConfigCache.php
vendored
Normal file
@@ -0,0 +1,117 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Config;
|
||||
|
||||
/**
|
||||
* ConfigCache manages PHP cache files.
|
||||
*
|
||||
* When debug is enabled, it knows when to flush the cache
|
||||
* thanks to an array of ResourceInterface instances.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*/
|
||||
class ConfigCache
|
||||
{
|
||||
private $debug;
|
||||
private $file;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param string $file The absolute cache path
|
||||
* @param Boolean $debug Whether debugging is enabled or not
|
||||
*/
|
||||
public function __construct($file, $debug)
|
||||
{
|
||||
$this->file = $file;
|
||||
$this->debug = (Boolean) $debug;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the cache file path.
|
||||
*
|
||||
* @return string The cache file path
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
return $this->file;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the cache is still fresh.
|
||||
*
|
||||
* This method always returns true when debug is off and the
|
||||
* cache file exists.
|
||||
*
|
||||
* @return Boolean true if the cache is fresh, false otherwise
|
||||
*/
|
||||
public function isFresh()
|
||||
{
|
||||
if (!is_file($this->file)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$this->debug) {
|
||||
return true;
|
||||
}
|
||||
|
||||
$metadata = $this->file.'.meta';
|
||||
if (!is_file($metadata)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$time = filemtime($this->file);
|
||||
$meta = unserialize(file_get_contents($metadata));
|
||||
foreach ($meta as $resource) {
|
||||
if (!$resource->isFresh($time)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes cache.
|
||||
*
|
||||
* @param string $content The content to write in the cache
|
||||
* @param array $metadata An array of ResourceInterface instances
|
||||
*
|
||||
* @throws \RuntimeException When cache file can't be wrote
|
||||
*/
|
||||
public function write($content, array $metadata = null)
|
||||
{
|
||||
$dir = dirname($this->file);
|
||||
if (!is_dir($dir)) {
|
||||
if (false === @mkdir($dir, 0777, true)) {
|
||||
throw new \RuntimeException(sprintf('Unable to create the %s directory', $dir));
|
||||
}
|
||||
} elseif (!is_writable($dir)) {
|
||||
throw new \RuntimeException(sprintf('Unable to write in the %s directory', $dir));
|
||||
}
|
||||
|
||||
$tmpFile = tempnam(dirname($this->file), basename($this->file));
|
||||
if (false !== @file_put_contents($tmpFile, $content) && @rename($tmpFile, $this->file)) {
|
||||
@chmod($this->file, 0666 & ~umask());
|
||||
} else {
|
||||
throw new \RuntimeException(sprintf('Failed to write cache file "%s".', $this->file));
|
||||
}
|
||||
|
||||
if (null !== $metadata && true === $this->debug) {
|
||||
$file = $this->file.'.meta';
|
||||
$tmpFile = tempnam(dirname($file), basename($file));
|
||||
if (false !== @file_put_contents($tmpFile, serialize($metadata)) && @rename($tmpFile, $file)) {
|
||||
@chmod($file, 0666 & ~umask());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
362
core/vendor/symfony/config/Symfony/Component/Config/Definition/ArrayNode.php
vendored
Normal file
362
core/vendor/symfony/config/Symfony/Component/Config/Definition/ArrayNode.php
vendored
Normal file
@@ -0,0 +1,362 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Config\Definition;
|
||||
|
||||
use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException;
|
||||
use Symfony\Component\Config\Definition\Exception\InvalidTypeException;
|
||||
use Symfony\Component\Config\Definition\Exception\UnsetKeyException;
|
||||
|
||||
/**
|
||||
* Represents an Array node in the config tree.
|
||||
*
|
||||
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
||||
*/
|
||||
class ArrayNode extends BaseNode implements PrototypeNodeInterface
|
||||
{
|
||||
protected $xmlRemappings;
|
||||
protected $children;
|
||||
protected $allowFalse;
|
||||
protected $allowNewKeys;
|
||||
protected $addIfNotSet;
|
||||
protected $performDeepMerging;
|
||||
protected $ignoreExtraKeys;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param string $name The Node's name
|
||||
* @param NodeInterface $parent The node parent
|
||||
*/
|
||||
public function __construct($name, NodeInterface $parent = null)
|
||||
{
|
||||
parent::__construct($name, $parent);
|
||||
|
||||
$this->children = array();
|
||||
$this->xmlRemappings = array();
|
||||
$this->removeKeyAttribute = true;
|
||||
$this->allowFalse = false;
|
||||
$this->addIfNotSet = false;
|
||||
$this->allowNewKeys = true;
|
||||
$this->performDeepMerging = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the children of this node.
|
||||
*
|
||||
* @return array The children
|
||||
*/
|
||||
public function getChildren()
|
||||
{
|
||||
return $this->children;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the xml remappings that should be performed.
|
||||
*
|
||||
* @param array $remappings an array of the form array(array(string, string))
|
||||
*/
|
||||
public function setXmlRemappings(array $remappings)
|
||||
{
|
||||
$this->xmlRemappings = $remappings;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets whether to add default values for this array if it has not been
|
||||
* defined in any of the configuration files.
|
||||
*
|
||||
* @param Boolean $boolean
|
||||
*/
|
||||
public function setAddIfNotSet($boolean)
|
||||
{
|
||||
$this->addIfNotSet = (Boolean) $boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets whether false is allowed as value indicating that the array should be unset.
|
||||
*
|
||||
* @param Boolean $allow
|
||||
*/
|
||||
public function setAllowFalse($allow)
|
||||
{
|
||||
$this->allowFalse = (Boolean) $allow;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets whether new keys can be defined in subsequent configurations.
|
||||
*
|
||||
* @param Boolean $allow
|
||||
*/
|
||||
public function setAllowNewKeys($allow)
|
||||
{
|
||||
$this->allowNewKeys = (Boolean) $allow;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets if deep merging should occur.
|
||||
*
|
||||
* @param Boolean $boolean
|
||||
*/
|
||||
public function setPerformDeepMerging($boolean)
|
||||
{
|
||||
$this->performDeepMerging = (Boolean) $boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether extra keys should just be ignore without an exception.
|
||||
*
|
||||
* @param Boolean $boolean To allow extra keys
|
||||
*/
|
||||
public function setIgnoreExtraKeys($boolean)
|
||||
{
|
||||
$this->ignoreExtraKeys = (Boolean) $boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the node Name.
|
||||
*
|
||||
* @param string $name The node's name
|
||||
*/
|
||||
public function setName($name)
|
||||
{
|
||||
$this->name = $name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the node has a default value.
|
||||
*
|
||||
* @return Boolean
|
||||
*/
|
||||
public function hasDefaultValue()
|
||||
{
|
||||
return $this->addIfNotSet;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the default value.
|
||||
*
|
||||
* @return array The default value
|
||||
*
|
||||
* @throws \RuntimeException if the node has no default value
|
||||
*/
|
||||
public function getDefaultValue()
|
||||
{
|
||||
if (!$this->hasDefaultValue()) {
|
||||
throw new \RuntimeException(sprintf('The node at path "%s" has no default value.', $this->getPath()));
|
||||
}
|
||||
|
||||
$defaults = array();
|
||||
foreach ($this->children as $name => $child) {
|
||||
if ($child->hasDefaultValue()) {
|
||||
$defaults[$name] = $child->getDefaultValue();
|
||||
}
|
||||
}
|
||||
|
||||
return $defaults;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a child node.
|
||||
*
|
||||
* @param NodeInterface $node The child node to add
|
||||
*
|
||||
* @throws \InvalidArgumentException when the child node has no name
|
||||
* @throws \InvalidArgumentException when the child node's name is not unique
|
||||
*/
|
||||
public function addChild(NodeInterface $node)
|
||||
{
|
||||
$name = $node->getName();
|
||||
if (empty($name)) {
|
||||
throw new \InvalidArgumentException('Child nodes must be named.');
|
||||
}
|
||||
if (isset($this->children[$name])) {
|
||||
throw new \InvalidArgumentException(sprintf('A child node named "%s" already exists.', $name));
|
||||
}
|
||||
|
||||
$this->children[$name] = $node;
|
||||
}
|
||||
|
||||
/**
|
||||
* Finalizes the value of this node.
|
||||
*
|
||||
* @param mixed $value
|
||||
*
|
||||
* @return mixed The finalised value
|
||||
*
|
||||
* @throws UnsetKeyException
|
||||
* @throws InvalidConfigurationException if the node doesn't have enough children
|
||||
*/
|
||||
protected function finalizeValue($value)
|
||||
{
|
||||
if (false === $value) {
|
||||
$msg = sprintf('Unsetting key for path "%s", value: %s', $this->getPath(), json_encode($value));
|
||||
throw new UnsetKeyException($msg);
|
||||
}
|
||||
|
||||
foreach ($this->children as $name => $child) {
|
||||
if (!array_key_exists($name, $value)) {
|
||||
if ($child->isRequired()) {
|
||||
$msg = sprintf('The child node "%s" at path "%s" must be configured.', $name, $this->getPath());
|
||||
$ex = new InvalidConfigurationException($msg);
|
||||
$ex->setPath($this->getPath());
|
||||
|
||||
throw $ex;
|
||||
}
|
||||
|
||||
if ($child->hasDefaultValue()) {
|
||||
$value[$name] = $child->getDefaultValue();
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
try {
|
||||
$value[$name] = $child->finalize($value[$name]);
|
||||
} catch (UnsetKeyException $unset) {
|
||||
unset($value[$name]);
|
||||
}
|
||||
}
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates the type of the value.
|
||||
*
|
||||
* @param mixed $value
|
||||
*
|
||||
* @throws InvalidTypeException
|
||||
*/
|
||||
protected function validateType($value)
|
||||
{
|
||||
if (!is_array($value) && (!$this->allowFalse || false !== $value)) {
|
||||
$ex = new InvalidTypeException(sprintf(
|
||||
'Invalid type for path "%s". Expected array, but got %s',
|
||||
$this->getPath(),
|
||||
gettype($value)
|
||||
));
|
||||
$ex->setPath($this->getPath());
|
||||
|
||||
throw $ex;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Normalizes the value.
|
||||
*
|
||||
* @param mixed $value The value to normalize
|
||||
*
|
||||
* @return mixed The normalized value
|
||||
*/
|
||||
protected function normalizeValue($value)
|
||||
{
|
||||
if (false === $value) {
|
||||
return $value;
|
||||
}
|
||||
|
||||
$value = $this->remapXml($value);
|
||||
|
||||
$normalized = array();
|
||||
foreach ($this->children as $name => $child) {
|
||||
if (array_key_exists($name, $value)) {
|
||||
$normalized[$name] = $child->normalize($value[$name]);
|
||||
unset($value[$name]);
|
||||
}
|
||||
}
|
||||
|
||||
// if extra fields are present, throw exception
|
||||
if (count($value) && !$this->ignoreExtraKeys) {
|
||||
$msg = sprintf('Unrecognized options "%s" under "%s"', implode(', ', array_keys($value)), $this->getPath());
|
||||
$ex = new InvalidConfigurationException($msg);
|
||||
$ex->setPath($this->getPath());
|
||||
|
||||
throw $ex;
|
||||
}
|
||||
|
||||
return $normalized;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remaps multiple singular values to a single plural value.
|
||||
*
|
||||
* @param array $value The source values
|
||||
*
|
||||
* @return array The remapped values
|
||||
*/
|
||||
protected function remapXml($value)
|
||||
{
|
||||
foreach ($this->xmlRemappings as $transformation) {
|
||||
list($singular, $plural) = $transformation;
|
||||
|
||||
if (!isset($value[$singular])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$value[$plural] = Processor::normalizeConfig($value, $singular, $plural);
|
||||
unset($value[$singular]);
|
||||
}
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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) {
|
||||
// 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;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
337
core/vendor/symfony/config/Symfony/Component/Config/Definition/BaseNode.php
vendored
Normal file
337
core/vendor/symfony/config/Symfony/Component/Config/Definition/BaseNode.php
vendored
Normal file
@@ -0,0 +1,337 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Config\Definition;
|
||||
|
||||
use Symfony\Component\Config\Definition\Exception\Exception;
|
||||
use Symfony\Component\Config\Definition\Exception\ForbiddenOverwriteException;
|
||||
use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException;
|
||||
|
||||
/**
|
||||
* The base node class
|
||||
*
|
||||
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
||||
*/
|
||||
abstract class BaseNode implements NodeInterface
|
||||
{
|
||||
protected $name;
|
||||
protected $parent;
|
||||
protected $normalizationClosures;
|
||||
protected $finalValidationClosures;
|
||||
protected $allowOverwrite;
|
||||
protected $required;
|
||||
protected $equivalentValues;
|
||||
protected $attributes = array();
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param string $name The name of the node
|
||||
* @param NodeInterface $parent The parent of this node
|
||||
*
|
||||
* @throws \InvalidArgumentException if the name contains a period.
|
||||
*/
|
||||
public function __construct($name, NodeInterface $parent = null)
|
||||
{
|
||||
if (false !== strpos($name, '.')) {
|
||||
throw new \InvalidArgumentException('The name must not contain ".".');
|
||||
}
|
||||
|
||||
$this->name = $name;
|
||||
$this->parent = $parent;
|
||||
$this->normalizationClosures = array();
|
||||
$this->finalValidationClosures = array();
|
||||
$this->allowOverwrite = true;
|
||||
$this->required = false;
|
||||
$this->equivalentValues = array();
|
||||
}
|
||||
|
||||
public function setAttribute($key, $value)
|
||||
{
|
||||
$this->attributes[$key] = $value;
|
||||
}
|
||||
|
||||
public function getAttribute($key, $default = null)
|
||||
{
|
||||
return isset($this->attributes[$key]) ? $this->attributes[$key] : $default;
|
||||
}
|
||||
|
||||
public function hasAttribute($key)
|
||||
{
|
||||
return isset($this->attributes[$key]);
|
||||
}
|
||||
|
||||
public function getAttributes()
|
||||
{
|
||||
return $this->attributes;
|
||||
}
|
||||
|
||||
public function setAttributes(array $attributes)
|
||||
{
|
||||
$this->attributes = $attributes;
|
||||
}
|
||||
|
||||
public function removeAttribute($key)
|
||||
{
|
||||
unset($this->attributes[$key]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets an info message.
|
||||
*
|
||||
* @param string $info
|
||||
*/
|
||||
public function setInfo($info)
|
||||
{
|
||||
$this->setAttribute('info', $info);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns info message.
|
||||
*
|
||||
* @return string The info text
|
||||
*/
|
||||
public function getInfo()
|
||||
{
|
||||
return $this->getAttribute('info');
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the example configuration for this node.
|
||||
*
|
||||
* @param string|array $example
|
||||
*/
|
||||
public function setExample($example)
|
||||
{
|
||||
$this->setAttribute('example', $example);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the example configuration for this node.
|
||||
*
|
||||
* @return string|array The example
|
||||
*/
|
||||
public function getExample()
|
||||
{
|
||||
return $this->getAttribute('example');
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds an equivalent value.
|
||||
*
|
||||
* @param mixed $originalValue
|
||||
* @param mixed $equivalentValue
|
||||
*/
|
||||
public function addEquivalentValue($originalValue, $equivalentValue)
|
||||
{
|
||||
$this->equivalentValues[] = array($originalValue, $equivalentValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set this node as required.
|
||||
*
|
||||
* @param Boolean $boolean Required node
|
||||
*/
|
||||
public function setRequired($boolean)
|
||||
{
|
||||
$this->required = (Boolean) $boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets if this node can be overridden.
|
||||
*
|
||||
* @param Boolean $allow
|
||||
*/
|
||||
public function setAllowOverwrite($allow)
|
||||
{
|
||||
$this->allowOverwrite = (Boolean) $allow;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the closures used for normalization.
|
||||
*
|
||||
* @param array $closures An array of Closures used for normalization
|
||||
*/
|
||||
public function setNormalizationClosures(array $closures)
|
||||
{
|
||||
$this->normalizationClosures = $closures;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the closures used for final validation.
|
||||
*
|
||||
* @param array $closures An array of Closures used for final validation
|
||||
*/
|
||||
public function setFinalValidationClosures(array $closures)
|
||||
{
|
||||
$this->finalValidationClosures = $closures;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if this node is required.
|
||||
*
|
||||
* @return Boolean
|
||||
*/
|
||||
public function isRequired()
|
||||
{
|
||||
return $this->required;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the name of this node
|
||||
*
|
||||
* @return string The Node's name.
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the path of this node.
|
||||
*
|
||||
* @return string The Node's path
|
||||
*/
|
||||
public function getPath()
|
||||
{
|
||||
$path = $this->name;
|
||||
|
||||
if (null !== $this->parent) {
|
||||
$path = $this->parent->getPath().'.'.$path;
|
||||
}
|
||||
|
||||
return $path;
|
||||
}
|
||||
|
||||
/**
|
||||
* Merges two values together.
|
||||
*
|
||||
* @param mixed $leftSide
|
||||
* @param mixed $rightSide
|
||||
*
|
||||
* @return mixed The merged value
|
||||
*
|
||||
* @throws ForbiddenOverwriteException
|
||||
*/
|
||||
final public function merge($leftSide, $rightSide)
|
||||
{
|
||||
if (!$this->allowOverwrite) {
|
||||
throw new ForbiddenOverwriteException(sprintf(
|
||||
'Configuration path "%s" cannot be overwritten. You have to '
|
||||
.'define all options for this path, and any of its sub-paths in '
|
||||
.'one configuration section.',
|
||||
$this->getPath()
|
||||
));
|
||||
}
|
||||
|
||||
$this->validateType($leftSide);
|
||||
$this->validateType($rightSide);
|
||||
|
||||
return $this->mergeValues($leftSide, $rightSide);
|
||||
}
|
||||
|
||||
/**
|
||||
* Normalizes a value, applying all normalization closures.
|
||||
*
|
||||
* @param mixed $value Value to normalize.
|
||||
*
|
||||
* @return mixed The normalized value.
|
||||
*/
|
||||
final public function normalize($value)
|
||||
{
|
||||
// run custom normalization closures
|
||||
foreach ($this->normalizationClosures as $closure) {
|
||||
$value = $closure($value);
|
||||
}
|
||||
|
||||
// replace value with their equivalent
|
||||
foreach ($this->equivalentValues as $data) {
|
||||
if ($data[0] === $value) {
|
||||
$value = $data[1];
|
||||
}
|
||||
}
|
||||
|
||||
// validate type
|
||||
$this->validateType($value);
|
||||
|
||||
// normalize value
|
||||
return $this->normalizeValue($value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Finalizes a value, applying all finalization closures.
|
||||
*
|
||||
* @param mixed $value The value to finalize
|
||||
*
|
||||
* @return mixed The finalized value
|
||||
*/
|
||||
final public function finalize($value)
|
||||
{
|
||||
$this->validateType($value);
|
||||
|
||||
$value = $this->finalizeValue($value);
|
||||
|
||||
// Perform validation on the final value if a closure has been set.
|
||||
// The closure is also allowed to return another value.
|
||||
foreach ($this->finalValidationClosures as $closure) {
|
||||
try {
|
||||
$value = $closure($value);
|
||||
} catch (Exception $correctEx) {
|
||||
throw $correctEx;
|
||||
} catch (\Exception $invalid) {
|
||||
throw new InvalidConfigurationException(sprintf(
|
||||
'Invalid configuration for path "%s": %s',
|
||||
$this->getPath(),
|
||||
$invalid->getMessage()
|
||||
), $invalid->getCode(), $invalid);
|
||||
}
|
||||
}
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates the type of a Node.
|
||||
*
|
||||
* @param mixed $value The value to validate
|
||||
*
|
||||
* @throws InvalidTypeException when the value is invalid
|
||||
*/
|
||||
abstract protected function validateType($value);
|
||||
|
||||
/**
|
||||
* Normalizes the value.
|
||||
*
|
||||
* @param mixed $value The value to normalize.
|
||||
*
|
||||
* @return mixed The normalized value
|
||||
*/
|
||||
abstract protected function normalizeValue($value);
|
||||
|
||||
/**
|
||||
* Merges two values together.
|
||||
*
|
||||
* @param mixed $leftSide
|
||||
* @param mixed $rightSide
|
||||
*
|
||||
* @return mixed The merged value
|
||||
*/
|
||||
abstract protected function mergeValues($leftSide, $rightSide);
|
||||
|
||||
/**
|
||||
* Finalizes a value.
|
||||
*
|
||||
* @param mixed $value The value to finalize
|
||||
*
|
||||
* @return mixed The finalized value
|
||||
*/
|
||||
abstract protected function finalizeValue($value);
|
||||
}
|
||||
39
core/vendor/symfony/config/Symfony/Component/Config/Definition/BooleanNode.php
vendored
Normal file
39
core/vendor/symfony/config/Symfony/Component/Config/Definition/BooleanNode.php
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Config\Definition;
|
||||
|
||||
use Symfony\Component\Config\Definition\Exception\InvalidTypeException;
|
||||
|
||||
/**
|
||||
* This node represents a Boolean value in the config tree.
|
||||
*
|
||||
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
||||
*/
|
||||
class BooleanNode extends ScalarNode
|
||||
{
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
protected function validateType($value)
|
||||
{
|
||||
if (!is_bool($value)) {
|
||||
$ex = new InvalidTypeException(sprintf(
|
||||
'Invalid type for path "%s". Expected boolean, but got %s.',
|
||||
$this->getPath(),
|
||||
gettype($value)
|
||||
));
|
||||
$ex->setPath($this->getPath());
|
||||
|
||||
throw $ex;
|
||||
}
|
||||
}
|
||||
}
|
||||
419
core/vendor/symfony/config/Symfony/Component/Config/Definition/Builder/ArrayNodeDefinition.php
vendored
Normal file
419
core/vendor/symfony/config/Symfony/Component/Config/Definition/Builder/ArrayNodeDefinition.php
vendored
Normal file
@@ -0,0 +1,419 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Config\Definition\Builder;
|
||||
|
||||
use Symfony\Component\Config\Definition\ArrayNode;
|
||||
use Symfony\Component\Config\Definition\PrototypedArrayNode;
|
||||
use Symfony\Component\Config\Definition\Exception\InvalidDefinitionException;
|
||||
|
||||
/**
|
||||
* This class provides a fluent interface for defining an array node.
|
||||
*
|
||||
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
||||
*/
|
||||
class ArrayNodeDefinition extends NodeDefinition implements ParentNodeDefinitionInterface
|
||||
{
|
||||
protected $performDeepMerging;
|
||||
protected $ignoreExtraKeys;
|
||||
protected $children;
|
||||
protected $prototype;
|
||||
protected $atLeastOne;
|
||||
protected $allowNewKeys;
|
||||
protected $key;
|
||||
protected $removeKeyItem;
|
||||
protected $addDefaults;
|
||||
protected $addDefaultChildren;
|
||||
protected $nodeBuilder;
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function __construct($name, NodeParentInterface $parent = null)
|
||||
{
|
||||
parent::__construct($name, $parent);
|
||||
|
||||
$this->children = array();
|
||||
$this->addDefaults = false;
|
||||
$this->addDefaultChildren = false;
|
||||
$this->allowNewKeys = true;
|
||||
$this->atLeastOne = false;
|
||||
$this->allowEmptyValue = true;
|
||||
$this->performDeepMerging = true;
|
||||
$this->nullEquivalent = array();
|
||||
$this->trueEquivalent = array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a custom children builder.
|
||||
*
|
||||
* @param NodeBuilder $builder A custom NodeBuilder
|
||||
*/
|
||||
public function setBuilder(NodeBuilder $builder)
|
||||
{
|
||||
$this->nodeBuilder = $builder;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a builder to add children nodes.
|
||||
*
|
||||
* @return NodeBuilder
|
||||
*/
|
||||
public function children()
|
||||
{
|
||||
return $this->getNodeBuilder();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a prototype for child nodes.
|
||||
*
|
||||
* @param string $type the type of node
|
||||
*
|
||||
* @return NodeDefinition
|
||||
*/
|
||||
public function prototype($type)
|
||||
{
|
||||
return $this->prototype = $this->getNodeBuilder()->node(null, $type)->setParent($this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the default value if the node is not set in the configuration.
|
||||
*
|
||||
* This method is applicable to concrete nodes only (not to prototype nodes).
|
||||
* If this function has been called and the node is not set during the finalization
|
||||
* phase, it's default value will be derived from its children default values.
|
||||
*
|
||||
* @return ArrayNodeDefinition
|
||||
*/
|
||||
public function addDefaultsIfNotSet()
|
||||
{
|
||||
$this->addDefaults = true;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds children with a default value when none are defined.
|
||||
*
|
||||
* @param integer|string|array|null $children The number of children|The child name|The children names to be added
|
||||
*
|
||||
* This method is applicable to prototype nodes only.
|
||||
*
|
||||
* @return ArrayNodeDefinition
|
||||
*/
|
||||
public function addDefaultChildrenIfNoneSet($children = null)
|
||||
{
|
||||
$this->addDefaultChildren = $children;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Requires the node to have at least one element.
|
||||
*
|
||||
* This method is applicable to prototype nodes only.
|
||||
*
|
||||
* @return ArrayNodeDefinition
|
||||
*/
|
||||
public function requiresAtLeastOneElement()
|
||||
{
|
||||
$this->atLeastOne = true;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Disallows adding news keys in a subsequent configuration.
|
||||
*
|
||||
* If used all keys have to be defined in the same configuration file.
|
||||
*
|
||||
* @return ArrayNodeDefinition
|
||||
*/
|
||||
public function disallowNewKeysInSubsequentConfigs()
|
||||
{
|
||||
$this->allowNewKeys = false;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a normalization rule for XML configurations.
|
||||
*
|
||||
* @param string $singular The key to remap
|
||||
* @param string $plural The plural of the key for irregular plurals
|
||||
*
|
||||
* @return ArrayNodeDefinition
|
||||
*/
|
||||
public function fixXmlConfig($singular, $plural = null)
|
||||
{
|
||||
$this->normalization()->remap($singular, $plural);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the attribute which value is to be used as key.
|
||||
*
|
||||
* This is useful when you have an indexed array that should be an
|
||||
* associative array. You can select an item from within the array
|
||||
* to be the key of the particular item. For example, if "id" is the
|
||||
* "key", then:
|
||||
*
|
||||
* array(
|
||||
* array('id' => 'my_name', 'foo' => 'bar'),
|
||||
* );
|
||||
*
|
||||
* becomes
|
||||
*
|
||||
* array(
|
||||
* 'my_name' => array('foo' => 'bar'),
|
||||
* );
|
||||
*
|
||||
* If you'd like "'id' => 'my_name'" to still be present in the resulting
|
||||
* array, then you can set the second argument of this method to false.
|
||||
*
|
||||
* This method is applicable to prototype nodes only.
|
||||
*
|
||||
* @param string $name The name of the key
|
||||
* @param Boolean $removeKeyItem Whether or not the key item should be removed.
|
||||
*
|
||||
* @return ArrayNodeDefinition
|
||||
*/
|
||||
public function useAttributeAsKey($name, $removeKeyItem = true)
|
||||
{
|
||||
$this->key = $name;
|
||||
$this->removeKeyItem = $removeKeyItem;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets whether the node can be unset.
|
||||
*
|
||||
* @param Boolean $allow
|
||||
*
|
||||
* @return ArrayNodeDefinition
|
||||
*/
|
||||
public function canBeUnset($allow = true)
|
||||
{
|
||||
$this->merge()->allowUnset($allow);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Disables the deep merging of the node.
|
||||
*
|
||||
* @return ArrayNodeDefinition
|
||||
*/
|
||||
public function performNoDeepMerging()
|
||||
{
|
||||
$this->performDeepMerging = false;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Allows extra config keys to be specified under an array without
|
||||
* throwing an exception.
|
||||
*
|
||||
* Those config values are simply ignored. This should be used only
|
||||
* in special cases where you want to send an entire configuration
|
||||
* array through a special tree that processes only part of the array.
|
||||
*
|
||||
* @return ArrayNodeDefinition
|
||||
*/
|
||||
public function ignoreExtraKeys()
|
||||
{
|
||||
$this->ignoreExtraKeys = true;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends a node definition.
|
||||
*
|
||||
* $node = new ArrayNodeDefinition()
|
||||
* ->children()
|
||||
* ->scalarNode('foo')->end()
|
||||
* ->scalarNode('baz')->end()
|
||||
* ->end()
|
||||
* ->append($this->getBarNodeDefinition())
|
||||
* ;
|
||||
*
|
||||
* @param NodeDefinition $node A NodeDefinition instance
|
||||
*
|
||||
* @return ArrayNodeDefinition This node
|
||||
*/
|
||||
public function append(NodeDefinition $node)
|
||||
{
|
||||
$this->children[$node->name] = $node->setParent($this);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a node builder to be used to add children and prototype
|
||||
*
|
||||
* @return NodeBuilder The node builder
|
||||
*/
|
||||
protected function getNodeBuilder()
|
||||
{
|
||||
if (null === $this->nodeBuilder) {
|
||||
$this->nodeBuilder = new NodeBuilder();
|
||||
}
|
||||
|
||||
return $this->nodeBuilder->setParent($this);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
protected function createNode()
|
||||
{
|
||||
if (null === $this->prototype) {
|
||||
$node = new ArrayNode($this->name, $this->parent);
|
||||
|
||||
$this->validateConcreteNode($node);
|
||||
|
||||
$node->setAddIfNotSet($this->addDefaults);
|
||||
|
||||
foreach ($this->children as $child) {
|
||||
$child->parent = $node;
|
||||
$node->addChild($child->getNode());
|
||||
}
|
||||
} else {
|
||||
$node = new PrototypedArrayNode($this->name, $this->parent);
|
||||
|
||||
$this->validatePrototypeNode($node);
|
||||
|
||||
if (null !== $this->key) {
|
||||
$node->setKeyAttribute($this->key, $this->removeKeyItem);
|
||||
}
|
||||
|
||||
if (true === $this->atLeastOne) {
|
||||
$node->setMinNumberOfElements(1);
|
||||
}
|
||||
|
||||
if ($this->default) {
|
||||
$node->setDefaultValue($this->defaultValue);
|
||||
}
|
||||
|
||||
if (false !== $this->addDefaultChildren) {
|
||||
$node->setAddChildrenIfNoneSet($this->addDefaultChildren);
|
||||
if ($this->prototype instanceof static && null === $this->prototype->prototype) {
|
||||
$this->prototype->addDefaultsIfNotSet();
|
||||
}
|
||||
}
|
||||
|
||||
$this->prototype->parent = $node;
|
||||
$node->setPrototype($this->prototype->getNode());
|
||||
}
|
||||
|
||||
$node->setAllowNewKeys($this->allowNewKeys);
|
||||
$node->addEquivalentValue(null, $this->nullEquivalent);
|
||||
$node->addEquivalentValue(true, $this->trueEquivalent);
|
||||
$node->addEquivalentValue(false, $this->falseEquivalent);
|
||||
$node->setPerformDeepMerging($this->performDeepMerging);
|
||||
$node->setRequired($this->required);
|
||||
$node->setIgnoreExtraKeys($this->ignoreExtraKeys);
|
||||
|
||||
if (null !== $this->normalization) {
|
||||
$node->setNormalizationClosures($this->normalization->before);
|
||||
$node->setXmlRemappings($this->normalization->remappings);
|
||||
}
|
||||
|
||||
if (null !== $this->merge) {
|
||||
$node->setAllowOverwrite($this->merge->allowOverwrite);
|
||||
$node->setAllowFalse($this->merge->allowFalse);
|
||||
}
|
||||
|
||||
if (null !== $this->validation) {
|
||||
$node->setFinalValidationClosures($this->validation->rules);
|
||||
}
|
||||
|
||||
return $node;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate the configuration of a concrete node.
|
||||
*
|
||||
* @param NodeInterface $node The related node
|
||||
*
|
||||
* @throws InvalidDefinitionException When an error is detected in the configuration
|
||||
*/
|
||||
protected function validateConcreteNode(ArrayNode $node)
|
||||
{
|
||||
$path = $node->getPath();
|
||||
|
||||
if (null !== $this->key) {
|
||||
throw new InvalidDefinitionException(
|
||||
sprintf('->useAttributeAsKey() is not applicable to concrete nodes at path "%s"', $path)
|
||||
);
|
||||
}
|
||||
|
||||
if (true === $this->atLeastOne) {
|
||||
throw new InvalidDefinitionException(
|
||||
sprintf('->requiresAtLeastOneElement() is not applicable to concrete nodes at path "%s"', $path)
|
||||
);
|
||||
}
|
||||
|
||||
if ($this->default) {
|
||||
throw new InvalidDefinitionException(
|
||||
sprintf('->defaultValue() is not applicable to concrete nodes at path "%s"', $path)
|
||||
);
|
||||
}
|
||||
|
||||
if (false !== $this->addDefaultChildren) {
|
||||
throw new InvalidDefinitionException(
|
||||
sprintf('->addDefaultChildrenIfNoneSet() is not applicable to concrete nodes at path "%s"', $path)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate the configuration of a prototype node.
|
||||
*
|
||||
* @param NodeInterface $node The related node
|
||||
*
|
||||
* @throws InvalidDefinitionException When an error is detected in the configuration
|
||||
*/
|
||||
protected function validatePrototypeNode(PrototypedArrayNode $node)
|
||||
{
|
||||
$path = $node->getPath();
|
||||
|
||||
if ($this->addDefaults) {
|
||||
throw new InvalidDefinitionException(
|
||||
sprintf('->addDefaultsIfNotSet() is not applicable to prototype nodes at path "%s"', $path)
|
||||
);
|
||||
}
|
||||
|
||||
if (false !== $this->addDefaultChildren) {
|
||||
if ($this->default) {
|
||||
throw new InvalidDefinitionException(
|
||||
sprintf('A default value and default children might not be used together at path "%s"', $path)
|
||||
);
|
||||
}
|
||||
|
||||
if (null !== $this->key && (null === $this->addDefaultChildren || is_integer($this->addDefaultChildren) && $this->addDefaultChildren > 0)) {
|
||||
throw new InvalidDefinitionException(
|
||||
sprintf('->addDefaultChildrenIfNoneSet() should set default children names as ->useAttributeAsKey() is used at path "%s"', $path)
|
||||
);
|
||||
}
|
||||
|
||||
if (null === $this->key && (is_string($this->addDefaultChildren) || is_array($this->addDefaultChildren))) {
|
||||
throw new InvalidDefinitionException(
|
||||
sprintf('->addDefaultChildrenIfNoneSet() might not set default children names as ->useAttributeAsKey() is not used at path "%s"', $path)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
43
core/vendor/symfony/config/Symfony/Component/Config/Definition/Builder/BooleanNodeDefinition.php
vendored
Normal file
43
core/vendor/symfony/config/Symfony/Component/Config/Definition/Builder/BooleanNodeDefinition.php
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Config\Definition\Builder;
|
||||
|
||||
use Symfony\Component\Config\Definition\BooleanNode;
|
||||
|
||||
/**
|
||||
* This class provides a fluent interface for defining a node.
|
||||
*
|
||||
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
||||
*/
|
||||
class BooleanNodeDefinition extends ScalarNodeDefinition
|
||||
{
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function __construct($name, NodeParentInterface $parent = null)
|
||||
{
|
||||
parent::__construct($name, $parent);
|
||||
|
||||
$this->nullEquivalent = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiate a Node
|
||||
*
|
||||
* @return BooleanNode The node
|
||||
*/
|
||||
protected function instantiateNode()
|
||||
{
|
||||
return new BooleanNode($this->name, $this->parent);
|
||||
}
|
||||
|
||||
}
|
||||
43
core/vendor/symfony/config/Symfony/Component/Config/Definition/Builder/EnumNodeDefinition.php
vendored
Normal file
43
core/vendor/symfony/config/Symfony/Component/Config/Definition/Builder/EnumNodeDefinition.php
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace Symfony\Component\Config\Definition\Builder;
|
||||
|
||||
use Symfony\Component\Config\Definition\EnumNode;
|
||||
use Symfony\Component\Config\Definition\Builder\ScalarNodeDefinition;
|
||||
|
||||
/**
|
||||
* Enum Node Definition.
|
||||
*
|
||||
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
||||
*/
|
||||
class EnumNodeDefinition extends ScalarNodeDefinition
|
||||
{
|
||||
private $values;
|
||||
|
||||
public function values(array $values)
|
||||
{
|
||||
$values = array_unique($values);
|
||||
|
||||
if (count($values) <= 1) {
|
||||
throw new \InvalidArgumentException('->values() must be called with at least two distinct values.');
|
||||
}
|
||||
|
||||
$this->values = $values;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiate a Node
|
||||
*
|
||||
* @return EnumNode The node
|
||||
*/
|
||||
protected function instantiateNode()
|
||||
{
|
||||
if (null === $this->values) {
|
||||
throw new \RuntimeException('You must call ->values() on enum nodes.');
|
||||
}
|
||||
|
||||
return new EnumNode($this->name, $this->parent, $this->values);
|
||||
}
|
||||
}
|
||||
229
core/vendor/symfony/config/Symfony/Component/Config/Definition/Builder/ExprBuilder.php
vendored
Normal file
229
core/vendor/symfony/config/Symfony/Component/Config/Definition/Builder/ExprBuilder.php
vendored
Normal file
@@ -0,0 +1,229 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Config\Definition\Builder;
|
||||
use Symfony\Component\Config\Definition\Exception\UnsetKeyException;
|
||||
|
||||
/**
|
||||
* This class builds an if expression.
|
||||
*
|
||||
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
||||
* @author Christophe Coevoet <stof@notk.org>
|
||||
*/
|
||||
class ExprBuilder
|
||||
{
|
||||
protected $node;
|
||||
public $ifPart;
|
||||
public $thenPart;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param NodeDefinition $node The related node
|
||||
*/
|
||||
public function __construct(NodeDefinition $node)
|
||||
{
|
||||
$this->node = $node;
|
||||
}
|
||||
|
||||
/**
|
||||
* Marks the expression as being always used.
|
||||
*
|
||||
* @param \Closure $then
|
||||
*
|
||||
* @return ExprBuilder
|
||||
*/
|
||||
public function always(\Closure $then = null)
|
||||
{
|
||||
$this->ifPart = function($v) { return true; };
|
||||
|
||||
if (null !== $then) {
|
||||
$this->thenPart = $then;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a closure to use as tests.
|
||||
*
|
||||
* The default one tests if the value is true.
|
||||
*
|
||||
* @param \Closure $closure
|
||||
*
|
||||
* @return ExprBuilder
|
||||
*/
|
||||
public function ifTrue(\Closure $closure = null)
|
||||
{
|
||||
if (null === $closure) {
|
||||
$closure = function($v) { return true === $v; };
|
||||
}
|
||||
|
||||
$this->ifPart = $closure;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests if the value is a string.
|
||||
*
|
||||
* @return ExprBuilder
|
||||
*/
|
||||
public function ifString()
|
||||
{
|
||||
$this->ifPart = function($v) { return is_string($v); };
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests if the value is null.
|
||||
*
|
||||
* @return ExprBuilder
|
||||
*/
|
||||
public function ifNull()
|
||||
{
|
||||
$this->ifPart = function($v) { return null === $v; };
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests if the value is an array.
|
||||
*
|
||||
* @return ExprBuilder
|
||||
*/
|
||||
public function ifArray()
|
||||
{
|
||||
$this->ifPart = function($v) { return is_array($v); };
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests if the value is in an array.
|
||||
*
|
||||
* @param array $array
|
||||
*
|
||||
* @return ExprBuilder
|
||||
*/
|
||||
public function ifInArray(array $array)
|
||||
{
|
||||
$this->ifPart = function($v) use ($array) { return in_array($v, $array, true); };
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests if the value is not in an array.
|
||||
*
|
||||
* @param array $array
|
||||
*
|
||||
* @return ExprBuilder
|
||||
*/
|
||||
public function ifNotInArray(array $array)
|
||||
{
|
||||
$this->ifPart = function($v) use ($array) { return !in_array($v, $array, true); };
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the closure to run if the test pass.
|
||||
*
|
||||
* @param \Closure $closure
|
||||
*
|
||||
* @return ExprBuilder
|
||||
*/
|
||||
public function then(\Closure $closure)
|
||||
{
|
||||
$this->thenPart = $closure;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a closure returning an empty array.
|
||||
*
|
||||
* @return ExprBuilder
|
||||
*/
|
||||
public function thenEmptyArray()
|
||||
{
|
||||
$this->thenPart = function($v) { return array(); };
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a closure marking the value as invalid at validation time.
|
||||
*
|
||||
* if you want to add the value of the node in your message just use a %s placeholder.
|
||||
*
|
||||
* @param string $message
|
||||
*
|
||||
* @return ExprBuilder
|
||||
*/
|
||||
public function thenInvalid($message)
|
||||
{
|
||||
$this->thenPart = function ($v) use ($message) {throw new \InvalidArgumentException(sprintf($message, json_encode($v))); };
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a closure unsetting this key of the array at validation time.
|
||||
*
|
||||
* @return ExprBuilder
|
||||
*/
|
||||
public function thenUnset()
|
||||
{
|
||||
$this->thenPart = function ($v) { throw new UnsetKeyException('Unsetting key'); };
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the related node
|
||||
*
|
||||
* @return NodeDefinition
|
||||
*/
|
||||
public function end()
|
||||
{
|
||||
if (null === $this->ifPart) {
|
||||
throw new \RuntimeException('You must specify an if part.');
|
||||
}
|
||||
if (null === $this->thenPart) {
|
||||
throw new \RuntimeException('You must specify a then part.');
|
||||
}
|
||||
|
||||
return $this->node;
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds the expressions.
|
||||
*
|
||||
* @param array $expressions An array of ExprBuilder instances to build
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function buildExpressions(array $expressions)
|
||||
{
|
||||
foreach ($expressions as $k => $expr) {
|
||||
if ($expr instanceof ExprBuilder) {
|
||||
$expressions[$k] = function($v) use ($expr) {
|
||||
return call_user_func($expr->ifPart, $v) ? call_user_func($expr->thenPart, $v) : $v;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
return $expressions;
|
||||
}
|
||||
}
|
||||
74
core/vendor/symfony/config/Symfony/Component/Config/Definition/Builder/MergeBuilder.php
vendored
Normal file
74
core/vendor/symfony/config/Symfony/Component/Config/Definition/Builder/MergeBuilder.php
vendored
Normal file
@@ -0,0 +1,74 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Config\Definition\Builder;
|
||||
|
||||
/**
|
||||
* This class builds merge conditions.
|
||||
*
|
||||
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
||||
*/
|
||||
class MergeBuilder
|
||||
{
|
||||
protected $node;
|
||||
public $allowFalse;
|
||||
public $allowOverwrite;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param NodeDefinition $node The related node
|
||||
*/
|
||||
public function __construct(NodeDefinition $node)
|
||||
{
|
||||
$this->node = $node;
|
||||
$this->allowFalse = false;
|
||||
$this->allowOverwrite = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets whether the node can be unset.
|
||||
*
|
||||
* @param Boolean $allow
|
||||
*
|
||||
* @return MergeBuilder
|
||||
*/
|
||||
public function allowUnset($allow = true)
|
||||
{
|
||||
$this->allowFalse = $allow;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets whether the node can be overwritten.
|
||||
*
|
||||
* @param Boolean $deny Whether the overwriting is forbidden or not
|
||||
*
|
||||
* @return MergeBuilder
|
||||
*/
|
||||
public function denyOverwrite($deny = true)
|
||||
{
|
||||
$this->allowOverwrite = !$deny;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the related node.
|
||||
*
|
||||
* @return NodeDefinition
|
||||
*/
|
||||
public function end()
|
||||
{
|
||||
return $this->node;
|
||||
}
|
||||
}
|
||||
219
core/vendor/symfony/config/Symfony/Component/Config/Definition/Builder/NodeBuilder.php
vendored
Normal file
219
core/vendor/symfony/config/Symfony/Component/Config/Definition/Builder/NodeBuilder.php
vendored
Normal file
@@ -0,0 +1,219 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Config\Definition\Builder;
|
||||
|
||||
/**
|
||||
* This class provides a fluent interface for building a node.
|
||||
*
|
||||
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
||||
*/
|
||||
class NodeBuilder implements NodeParentInterface
|
||||
{
|
||||
protected $parent;
|
||||
protected $nodeMapping;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->nodeMapping = array(
|
||||
'variable' => __NAMESPACE__.'\\VariableNodeDefinition',
|
||||
'scalar' => __NAMESPACE__.'\\ScalarNodeDefinition',
|
||||
'boolean' => __NAMESPACE__.'\\BooleanNodeDefinition',
|
||||
'array' => __NAMESPACE__.'\\ArrayNodeDefinition',
|
||||
'enum' => __NAMESPACE__.'\\EnumNodeDefinition',
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the parent node.
|
||||
*
|
||||
* @param ParentNodeDefinitionInterface $parent The parent node
|
||||
*
|
||||
* @return NodeBuilder This node builder
|
||||
*/
|
||||
public function setParent(ParentNodeDefinitionInterface $parent = null)
|
||||
{
|
||||
$this->parent = $parent;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a child array node.
|
||||
*
|
||||
* @param string $name The name of the node
|
||||
*
|
||||
* @return ArrayNodeDefinition The child node
|
||||
*/
|
||||
public function arrayNode($name)
|
||||
{
|
||||
return $this->node($name, 'array');
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a child scalar node.
|
||||
*
|
||||
* @param string $name the name of the node
|
||||
*
|
||||
* @return ScalarNodeDefinition The child node
|
||||
*/
|
||||
public function scalarNode($name)
|
||||
{
|
||||
return $this->node($name, 'scalar');
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a child Boolean node.
|
||||
*
|
||||
* @param string $name The name of the node
|
||||
*
|
||||
* @return BooleanNodeDefinition The child node
|
||||
*/
|
||||
public function booleanNode($name)
|
||||
{
|
||||
return $this->node($name, 'boolean');
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a child EnumNode.
|
||||
*
|
||||
* @param string $name
|
||||
*
|
||||
* @return EnumNodeDefinition
|
||||
*/
|
||||
public function enumNode($name)
|
||||
{
|
||||
return $this->node($name, 'enum');
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a child variable node.
|
||||
*
|
||||
* @param string $name The name of the node
|
||||
*
|
||||
* @return VariableNodeDefinition The builder of the child node
|
||||
*/
|
||||
public function variableNode($name)
|
||||
{
|
||||
return $this->node($name, 'variable');
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the parent node.
|
||||
*
|
||||
* @return ParentNodeDefinitionInterface The parent node
|
||||
*/
|
||||
public function end()
|
||||
{
|
||||
return $this->parent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a child node.
|
||||
*
|
||||
* @param string $name The name of the node
|
||||
* @param string $type The type of the node
|
||||
*
|
||||
* @return NodeDefinition The child node
|
||||
*
|
||||
* @throws \RuntimeException When the node type is not registered
|
||||
* @throws \RuntimeException When the node class is not found
|
||||
*/
|
||||
public function node($name, $type)
|
||||
{
|
||||
$class = $this->getNodeClass($type);
|
||||
|
||||
$node = new $class($name);
|
||||
|
||||
$this->append($node);
|
||||
|
||||
return $node;
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends a node definition.
|
||||
*
|
||||
* Usage:
|
||||
*
|
||||
* $node = new ArrayNodeDefinition('name')
|
||||
* ->children()
|
||||
* ->scalarNode('foo')->end()
|
||||
* ->scalarNode('baz')->end()
|
||||
* ->append($this->getBarNodeDefinition())
|
||||
* ->end()
|
||||
* ;
|
||||
*
|
||||
* @return NodeBuilder This node builder
|
||||
*/
|
||||
public function append(NodeDefinition $node)
|
||||
{
|
||||
if ($node instanceof ParentNodeDefinitionInterface) {
|
||||
$builder = clone $this;
|
||||
$builder->setParent(null);
|
||||
$node->setBuilder($builder);
|
||||
}
|
||||
|
||||
if (null !== $this->parent) {
|
||||
$this->parent->append($node);
|
||||
// Make this builder the node parent to allow for a fluid interface
|
||||
$node->setParent($this);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds or overrides a node Type.
|
||||
*
|
||||
* @param string $type The name of the type
|
||||
* @param string $class The fully qualified name the node definition class
|
||||
*
|
||||
* @return NodeBuilder This node builder
|
||||
*/
|
||||
public function setNodeClass($type, $class)
|
||||
{
|
||||
$this->nodeMapping[strtolower($type)] = $class;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the class name of the node definition.
|
||||
*
|
||||
* @param string $type The node type
|
||||
*
|
||||
* @return string The node definition class name
|
||||
*
|
||||
* @throws \RuntimeException When the node type is not registered
|
||||
* @throws \RuntimeException When the node class is not found
|
||||
*/
|
||||
protected function getNodeClass($type)
|
||||
{
|
||||
$type = strtolower($type);
|
||||
|
||||
if (!isset($this->nodeMapping[$type])) {
|
||||
throw new \RuntimeException(sprintf('The node type "%s" is not registered.', $type));
|
||||
}
|
||||
|
||||
$class = $this->nodeMapping[$type];
|
||||
|
||||
if (!class_exists($class)) {
|
||||
throw new \RuntimeException(sprintf('The node class "%s" does not exist.', $class));
|
||||
}
|
||||
|
||||
return $class;
|
||||
}
|
||||
|
||||
}
|
||||
343
core/vendor/symfony/config/Symfony/Component/Config/Definition/Builder/NodeDefinition.php
vendored
Normal file
343
core/vendor/symfony/config/Symfony/Component/Config/Definition/Builder/NodeDefinition.php
vendored
Normal file
@@ -0,0 +1,343 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Config\Definition\Builder;
|
||||
|
||||
use Symfony\Component\Config\Definition\NodeInterface;
|
||||
|
||||
/**
|
||||
* This class provides a fluent interface for defining a node.
|
||||
*
|
||||
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
||||
*/
|
||||
abstract class NodeDefinition implements NodeParentInterface
|
||||
{
|
||||
protected $name;
|
||||
protected $normalization;
|
||||
protected $validation;
|
||||
protected $defaultValue;
|
||||
protected $default;
|
||||
protected $required;
|
||||
protected $merge;
|
||||
protected $allowEmptyValue;
|
||||
protected $nullEquivalent;
|
||||
protected $trueEquivalent;
|
||||
protected $falseEquivalent;
|
||||
protected $parent;
|
||||
protected $attributes = array();
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param string $name The name of the node
|
||||
* @param NodeParentInterface $parent The parent
|
||||
*/
|
||||
public function __construct($name, NodeParentInterface $parent = null)
|
||||
{
|
||||
$this->parent = $parent;
|
||||
$this->name = $name;
|
||||
$this->default = false;
|
||||
$this->required = false;
|
||||
$this->trueEquivalent = true;
|
||||
$this->falseEquivalent = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the parent node.
|
||||
*
|
||||
* @param NodeParentInterface $parent The parent
|
||||
*
|
||||
* @return NodeDefinition
|
||||
*/
|
||||
public function setParent(NodeParentInterface $parent)
|
||||
{
|
||||
$this->parent = $parent;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets info message.
|
||||
*
|
||||
* @param string $info The info text
|
||||
*
|
||||
* @return NodeDefinition
|
||||
*/
|
||||
public function info($info)
|
||||
{
|
||||
return $this->attribute('info', $info);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets example configuration.
|
||||
*
|
||||
* @param string|array $example
|
||||
*
|
||||
* @return NodeDefinition
|
||||
*/
|
||||
public function example($example)
|
||||
{
|
||||
return $this->attribute('example', $example);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets an attribute on the node.
|
||||
*
|
||||
* @param string $key
|
||||
* @param mixed $value
|
||||
*
|
||||
* @return NodeDefinition
|
||||
*/
|
||||
public function attribute($key, $value)
|
||||
{
|
||||
$this->attributes[$key] = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the parent node.
|
||||
*
|
||||
* @return NodeParentInterface The builder of the parent node
|
||||
*/
|
||||
public function end()
|
||||
{
|
||||
return $this->parent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the node.
|
||||
*
|
||||
* @param Boolean $forceRootNode Whether to force this node as the root node
|
||||
*
|
||||
* @return NodeInterface
|
||||
*/
|
||||
public function getNode($forceRootNode = false)
|
||||
{
|
||||
if ($forceRootNode) {
|
||||
$this->parent = null;
|
||||
}
|
||||
|
||||
if (null !== $this->normalization) {
|
||||
$this->normalization->before = ExprBuilder::buildExpressions($this->normalization->before);
|
||||
}
|
||||
|
||||
if (null !== $this->validation) {
|
||||
$this->validation->rules = ExprBuilder::buildExpressions($this->validation->rules);
|
||||
}
|
||||
|
||||
$node = $this->createNode();
|
||||
$node->setAttributes($this->attributes);
|
||||
|
||||
return $node;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the default value.
|
||||
*
|
||||
* @param mixed $value The default value
|
||||
*
|
||||
* @return NodeDefinition
|
||||
*/
|
||||
public function defaultValue($value)
|
||||
{
|
||||
$this->default = true;
|
||||
$this->defaultValue = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the node as required.
|
||||
*
|
||||
* @return NodeDefinition
|
||||
*/
|
||||
public function isRequired()
|
||||
{
|
||||
$this->required = true;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the equivalent value used when the node contains null.
|
||||
*
|
||||
* @param mixed $value
|
||||
*
|
||||
* @return NodeDefinition
|
||||
*/
|
||||
public function treatNullLike($value)
|
||||
{
|
||||
$this->nullEquivalent = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the equivalent value used when the node contains true.
|
||||
*
|
||||
* @param mixed $value
|
||||
*
|
||||
* @return NodeDefinition
|
||||
*/
|
||||
public function treatTrueLike($value)
|
||||
{
|
||||
$this->trueEquivalent = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the equivalent value used when the node contains false.
|
||||
*
|
||||
* @param mixed $value
|
||||
*
|
||||
* @return NodeDefinition
|
||||
*/
|
||||
public function treatFalseLike($value)
|
||||
{
|
||||
$this->falseEquivalent = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets null as the default value.
|
||||
*
|
||||
* @return NodeDefinition
|
||||
*/
|
||||
public function defaultNull()
|
||||
{
|
||||
return $this->defaultValue(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets true as the default value.
|
||||
*
|
||||
* @return NodeDefinition
|
||||
*/
|
||||
public function defaultTrue()
|
||||
{
|
||||
return $this->defaultValue(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets false as the default value.
|
||||
*
|
||||
* @return NodeDefinition
|
||||
*/
|
||||
public function defaultFalse()
|
||||
{
|
||||
return $this->defaultValue(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets an expression to run before the normalization.
|
||||
*
|
||||
* @return ExprBuilder
|
||||
*/
|
||||
public function beforeNormalization()
|
||||
{
|
||||
return $this->normalization()->before();
|
||||
}
|
||||
|
||||
/**
|
||||
* Denies the node value being empty.
|
||||
*
|
||||
* @return NodeDefinition
|
||||
*/
|
||||
public function cannotBeEmpty()
|
||||
{
|
||||
$this->allowEmptyValue = false;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets an expression to run for the validation.
|
||||
*
|
||||
* The expression receives the value of the node and must return it. It can
|
||||
* modify it.
|
||||
* An exception should be thrown when the node is not valid.
|
||||
*
|
||||
* @return ExprBuilder
|
||||
*/
|
||||
public function validate()
|
||||
{
|
||||
return $this->validation()->rule();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets whether the node can be overwritten.
|
||||
*
|
||||
* @param Boolean $deny Whether the overwriting is forbidden or not
|
||||
*
|
||||
* @return NodeDefinition
|
||||
*/
|
||||
public function cannotBeOverwritten($deny = true)
|
||||
{
|
||||
$this->merge()->denyOverwrite($deny);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the builder for validation rules.
|
||||
*
|
||||
* @return ValidationBuilder
|
||||
*/
|
||||
protected function validation()
|
||||
{
|
||||
if (null === $this->validation) {
|
||||
$this->validation = new ValidationBuilder($this);
|
||||
}
|
||||
|
||||
return $this->validation;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the builder for merging rules.
|
||||
*
|
||||
* @return MergeBuilder
|
||||
*/
|
||||
protected function merge()
|
||||
{
|
||||
if (null === $this->merge) {
|
||||
$this->merge = new MergeBuilder($this);
|
||||
}
|
||||
|
||||
return $this->merge;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the builder for normalization rules.
|
||||
*
|
||||
* @return NormalizationBuilder
|
||||
*/
|
||||
protected function normalization()
|
||||
{
|
||||
if (null === $this->normalization) {
|
||||
$this->normalization = new NormalizationBuilder($this);
|
||||
}
|
||||
|
||||
return $this->normalization;
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiate and configure the node according to this definition
|
||||
*
|
||||
* @return NodeInterface $node The node instance
|
||||
*
|
||||
* @throws Symfony\Component\Config\Definition\Exception\InvalidDefinitionException When the definition is invalid
|
||||
*/
|
||||
abstract protected function createNode();
|
||||
|
||||
}
|
||||
21
core/vendor/symfony/config/Symfony/Component/Config/Definition/Builder/NodeParentInterface.php
vendored
Normal file
21
core/vendor/symfony/config/Symfony/Component/Config/Definition/Builder/NodeParentInterface.php
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Config\Definition\Builder;
|
||||
|
||||
/**
|
||||
* An interface that must be implemented by all node parents
|
||||
*
|
||||
* @author Victor Berchet <victor@suumit.com>
|
||||
*/
|
||||
interface NodeParentInterface
|
||||
{
|
||||
}
|
||||
70
core/vendor/symfony/config/Symfony/Component/Config/Definition/Builder/NormalizationBuilder.php
vendored
Normal file
70
core/vendor/symfony/config/Symfony/Component/Config/Definition/Builder/NormalizationBuilder.php
vendored
Normal file
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Config\Definition\Builder;
|
||||
|
||||
/**
|
||||
* This class builds normalization conditions.
|
||||
*
|
||||
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
||||
*/
|
||||
class NormalizationBuilder
|
||||
{
|
||||
protected $node;
|
||||
public $before;
|
||||
public $remappings;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param NodeDefinition $node The related node
|
||||
*/
|
||||
public function __construct(NodeDefinition $node)
|
||||
{
|
||||
$this->node = $node;
|
||||
$this->keys = false;
|
||||
$this->remappings = array();
|
||||
$this->before = array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a key to remap to its plural form.
|
||||
*
|
||||
* @param string $key The key to remap
|
||||
* @param string $plural The plural of the key in case of irregular plural
|
||||
*
|
||||
* @return NormalizationBuilder
|
||||
*/
|
||||
public function remap($key, $plural = null)
|
||||
{
|
||||
$this->remappings[] = array($key, null === $plural ? $key.'s' : $plural);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a closure to run before the normalization or an expression builder to build it if null is provided.
|
||||
*
|
||||
* @param \Closure $closure
|
||||
*
|
||||
* @return ExprBuilder|NormalizationBuilder
|
||||
*/
|
||||
public function before(\Closure $closure = null)
|
||||
{
|
||||
if (null !== $closure) {
|
||||
$this->before[] = $closure;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
return $this->before[] = new ExprBuilder($this->node);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Config\Definition\Builder;
|
||||
|
||||
/**
|
||||
* An interface that must be implemented by nodes which can have children
|
||||
*
|
||||
* @author Victor Berchet <victor@suumit.com>
|
||||
*/
|
||||
interface ParentNodeDefinitionInterface
|
||||
{
|
||||
public function children();
|
||||
|
||||
public function append(NodeDefinition $node);
|
||||
|
||||
public function setBuilder(NodeBuilder $builder);
|
||||
}
|
||||
32
core/vendor/symfony/config/Symfony/Component/Config/Definition/Builder/ScalarNodeDefinition.php
vendored
Normal file
32
core/vendor/symfony/config/Symfony/Component/Config/Definition/Builder/ScalarNodeDefinition.php
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Config\Definition\Builder;
|
||||
|
||||
use Symfony\Component\Config\Definition\ScalarNode;
|
||||
|
||||
/**
|
||||
* This class provides a fluent interface for defining a node.
|
||||
*
|
||||
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
||||
*/
|
||||
class ScalarNodeDefinition extends VariableNodeDefinition
|
||||
{
|
||||
/**
|
||||
* Instantiate a Node
|
||||
*
|
||||
* @return ScalarNode The node
|
||||
*/
|
||||
protected function instantiateNode()
|
||||
{
|
||||
return new ScalarNode($this->name, $this->parent);
|
||||
}
|
||||
}
|
||||
59
core/vendor/symfony/config/Symfony/Component/Config/Definition/Builder/TreeBuilder.php
vendored
Normal file
59
core/vendor/symfony/config/Symfony/Component/Config/Definition/Builder/TreeBuilder.php
vendored
Normal file
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Config\Definition\Builder;
|
||||
|
||||
/**
|
||||
* This is the entry class for building a config tree.
|
||||
*
|
||||
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
||||
*/
|
||||
class TreeBuilder implements NodeParentInterface
|
||||
{
|
||||
protected $tree;
|
||||
protected $root;
|
||||
protected $builder;
|
||||
|
||||
/**
|
||||
* Creates the root node.
|
||||
*
|
||||
* @param string $name The name of the root node
|
||||
* @param string $type The type of the root node
|
||||
* @param NodeBuilder $builder A custom node builder instance
|
||||
*
|
||||
* @return ArrayNodeDefinition|NodeDefinition The root node (as an ArrayNodeDefinition when the type is 'array')
|
||||
*
|
||||
* @throws \RuntimeException When the node type is not supported
|
||||
*/
|
||||
public function root($name, $type = 'array', NodeBuilder $builder = null)
|
||||
{
|
||||
$builder = $builder ?: new NodeBuilder();
|
||||
|
||||
return $this->root = $builder->node($name, $type)->setParent($this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds the tree.
|
||||
*
|
||||
* @return NodeInterface
|
||||
*/
|
||||
public function buildTree()
|
||||
{
|
||||
if (null === $this->root) {
|
||||
throw new \RuntimeException('The configuration tree has no root node.');
|
||||
}
|
||||
if (null !== $this->tree) {
|
||||
return $this->tree;
|
||||
}
|
||||
|
||||
return $this->tree = $this->root->getNode(true);
|
||||
}
|
||||
}
|
||||
53
core/vendor/symfony/config/Symfony/Component/Config/Definition/Builder/ValidationBuilder.php
vendored
Normal file
53
core/vendor/symfony/config/Symfony/Component/Config/Definition/Builder/ValidationBuilder.php
vendored
Normal file
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Config\Definition\Builder;
|
||||
|
||||
/**
|
||||
* This class builds validation conditions.
|
||||
*
|
||||
* @author Christophe Coevoet <stof@notk.org>
|
||||
*/
|
||||
class ValidationBuilder
|
||||
{
|
||||
protected $node;
|
||||
public $rules;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param NodeDefinition $node The related node
|
||||
*/
|
||||
public function __construct(NodeDefinition $node)
|
||||
{
|
||||
$this->node = $node;
|
||||
|
||||
$this->rules = array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a closure to run as normalization or an expression builder to build it if null is provided.
|
||||
*
|
||||
* @param \Closure $closure
|
||||
*
|
||||
* @return ExprBuilder|ValidationBuilder
|
||||
*/
|
||||
public function rule(\Closure $closure = null)
|
||||
{
|
||||
if (null !== $closure) {
|
||||
$this->rules[] = $closure;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
return $this->rules[] = new ExprBuilder($this->node);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Config\Definition\Builder;
|
||||
|
||||
use Symfony\Component\Config\Definition\VariableNode;
|
||||
|
||||
/**
|
||||
* This class provides a fluent interface for defining a node.
|
||||
*
|
||||
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
||||
*/
|
||||
class VariableNodeDefinition extends NodeDefinition
|
||||
{
|
||||
/**
|
||||
* Instantiate a Node
|
||||
*
|
||||
* @return VariableNode The node
|
||||
*/
|
||||
protected function instantiateNode()
|
||||
{
|
||||
return new VariableNode($this->name, $this->parent);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
protected function createNode()
|
||||
{
|
||||
$node = $this->instantiateNode();
|
||||
|
||||
if (null !== $this->normalization) {
|
||||
$node->setNormalizationClosures($this->normalization->before);
|
||||
}
|
||||
|
||||
if (null !== $this->merge) {
|
||||
$node->setAllowOverwrite($this->merge->allowOverwrite);
|
||||
}
|
||||
|
||||
if (true === $this->default) {
|
||||
$node->setDefaultValue($this->defaultValue);
|
||||
}
|
||||
|
||||
if (false === $this->allowEmptyValue) {
|
||||
$node->setAllowEmptyValue($this->allowEmptyValue);
|
||||
}
|
||||
|
||||
$node->addEquivalentValue(null, $this->nullEquivalent);
|
||||
$node->addEquivalentValue(true, $this->trueEquivalent);
|
||||
$node->addEquivalentValue(false, $this->falseEquivalent);
|
||||
$node->setRequired($this->required);
|
||||
|
||||
if (null !== $this->validation) {
|
||||
$node->setFinalValidationClosures($this->validation->rules);
|
||||
}
|
||||
|
||||
return $node;
|
||||
}
|
||||
|
||||
}
|
||||
27
core/vendor/symfony/config/Symfony/Component/Config/Definition/ConfigurationInterface.php
vendored
Normal file
27
core/vendor/symfony/config/Symfony/Component/Config/Definition/ConfigurationInterface.php
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Config\Definition;
|
||||
|
||||
/**
|
||||
* Configuration interface
|
||||
*
|
||||
* @author Victor Berchet <victor@suumit.com>
|
||||
*/
|
||||
interface ConfigurationInterface
|
||||
{
|
||||
/**
|
||||
* Generates the configuration tree builder.
|
||||
*
|
||||
* @return \Symfony\Component\Config\Definition\Builder\TreeBuilder The tree builder
|
||||
*/
|
||||
public function getConfigTreeBuilder();
|
||||
}
|
||||
50
core/vendor/symfony/config/Symfony/Component/Config/Definition/EnumNode.php
vendored
Normal file
50
core/vendor/symfony/config/Symfony/Component/Config/Definition/EnumNode.php
vendored
Normal file
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace Symfony\Component\Config\Definition;
|
||||
|
||||
use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException;
|
||||
use Symfony\Component\Config\Definition\ScalarNode;
|
||||
|
||||
/**
|
||||
* Node which only allows a finite set of values.
|
||||
*
|
||||
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
||||
*/
|
||||
class EnumNode extends ScalarNode
|
||||
{
|
||||
private $values;
|
||||
|
||||
public function __construct($name, NodeInterface $parent = null, array $values = array())
|
||||
{
|
||||
$values = array_unique($values);
|
||||
if (count($values) <= 1) {
|
||||
throw new \InvalidArgumentException('$values must contain at least two distinct elements.');
|
||||
}
|
||||
|
||||
parent::__construct($name, $parent);
|
||||
$this->values = $values;
|
||||
}
|
||||
|
||||
public function getValues()
|
||||
{
|
||||
return $this->values;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Config\Definition\Exception;
|
||||
|
||||
/**
|
||||
* This exception is thrown whenever the key of an array is not unique. This can
|
||||
* only be the case if the configuration is coming from an XML file.
|
||||
*
|
||||
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
||||
*/
|
||||
class DuplicateKeyException extends InvalidConfigurationException
|
||||
{
|
||||
}
|
||||
21
core/vendor/symfony/config/Symfony/Component/Config/Definition/Exception/Exception.php
vendored
Normal file
21
core/vendor/symfony/config/Symfony/Component/Config/Definition/Exception/Exception.php
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Config\Definition\Exception;
|
||||
|
||||
/**
|
||||
* Base exception for all configuration exceptions
|
||||
*
|
||||
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
||||
*/
|
||||
class Exception extends \RuntimeException
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Config\Definition\Exception;
|
||||
|
||||
/**
|
||||
* This exception is thrown when a configuration path is overwritten from a
|
||||
* subsequent configuration file, but the entry node specifically forbids this.
|
||||
*
|
||||
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
||||
*/
|
||||
class ForbiddenOverwriteException extends InvalidConfigurationException
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Config\Definition\Exception;
|
||||
|
||||
/**
|
||||
* A very general exception which can be thrown whenever non of the more specific
|
||||
* exceptions is suitable.
|
||||
*
|
||||
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
||||
*/
|
||||
class InvalidConfigurationException extends Exception
|
||||
{
|
||||
private $path;
|
||||
|
||||
public function setPath($path)
|
||||
{
|
||||
$this->path = $path;
|
||||
}
|
||||
|
||||
public function getPath()
|
||||
{
|
||||
return $this->path;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Config\Definition\Exception;
|
||||
|
||||
/**
|
||||
* Thrown when an error is detected in a node Definition.
|
||||
*
|
||||
* @author Victor Berchet <victor.berchet@suumit.com>
|
||||
*/
|
||||
class InvalidDefinitionException extends Exception
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Config\Definition\Exception;
|
||||
|
||||
/**
|
||||
* This exception is thrown if an invalid type is encountered.
|
||||
*
|
||||
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
||||
*/
|
||||
class InvalidTypeException extends InvalidConfigurationException
|
||||
{
|
||||
}
|
||||
22
core/vendor/symfony/config/Symfony/Component/Config/Definition/Exception/UnsetKeyException.php
vendored
Normal file
22
core/vendor/symfony/config/Symfony/Component/Config/Definition/Exception/UnsetKeyException.php
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Config\Definition\Exception;
|
||||
|
||||
/**
|
||||
* This exception is usually not encountered by the end-user, but only used
|
||||
* internally to signal the parent scope to unset a key.
|
||||
*
|
||||
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
||||
*/
|
||||
class UnsetKeyException extends Exception
|
||||
{
|
||||
}
|
||||
87
core/vendor/symfony/config/Symfony/Component/Config/Definition/NodeInterface.php
vendored
Normal file
87
core/vendor/symfony/config/Symfony/Component/Config/Definition/NodeInterface.php
vendored
Normal file
@@ -0,0 +1,87 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Config\Definition;
|
||||
|
||||
/**
|
||||
* Common Interface among all nodes.
|
||||
*
|
||||
* In most cases, it is better to inherit from BaseNode instead of implementing
|
||||
* this interface yourself.
|
||||
*
|
||||
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
||||
*/
|
||||
interface NodeInterface
|
||||
{
|
||||
/**
|
||||
* Returns the name of the node.
|
||||
*
|
||||
* @return string The name of the node
|
||||
*/
|
||||
public function getName();
|
||||
|
||||
/**
|
||||
* Returns the path of the node.
|
||||
*
|
||||
* @return string The node path
|
||||
*/
|
||||
public function getPath();
|
||||
|
||||
/**
|
||||
* Returns true when the node is required.
|
||||
*
|
||||
* @return Boolean If the node is required
|
||||
*/
|
||||
public function isRequired();
|
||||
|
||||
/**
|
||||
* Returns true when the node has a default value.
|
||||
*
|
||||
* @return Boolean If the node has a default value
|
||||
*/
|
||||
public function hasDefaultValue();
|
||||
|
||||
/**
|
||||
* Returns the default value of the node.
|
||||
*
|
||||
* @return mixed The default value
|
||||
* @throws \RuntimeException if the node has no default value
|
||||
*/
|
||||
public function getDefaultValue();
|
||||
|
||||
/**
|
||||
* Normalizes the supplied value.
|
||||
*
|
||||
* @param mixed $value The value to normalize
|
||||
*
|
||||
* @return mixed The normalized value
|
||||
*/
|
||||
public function normalize($value);
|
||||
|
||||
/**
|
||||
* Merges two values together.
|
||||
*
|
||||
* @param mixed $leftSide
|
||||
* @param mixed $rightSide
|
||||
*
|
||||
* @return mixed The merged values
|
||||
*/
|
||||
public function merge($leftSide, $rightSide);
|
||||
|
||||
/**
|
||||
* Finalizes a value.
|
||||
*
|
||||
* @param mixed $value The value to finalize
|
||||
*
|
||||
* @return mixed The finalized value
|
||||
*/
|
||||
public function finalize($value);
|
||||
}
|
||||
127
core/vendor/symfony/config/Symfony/Component/Config/Definition/Processor.php
vendored
Normal file
127
core/vendor/symfony/config/Symfony/Component/Config/Definition/Processor.php
vendored
Normal file
@@ -0,0 +1,127 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Config\Definition;
|
||||
|
||||
/**
|
||||
* This class is the entry point for config normalization/merging/finalization.
|
||||
*
|
||||
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
||||
*/
|
||||
class Processor
|
||||
{
|
||||
/**
|
||||
* Processes an array of configurations.
|
||||
*
|
||||
* @param NodeInterface $configTree The node tree describing the configuration
|
||||
* @param array $configs An array of configuration items to process
|
||||
*
|
||||
* @return array The processed configuration
|
||||
*/
|
||||
public function process(NodeInterface $configTree, array $configs)
|
||||
{
|
||||
$configs = self::normalizeKeys($configs);
|
||||
|
||||
$currentConfig = array();
|
||||
foreach ($configs as $config) {
|
||||
$config = $configTree->normalize($config);
|
||||
$currentConfig = $configTree->merge($currentConfig, $config);
|
||||
}
|
||||
|
||||
return $configTree->finalize($currentConfig);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method normalizes keys between the different configuration formats
|
||||
*
|
||||
* Namely, you mostly have foo_bar in YAML while you have foo-bar in XML.
|
||||
* After running this method, all keys are normalized to foo_bar.
|
||||
*
|
||||
* If you have a mixed key like foo-bar_moo, it will not be altered.
|
||||
* The key will also not be altered if the target key already exists.
|
||||
*
|
||||
* @param array $config
|
||||
*
|
||||
* @return array the config with normalized keys
|
||||
*/
|
||||
public static function normalizeKeys(array $config)
|
||||
{
|
||||
foreach ($config as $key => $value) {
|
||||
if (is_array($value)) {
|
||||
$config[$key] = self::normalizeKeys($value);
|
||||
}
|
||||
|
||||
if (false !== strpos($key, '-') && false === strpos($key, '_') && !array_key_exists($normalizedKey = str_replace('-', '_', $key), $config)) {
|
||||
$config[$normalizedKey] = $config[$key];
|
||||
unset($config[$key]);
|
||||
}
|
||||
}
|
||||
|
||||
return $config;
|
||||
}
|
||||
|
||||
/**
|
||||
* Normalizes a configuration entry.
|
||||
*
|
||||
* This method returns a normalize configuration array for a given key
|
||||
* to remove the differences due to the original format (YAML and XML mainly).
|
||||
*
|
||||
* Here is an example.
|
||||
*
|
||||
* The configuration is XML:
|
||||
*
|
||||
* <twig:extension id="twig.extension.foo" />
|
||||
* <twig:extension id="twig.extension.bar" />
|
||||
*
|
||||
* And the same configuration in YAML:
|
||||
*
|
||||
* twig.extensions: ['twig.extension.foo', 'twig.extension.bar']
|
||||
*
|
||||
* @param array $config A config array
|
||||
* @param string $key The key to normalize
|
||||
* @param string $plural The plural form of the key if it is irregular
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function normalizeConfig($config, $key, $plural = null)
|
||||
{
|
||||
if (null === $plural) {
|
||||
$plural = $key.'s';
|
||||
}
|
||||
|
||||
$values = array();
|
||||
if (isset($config[$plural])) {
|
||||
$values = $config[$plural];
|
||||
} elseif (isset($config[$key])) {
|
||||
if (is_string($config[$key]) || !is_int(key($config[$key]))) {
|
||||
// only one
|
||||
$values = array($config[$key]);
|
||||
} else {
|
||||
$values = $config[$key];
|
||||
}
|
||||
}
|
||||
|
||||
return $values;
|
||||
}
|
||||
}
|
||||
27
core/vendor/symfony/config/Symfony/Component/Config/Definition/PrototypeNodeInterface.php
vendored
Normal file
27
core/vendor/symfony/config/Symfony/Component/Config/Definition/PrototypeNodeInterface.php
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Config\Definition;
|
||||
|
||||
/**
|
||||
* This interface must be implemented by nodes which can be used as prototypes.
|
||||
*
|
||||
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
||||
*/
|
||||
interface PrototypeNodeInterface extends NodeInterface
|
||||
{
|
||||
/**
|
||||
* Sets the name of the node.
|
||||
*
|
||||
* @param string $name The name of the node
|
||||
*/
|
||||
public function setName($name);
|
||||
}
|
||||
342
core/vendor/symfony/config/Symfony/Component/Config/Definition/PrototypedArrayNode.php
vendored
Normal file
342
core/vendor/symfony/config/Symfony/Component/Config/Definition/PrototypedArrayNode.php
vendored
Normal file
@@ -0,0 +1,342 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Config\Definition;
|
||||
|
||||
use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException;
|
||||
use Symfony\Component\Config\Definition\Exception\DuplicateKeyException;
|
||||
use Symfony\Component\Config\Definition\Exception\UnsetKeyException;
|
||||
use Symfony\Component\Config\Definition\Exception\Exception;
|
||||
|
||||
/**
|
||||
* Represents a prototyped Array node in the config tree.
|
||||
*
|
||||
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
||||
*/
|
||||
class PrototypedArrayNode extends ArrayNode
|
||||
{
|
||||
protected $prototype;
|
||||
protected $keyAttribute;
|
||||
protected $removeKeyAttribute;
|
||||
protected $minNumberOfElements;
|
||||
protected $defaultValue;
|
||||
protected $defaultChildren;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param string $name The Node's name
|
||||
* @param NodeInterface $parent The node parent
|
||||
*/
|
||||
public function __construct($name, NodeInterface $parent = null)
|
||||
{
|
||||
parent::__construct($name, $parent);
|
||||
|
||||
$this->minNumberOfElements = 0;
|
||||
$this->defaultValue = array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the minimum number of elements that a prototype based node must
|
||||
* contain. By default this is zero, meaning no elements.
|
||||
*
|
||||
* @param integer $number
|
||||
*/
|
||||
public function setMinNumberOfElements($number)
|
||||
{
|
||||
$this->minNumberOfElements = $number;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the attribute which value is to be used as key.
|
||||
*
|
||||
* This is useful when you have an indexed array that should be an
|
||||
* associative array. You can select an item from within the array
|
||||
* to be the key of the particular item. For example, if "id" is the
|
||||
* "key", then:
|
||||
*
|
||||
* array(
|
||||
* array('id' => 'my_name', 'foo' => 'bar'),
|
||||
* );
|
||||
*
|
||||
* becomes
|
||||
*
|
||||
* array(
|
||||
* 'my_name' => array('foo' => 'bar'),
|
||||
* );
|
||||
*
|
||||
* If you'd like "'id' => 'my_name'" to still be present in the resulting
|
||||
* array, then you can set the second argument of this method to false.
|
||||
*
|
||||
* @param string $attribute The name of the attribute which value is to be used as a key
|
||||
* @param Boolean $remove Whether or not to remove the key
|
||||
*/
|
||||
public function setKeyAttribute($attribute, $remove = true)
|
||||
{
|
||||
$this->keyAttribute = $attribute;
|
||||
$this->removeKeyAttribute = $remove;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the name of the attribute which value should be used as key.
|
||||
*
|
||||
* @return string The name of the attribute
|
||||
*/
|
||||
public function getKeyAttribute()
|
||||
{
|
||||
return $this->keyAttribute;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the default value of this node.
|
||||
*
|
||||
* @param string $value
|
||||
*
|
||||
* @throws \InvalidArgumentException if the default value is not an array
|
||||
*/
|
||||
public function setDefaultValue($value)
|
||||
{
|
||||
if (!is_array($value)) {
|
||||
throw new \InvalidArgumentException($this->getPath().': the default value of an array node has to be an array.');
|
||||
}
|
||||
|
||||
$this->defaultValue = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the node has a default value.
|
||||
*
|
||||
* @return Boolean
|
||||
*/
|
||||
public function hasDefaultValue()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds default children when none are set.
|
||||
*
|
||||
* @param integer|string|array|null $children The number of children|The child name|The children names to be added
|
||||
*/
|
||||
public function setAddChildrenIfNoneSet($children = array('defaults'))
|
||||
{
|
||||
if (null === $children) {
|
||||
$this->defaultChildren = array('defaults');
|
||||
} else {
|
||||
$this->defaultChildren = is_integer($children) && $children > 0 ? range(1, $children) : (array) $children;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the default value.
|
||||
*
|
||||
* The default value could be either explicited or derived from the prototype
|
||||
* default value.
|
||||
*
|
||||
* @return array The default value
|
||||
*/
|
||||
public function getDefaultValue()
|
||||
{
|
||||
if (null !== $this->defaultChildren) {
|
||||
$default = $this->prototype->hasDefaultValue() ? $this->prototype->getDefaultValue() : array();
|
||||
$defaults = array();
|
||||
foreach (array_values($this->defaultChildren) as $i => $name) {
|
||||
$defaults[null === $this->keyAttribute ? $i : $name] = $default;
|
||||
}
|
||||
|
||||
return $defaults;
|
||||
}
|
||||
|
||||
return $this->defaultValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the node prototype.
|
||||
*
|
||||
* @param PrototypeNodeInterface $node
|
||||
*/
|
||||
public function setPrototype(PrototypeNodeInterface $node)
|
||||
{
|
||||
$this->prototype = $node;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the prototype
|
||||
*
|
||||
* @return PrototypeNodeInterface The prototype
|
||||
*/
|
||||
public function getPrototype()
|
||||
{
|
||||
return $this->prototype;
|
||||
}
|
||||
|
||||
/**
|
||||
* Disable adding concrete children for prototyped nodes.
|
||||
*
|
||||
* @param NodeInterface $node The child node to add
|
||||
*
|
||||
* @throws \RuntimeException Prototyped array nodes can't have concrete children.
|
||||
*/
|
||||
public function addChild(NodeInterface $node)
|
||||
{
|
||||
throw new Exception('A prototyped array node can not have concrete children.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Finalizes the value of this node.
|
||||
*
|
||||
* @param mixed $value
|
||||
*
|
||||
* @return mixed The finalized value
|
||||
*
|
||||
* @throws UnsetKeyException
|
||||
* @throws InvalidConfigurationException if the node doesn't have enough children
|
||||
*/
|
||||
protected function finalizeValue($value)
|
||||
{
|
||||
if (false === $value) {
|
||||
$msg = sprintf('Unsetting key for path "%s", value: %s', $this->getPath(), json_encode($value));
|
||||
throw new UnsetKeyException($msg);
|
||||
}
|
||||
|
||||
foreach ($value as $k => $v) {
|
||||
$this->prototype->setName($k);
|
||||
try {
|
||||
$value[$k] = $this->prototype->finalize($v);
|
||||
} catch (UnsetKeyException $unset) {
|
||||
unset($value[$k]);
|
||||
}
|
||||
}
|
||||
|
||||
if (count($value) < $this->minNumberOfElements) {
|
||||
$msg = sprintf('The path "%s" should have at least %d element(s) defined.', $this->getPath(), $this->minNumberOfElements);
|
||||
$ex = new InvalidConfigurationException($msg);
|
||||
$ex->setPath($this->getPath());
|
||||
|
||||
throw $ex;
|
||||
}
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Normalizes the value.
|
||||
*
|
||||
* @param mixed $value The value to normalize
|
||||
*
|
||||
* @return mixed The normalized value
|
||||
*/
|
||||
protected function normalizeValue($value)
|
||||
{
|
||||
if (false === $value) {
|
||||
return $value;
|
||||
}
|
||||
|
||||
$value = $this->remapXml($value);
|
||||
|
||||
$isAssoc = array_keys($value) === range(0, count($value) -1);
|
||||
$normalized = array();
|
||||
foreach ($value as $k => $v) {
|
||||
if (null !== $this->keyAttribute && is_array($v)) {
|
||||
if (!isset($v[$this->keyAttribute]) && is_int($k) && $isAssoc) {
|
||||
$msg = sprintf('The attribute "%s" must be set for path "%s".', $this->keyAttribute, $this->getPath());
|
||||
$ex = new InvalidConfigurationException($msg);
|
||||
$ex->setPath($this->getPath());
|
||||
|
||||
throw $ex;
|
||||
} elseif (isset($v[$this->keyAttribute])) {
|
||||
$k = $v[$this->keyAttribute];
|
||||
|
||||
// remove the key attribute when required
|
||||
if ($this->removeKeyAttribute) {
|
||||
unset($v[$this->keyAttribute]);
|
||||
}
|
||||
|
||||
// if only "value" is left
|
||||
if (1 == count($v) && isset($v['value'])) {
|
||||
$v = $v['value'];
|
||||
}
|
||||
}
|
||||
|
||||
if (array_key_exists($k, $normalized)) {
|
||||
$msg = sprintf('Duplicate key "%s" for path "%s".', $k, $this->getPath());
|
||||
$ex = new DuplicateKeyException($msg);
|
||||
$ex->setPath($this->getPath());
|
||||
|
||||
throw $ex;
|
||||
}
|
||||
}
|
||||
|
||||
$this->prototype->setName($k);
|
||||
if (null !== $this->keyAttribute) {
|
||||
$normalized[$k] = $this->prototype->normalize($v);
|
||||
} else {
|
||||
$normalized[] = $this->prototype->normalize($v);
|
||||
}
|
||||
}
|
||||
|
||||
return $normalized;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
}
|
||||
47
core/vendor/symfony/config/Symfony/Component/Config/Definition/ScalarNode.php
vendored
Normal file
47
core/vendor/symfony/config/Symfony/Component/Config/Definition/ScalarNode.php
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Config\Definition;
|
||||
|
||||
use Symfony\Component\Config\Definition\VariableNode;
|
||||
use Symfony\Component\Config\Definition\Exception\InvalidTypeException;
|
||||
|
||||
/**
|
||||
* This node represents a scalar value in the config tree.
|
||||
*
|
||||
* The following values are considered scalars:
|
||||
* * booleans
|
||||
* * strings
|
||||
* * null
|
||||
* * integers
|
||||
* * floats
|
||||
*
|
||||
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
||||
*/
|
||||
class ScalarNode extends VariableNode
|
||||
{
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
protected function validateType($value)
|
||||
{
|
||||
if (!is_scalar($value) && null !== $value) {
|
||||
$ex = new InvalidTypeException(sprintf(
|
||||
'Invalid type for path "%s". Expected scalar, but got %s.',
|
||||
$this->getPath(),
|
||||
gettype($value)
|
||||
));
|
||||
$ex->setPath($this->getPath());
|
||||
|
||||
throw $ex;
|
||||
}
|
||||
}
|
||||
}
|
||||
114
core/vendor/symfony/config/Symfony/Component/Config/Definition/VariableNode.php
vendored
Normal file
114
core/vendor/symfony/config/Symfony/Component/Config/Definition/VariableNode.php
vendored
Normal file
@@ -0,0 +1,114 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Config\Definition;
|
||||
|
||||
use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException;
|
||||
|
||||
/**
|
||||
* This node represents a value of variable type in the config tree.
|
||||
*
|
||||
* This node is intended for values of arbitrary type.
|
||||
* Any PHP type is accepted as a value.
|
||||
*
|
||||
* @author Jeremy Mikola <jmikola@gmail.com>
|
||||
*/
|
||||
class VariableNode extends BaseNode implements PrototypeNodeInterface
|
||||
{
|
||||
protected $defaultValueSet = false;
|
||||
protected $defaultValue;
|
||||
protected $allowEmptyValue = true;
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function setDefaultValue($value)
|
||||
{
|
||||
$this->defaultValueSet = true;
|
||||
$this->defaultValue = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function hasDefaultValue()
|
||||
{
|
||||
return $this->defaultValueSet;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function getDefaultValue()
|
||||
{
|
||||
return $this->defaultValue instanceof \Closure ? call_user_func($this->defaultValue) : $this->defaultValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets if this node is allowed to have an empty value.
|
||||
*
|
||||
* @param Boolean $boolean True if this entity will accept empty values.
|
||||
*/
|
||||
public function setAllowEmptyValue($boolean)
|
||||
{
|
||||
$this->allowEmptyValue = (Boolean) $boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function setName($name)
|
||||
{
|
||||
$this->name = $name;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
protected function validateType($value)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* {@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;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
protected function normalizeValue($value)
|
||||
{
|
||||
return $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
protected function mergeValues($leftSide, $rightSide)
|
||||
{
|
||||
return $rightSide;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Config\Exception;
|
||||
|
||||
/**
|
||||
* Exception class for when a circular reference is detected when importing resources.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*/
|
||||
class FileLoaderImportCircularReferenceException extends FileLoaderLoadException
|
||||
{
|
||||
public function __construct(array $resources, $code = null, $previous = null)
|
||||
{
|
||||
$message = sprintf('Circular reference detected in "%s" ("%s" > "%s").', $this->varToString($resources[0]), implode('" > "', $resources), $resources[0]);
|
||||
|
||||
call_user_func('Exception::__construct', $message, $code, $previous);
|
||||
}
|
||||
}
|
||||
78
core/vendor/symfony/config/Symfony/Component/Config/Exception/FileLoaderLoadException.php
vendored
Normal file
78
core/vendor/symfony/config/Symfony/Component/Config/Exception/FileLoaderLoadException.php
vendored
Normal file
@@ -0,0 +1,78 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Config\Exception;
|
||||
|
||||
/**
|
||||
* Exception class for when a resource cannot be loaded or imported.
|
||||
*
|
||||
* @author Ryan Weaver <ryan@thatsquality.com>
|
||||
*/
|
||||
class FileLoaderLoadException extends \Exception
|
||||
{
|
||||
/**
|
||||
* @param string $resource The resource that could not be imported
|
||||
* @param string $sourceResource The original resource importing the new resource
|
||||
* @param integer $code The error code
|
||||
* @param Exception $previous A previous exception
|
||||
*/
|
||||
public function __construct($resource, $sourceResource = null, $code = null, $previous = null)
|
||||
{
|
||||
if (null === $sourceResource) {
|
||||
$message = sprintf('Cannot load resource "%s".', $this->varToString($resource));
|
||||
} else {
|
||||
$message = sprintf('Cannot import resource "%s" from "%s".', $this->varToString($resource), $this->varToString($sourceResource));
|
||||
}
|
||||
|
||||
// Is the resource located inside a bundle?
|
||||
if ('@' === $resource[0]) {
|
||||
$parts = explode(DIRECTORY_SEPARATOR, $resource);
|
||||
$bundle = substr($parts[0], 1);
|
||||
$message .= ' '.sprintf('Make sure the "%s" bundle is correctly registered and loaded in the application kernel class.', $bundle);
|
||||
}
|
||||
|
||||
parent::__construct($message, $code, $previous);
|
||||
}
|
||||
|
||||
protected function varToString($var)
|
||||
{
|
||||
if (is_object($var)) {
|
||||
return sprintf('Object(%s)', get_class($var));
|
||||
}
|
||||
|
||||
if (is_array($var)) {
|
||||
$a = array();
|
||||
foreach ($var as $k => $v) {
|
||||
$a[] = sprintf('%s => %s', $k, $this->varToString($v));
|
||||
}
|
||||
|
||||
return sprintf("Array(%s)", implode(', ', $a));
|
||||
}
|
||||
|
||||
if (is_resource($var)) {
|
||||
return sprintf('Resource(%s)', get_resource_type($var));
|
||||
}
|
||||
|
||||
if (null === $var) {
|
||||
return 'null';
|
||||
}
|
||||
|
||||
if (false === $var) {
|
||||
return 'false';
|
||||
}
|
||||
|
||||
if (true === $var) {
|
||||
return 'true';
|
||||
}
|
||||
|
||||
return (string) $var;
|
||||
}
|
||||
}
|
||||
99
core/vendor/symfony/config/Symfony/Component/Config/FileLocator.php
vendored
Normal file
99
core/vendor/symfony/config/Symfony/Component/Config/FileLocator.php
vendored
Normal file
@@ -0,0 +1,99 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Config;
|
||||
|
||||
/**
|
||||
* FileLocator uses an array of pre-defined paths to find files.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*/
|
||||
class FileLocator implements FileLocatorInterface
|
||||
{
|
||||
protected $paths;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param string|array $paths A path or an array of paths where to look for resources
|
||||
*/
|
||||
public function __construct($paths = array())
|
||||
{
|
||||
$this->paths = (array) $paths;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a full path for a given file name.
|
||||
*
|
||||
* @param mixed $name The file name to locate
|
||||
* @param string $currentPath The current path
|
||||
* @param Boolean $first Whether to return the first occurrence or an array of filenames
|
||||
*
|
||||
* @return string|array The full path to the file|An array of file paths
|
||||
*
|
||||
* @throws \InvalidArgumentException When file is not found
|
||||
*/
|
||||
public function locate($name, $currentPath = null, $first = true)
|
||||
{
|
||||
if ($this->isAbsolutePath($name)) {
|
||||
if (!file_exists($name)) {
|
||||
throw new \InvalidArgumentException(sprintf('The file "%s" does not exist.', $name));
|
||||
}
|
||||
|
||||
return $name;
|
||||
}
|
||||
|
||||
$filepaths = array();
|
||||
if (null !== $currentPath && file_exists($file = $currentPath.DIRECTORY_SEPARATOR.$name)) {
|
||||
if (true === $first) {
|
||||
return $file;
|
||||
}
|
||||
$filepaths[] = $file;
|
||||
}
|
||||
|
||||
foreach ($this->paths as $path) {
|
||||
if (file_exists($file = $path.DIRECTORY_SEPARATOR.$name)) {
|
||||
if (true === $first) {
|
||||
return $file;
|
||||
}
|
||||
$filepaths[] = $file;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$filepaths) {
|
||||
throw new \InvalidArgumentException(sprintf('The file "%s" does not exist (in: %s%s).', $name, null !== $currentPath ? $currentPath.', ' : '', implode(', ', $this->paths)));
|
||||
}
|
||||
|
||||
return array_values(array_unique($filepaths));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the file path is an absolute path.
|
||||
*
|
||||
* @param string $file A file path
|
||||
*
|
||||
* @return Boolean
|
||||
*/
|
||||
private function isAbsolutePath($file)
|
||||
{
|
||||
if ($file[0] == '/' || $file[0] == '\\'
|
||||
|| (strlen($file) > 3 && ctype_alpha($file[0])
|
||||
&& $file[1] == ':'
|
||||
&& ($file[2] == '\\' || $file[2] == '/')
|
||||
)
|
||||
|| null !== parse_url($file, PHP_URL_SCHEME)
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
31
core/vendor/symfony/config/Symfony/Component/Config/FileLocatorInterface.php
vendored
Normal file
31
core/vendor/symfony/config/Symfony/Component/Config/FileLocatorInterface.php
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Config;
|
||||
|
||||
/**
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*/
|
||||
interface FileLocatorInterface
|
||||
{
|
||||
/**
|
||||
* Returns a full path for a given file name.
|
||||
*
|
||||
* @param mixed $name The file name to locate
|
||||
* @param string $currentPath The current path
|
||||
* @param Boolean $first Whether to return the first occurrence or an array of filenames
|
||||
*
|
||||
* @return string|array The full path to the file|An array of file paths
|
||||
*
|
||||
* @throws \InvalidArgumentException When file is not found
|
||||
*/
|
||||
public function locate($name, $currentPath = null, $first = true);
|
||||
}
|
||||
19
core/vendor/symfony/config/Symfony/Component/Config/LICENSE
vendored
Normal file
19
core/vendor/symfony/config/Symfony/Component/Config/LICENSE
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
Copyright (c) 2004-2012 Fabien Potencier
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is furnished
|
||||
to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
62
core/vendor/symfony/config/Symfony/Component/Config/Loader/DelegatingLoader.php
vendored
Normal file
62
core/vendor/symfony/config/Symfony/Component/Config/Loader/DelegatingLoader.php
vendored
Normal file
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Config\Loader;
|
||||
|
||||
use Symfony\Component\Config\Exception\FileLoaderLoadException;
|
||||
|
||||
/**
|
||||
* DelegatingLoader delegates loading to other loaders using a loader resolver.
|
||||
*
|
||||
* This loader acts as an array of LoaderInterface objects - each having
|
||||
* a chance to load a given resource (handled by the resolver)
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*/
|
||||
class DelegatingLoader extends Loader
|
||||
{
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param LoaderResolverInterface $resolver A LoaderResolverInterface instance
|
||||
*/
|
||||
public function __construct(LoaderResolverInterface $resolver)
|
||||
{
|
||||
$this->resolver = $resolver;
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads a resource.
|
||||
*
|
||||
* @param mixed $resource A resource
|
||||
* @param string $type The resource type
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @throws FileLoaderLoadException if no loader is found.
|
||||
*/
|
||||
public function load($resource, $type = null)
|
||||
{
|
||||
if (false === $loader = $this->resolver->resolve($resource, $type)) {
|
||||
throw new FileLoaderLoadException($resource);
|
||||
}
|
||||
|
||||
return $loader->load($resource, $type);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function supports($resource, $type = null)
|
||||
{
|
||||
return false === $this->resolver->resolve($resource, $type) ? false : true;
|
||||
}
|
||||
}
|
||||
93
core/vendor/symfony/config/Symfony/Component/Config/Loader/FileLoader.php
vendored
Normal file
93
core/vendor/symfony/config/Symfony/Component/Config/Loader/FileLoader.php
vendored
Normal file
@@ -0,0 +1,93 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Config\Loader;
|
||||
|
||||
use Symfony\Component\Config\FileLocatorInterface;
|
||||
use Symfony\Component\Config\Exception\FileLoaderLoadException;
|
||||
use Symfony\Component\Config\Exception\FileLoaderImportCircularReferenceException;
|
||||
|
||||
/**
|
||||
* FileLoader is the abstract class used by all built-in loaders that are file based.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*/
|
||||
abstract class FileLoader extends Loader
|
||||
{
|
||||
protected static $loading = array();
|
||||
|
||||
protected $locator;
|
||||
|
||||
private $currentDir;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param FileLocatorInterface $locator A FileLocatorInterface instance
|
||||
*/
|
||||
public function __construct(FileLocatorInterface $locator)
|
||||
{
|
||||
$this->locator = $locator;
|
||||
}
|
||||
|
||||
public function setCurrentDir($dir)
|
||||
{
|
||||
$this->currentDir = $dir;
|
||||
}
|
||||
|
||||
public function getLocator()
|
||||
{
|
||||
return $this->locator;
|
||||
}
|
||||
|
||||
/**
|
||||
* Imports a resource.
|
||||
*
|
||||
* @param mixed $resource A Resource
|
||||
* @param string $type The resource type
|
||||
* @param Boolean $ignoreErrors Whether to ignore import errors or not
|
||||
* @param string $sourceResource The original resource importing the new resource
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function import($resource, $type = null, $ignoreErrors = false, $sourceResource = null)
|
||||
{
|
||||
try {
|
||||
$loader = $this->resolve($resource, $type);
|
||||
|
||||
if ($loader instanceof FileLoader && null !== $this->currentDir) {
|
||||
$resource = $this->locator->locate($resource, $this->currentDir);
|
||||
}
|
||||
|
||||
if (isset(self::$loading[$resource])) {
|
||||
throw new FileLoaderImportCircularReferenceException(array_keys(self::$loading));
|
||||
}
|
||||
self::$loading[$resource] = true;
|
||||
|
||||
$ret = $loader->load($resource, $type);
|
||||
|
||||
unset(self::$loading[$resource]);
|
||||
|
||||
return $ret;
|
||||
} catch (FileLoaderImportCircularReferenceException $e) {
|
||||
throw $e;
|
||||
} catch (\Exception $e) {
|
||||
if (!$ignoreErrors) {
|
||||
// prevent embedded imports from nesting multiple exceptions
|
||||
if ($e instanceof FileLoaderLoadException) {
|
||||
throw $e;
|
||||
}
|
||||
|
||||
throw new FileLoaderLoadException($resource, $sourceResource, null, $e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
80
core/vendor/symfony/config/Symfony/Component/Config/Loader/Loader.php
vendored
Normal file
80
core/vendor/symfony/config/Symfony/Component/Config/Loader/Loader.php
vendored
Normal file
@@ -0,0 +1,80 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Config\Loader;
|
||||
|
||||
use Symfony\Component\Config\Exception\FileLoaderLoadException;
|
||||
|
||||
/**
|
||||
* Loader is the abstract class used by all built-in loaders.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*/
|
||||
abstract class Loader implements LoaderInterface
|
||||
{
|
||||
protected $resolver;
|
||||
|
||||
/**
|
||||
* Gets the loader resolver.
|
||||
*
|
||||
* @return LoaderResolverInterface A LoaderResolverInterface instance
|
||||
*/
|
||||
public function getResolver()
|
||||
{
|
||||
return $this->resolver;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the loader resolver.
|
||||
*
|
||||
* @param LoaderResolverInterface $resolver A LoaderResolverInterface instance
|
||||
*/
|
||||
public function setResolver(LoaderResolverInterface $resolver)
|
||||
{
|
||||
$this->resolver = $resolver;
|
||||
}
|
||||
|
||||
/**
|
||||
* Imports a resource.
|
||||
*
|
||||
* @param mixed $resource A Resource
|
||||
* @param string $type The resource type
|
||||
*/
|
||||
public function import($resource, $type = null)
|
||||
{
|
||||
$this->resolve($resource)->load($resource, $type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds a loader able to load an imported resource.
|
||||
*
|
||||
* @param mixed $resource A Resource
|
||||
* @param string $type The resource type
|
||||
*
|
||||
* @return LoaderInterface A LoaderInterface instance
|
||||
*
|
||||
* @throws FileLoaderLoadException if no loader is found
|
||||
*/
|
||||
public function resolve($resource, $type = null)
|
||||
{
|
||||
if ($this->supports($resource, $type)) {
|
||||
return $this;
|
||||
}
|
||||
|
||||
$loader = null === $this->resolver ? false : $this->resolver->resolve($resource, $type);
|
||||
|
||||
if (false === $loader) {
|
||||
throw new FileLoaderLoadException($resource);
|
||||
}
|
||||
|
||||
return $loader;
|
||||
}
|
||||
}
|
||||
53
core/vendor/symfony/config/Symfony/Component/Config/Loader/LoaderInterface.php
vendored
Normal file
53
core/vendor/symfony/config/Symfony/Component/Config/Loader/LoaderInterface.php
vendored
Normal file
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Config\Loader;
|
||||
|
||||
/**
|
||||
* LoaderInterface is the interface implemented by all loader classes.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*/
|
||||
interface LoaderInterface
|
||||
{
|
||||
/**
|
||||
* Loads a resource.
|
||||
*
|
||||
* @param mixed $resource The resource
|
||||
* @param string $type The resource type
|
||||
*/
|
||||
public function load($resource, $type = null);
|
||||
|
||||
/**
|
||||
* Returns true if this class supports the given resource.
|
||||
*
|
||||
* @param mixed $resource A resource
|
||||
* @param string $type The resource type
|
||||
*
|
||||
* @return Boolean true if this class supports the given resource, false otherwise
|
||||
*/
|
||||
public function supports($resource, $type = null);
|
||||
|
||||
/**
|
||||
* Gets the loader resolver.
|
||||
*
|
||||
* @return LoaderResolverInterface A LoaderResolverInterface instance
|
||||
*/
|
||||
public function getResolver();
|
||||
|
||||
/**
|
||||
* Sets the loader resolver.
|
||||
*
|
||||
* @param LoaderResolverInterface $resolver A LoaderResolverInterface instance
|
||||
*/
|
||||
public function setResolver(LoaderResolverInterface $resolver);
|
||||
|
||||
}
|
||||
81
core/vendor/symfony/config/Symfony/Component/Config/Loader/LoaderResolver.php
vendored
Normal file
81
core/vendor/symfony/config/Symfony/Component/Config/Loader/LoaderResolver.php
vendored
Normal file
@@ -0,0 +1,81 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Config\Loader;
|
||||
|
||||
/**
|
||||
* LoaderResolver selects a loader for a given resource.
|
||||
*
|
||||
* A resource can be anything (e.g. a full path to a config file or a Closure).
|
||||
* Each loader determines whether it can load a resource and how.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*/
|
||||
class LoaderResolver implements LoaderResolverInterface
|
||||
{
|
||||
/**
|
||||
* @var LoaderInterface[] An array of LoaderInterface objects
|
||||
*/
|
||||
private $loaders;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param LoaderInterface[] $loaders An array of loaders
|
||||
*/
|
||||
public function __construct(array $loaders = array())
|
||||
{
|
||||
$this->loaders = array();
|
||||
foreach ($loaders as $loader) {
|
||||
$this->addLoader($loader);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a loader able to load the resource.
|
||||
*
|
||||
* @param mixed $resource A resource
|
||||
* @param string $type The resource type
|
||||
*
|
||||
* @return LoaderInterface|false A LoaderInterface instance
|
||||
*/
|
||||
public function resolve($resource, $type = null)
|
||||
{
|
||||
foreach ($this->loaders as $loader) {
|
||||
if ($loader->supports($resource, $type)) {
|
||||
return $loader;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a loader.
|
||||
*
|
||||
* @param LoaderInterface $loader A LoaderInterface instance
|
||||
*/
|
||||
public function addLoader(LoaderInterface $loader)
|
||||
{
|
||||
$this->loaders[] = $loader;
|
||||
$loader->setResolver($this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the registered loaders.
|
||||
*
|
||||
* @return LoaderInterface[] An array of LoaderInterface instances
|
||||
*/
|
||||
public function getLoaders()
|
||||
{
|
||||
return $this->loaders;
|
||||
}
|
||||
}
|
||||
30
core/vendor/symfony/config/Symfony/Component/Config/Loader/LoaderResolverInterface.php
vendored
Normal file
30
core/vendor/symfony/config/Symfony/Component/Config/Loader/LoaderResolverInterface.php
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Config\Loader;
|
||||
|
||||
/**
|
||||
* LoaderResolverInterface selects a loader for a given resource.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*/
|
||||
interface LoaderResolverInterface
|
||||
{
|
||||
/**
|
||||
* Returns a loader able to load the resource.
|
||||
*
|
||||
* @param mixed $resource A resource
|
||||
* @param string $type The resource type
|
||||
*
|
||||
* @return LoaderInterface A LoaderInterface instance
|
||||
*/
|
||||
public function resolve($resource, $type = null);
|
||||
}
|
||||
14
core/vendor/symfony/config/Symfony/Component/Config/README.md
vendored
Normal file
14
core/vendor/symfony/config/Symfony/Component/Config/README.md
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
Config Component
|
||||
================
|
||||
|
||||
Config provides the infrastructure for loading configurations from different
|
||||
data sources and optionally monitoring these data sources for changes. There
|
||||
are additional tools for validating, normalizing and handling of defaults that
|
||||
can optionally be used to convert from different formats to arrays.
|
||||
|
||||
Resources
|
||||
---------
|
||||
|
||||
You can run the unit tests with the following command:
|
||||
|
||||
phpunit
|
||||
102
core/vendor/symfony/config/Symfony/Component/Config/Resource/DirectoryResource.php
vendored
Normal file
102
core/vendor/symfony/config/Symfony/Component/Config/Resource/DirectoryResource.php
vendored
Normal file
@@ -0,0 +1,102 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Config\Resource;
|
||||
|
||||
/**
|
||||
* DirectoryResource represents a resources stored in a subdirectory tree.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*/
|
||||
class DirectoryResource implements ResourceInterface, \Serializable
|
||||
{
|
||||
private $resource;
|
||||
private $pattern;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param string $resource The file path to the resource
|
||||
* @param string $pattern A pattern to restrict monitored files
|
||||
*/
|
||||
public function __construct($resource, $pattern = null)
|
||||
{
|
||||
$this->resource = $resource;
|
||||
$this->pattern = $pattern;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string representation of the Resource.
|
||||
*
|
||||
* @return string A string representation of the Resource
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
return (string) $this->resource;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the resource tied to this Resource.
|
||||
*
|
||||
* @return mixed The resource
|
||||
*/
|
||||
public function getResource()
|
||||
{
|
||||
return $this->resource;
|
||||
}
|
||||
|
||||
public function getPattern()
|
||||
{
|
||||
return $this->pattern;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the resource has not been updated since the given timestamp.
|
||||
*
|
||||
* @param integer $timestamp The last time the resource was loaded
|
||||
*
|
||||
* @return Boolean true if the resource has not been updated, false otherwise
|
||||
*/
|
||||
public function isFresh($timestamp)
|
||||
{
|
||||
if (!is_dir($this->resource)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$newestMTime = filemtime($this->resource);
|
||||
foreach (new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($this->resource), \RecursiveIteratorIterator::SELF_FIRST) as $file) {
|
||||
// if regex filtering is enabled only check matching files
|
||||
if ($this->pattern && $file->isFile() && !preg_match($this->pattern, $file->getBasename())) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// always monitor directories for changes, except the .. entries
|
||||
// (otherwise deleted files wouldn't get detected)
|
||||
if ($file->isDir() && '/..' === substr($file, -3)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$newestMTime = max($file->getMTime(), $newestMTime);
|
||||
}
|
||||
|
||||
return $newestMTime < $timestamp;
|
||||
}
|
||||
|
||||
public function serialize()
|
||||
{
|
||||
return serialize(array($this->resource, $this->pattern));
|
||||
}
|
||||
|
||||
public function unserialize($serialized)
|
||||
{
|
||||
list($this->resource, $this->pattern) = unserialize($serialized);
|
||||
}
|
||||
}
|
||||
80
core/vendor/symfony/config/Symfony/Component/Config/Resource/FileResource.php
vendored
Normal file
80
core/vendor/symfony/config/Symfony/Component/Config/Resource/FileResource.php
vendored
Normal file
@@ -0,0 +1,80 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Config\Resource;
|
||||
|
||||
/**
|
||||
* FileResource represents a resource stored on the filesystem.
|
||||
*
|
||||
* The resource can be a file or a directory.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*/
|
||||
class FileResource implements ResourceInterface, \Serializable
|
||||
{
|
||||
private $resource;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param string $resource The file path to the resource
|
||||
*/
|
||||
public function __construct($resource)
|
||||
{
|
||||
$this->resource = realpath($resource);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string representation of the Resource.
|
||||
*
|
||||
* @return string A string representation of the Resource
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
return (string) $this->resource;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the resource tied to this Resource.
|
||||
*
|
||||
* @return mixed The resource
|
||||
*/
|
||||
public function getResource()
|
||||
{
|
||||
return $this->resource;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the resource has not been updated since the given timestamp.
|
||||
*
|
||||
* @param integer $timestamp The last time the resource was loaded
|
||||
*
|
||||
* @return Boolean true if the resource has not been updated, false otherwise
|
||||
*/
|
||||
public function isFresh($timestamp)
|
||||
{
|
||||
if (!file_exists($this->resource)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return filemtime($this->resource) < $timestamp;
|
||||
}
|
||||
|
||||
public function serialize()
|
||||
{
|
||||
return serialize($this->resource);
|
||||
}
|
||||
|
||||
public function unserialize($serialized)
|
||||
{
|
||||
$this->resource = unserialize($serialized);
|
||||
}
|
||||
}
|
||||
43
core/vendor/symfony/config/Symfony/Component/Config/Resource/ResourceInterface.php
vendored
Normal file
43
core/vendor/symfony/config/Symfony/Component/Config/Resource/ResourceInterface.php
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Config\Resource;
|
||||
|
||||
/**
|
||||
* ResourceInterface is the interface that must be implemented by all Resource classes.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*/
|
||||
interface ResourceInterface
|
||||
{
|
||||
/**
|
||||
* Returns a string representation of the Resource.
|
||||
*
|
||||
* @return string A string representation of the Resource
|
||||
*/
|
||||
public function __toString();
|
||||
|
||||
/**
|
||||
* Returns true if the resource has not been updated since the given timestamp.
|
||||
*
|
||||
* @param integer $timestamp The last time the resource was loaded
|
||||
*
|
||||
* @return Boolean true if the resource has not been updated, false otherwise
|
||||
*/
|
||||
public function isFresh($timestamp);
|
||||
|
||||
/**
|
||||
* Returns the resource tied to this Resource.
|
||||
*
|
||||
* @return mixed The resource
|
||||
*/
|
||||
public function getResource();
|
||||
}
|
||||
57
core/vendor/symfony/config/Symfony/Component/Config/Tests/Definition/ArrayNodeTest.php
vendored
Normal file
57
core/vendor/symfony/config/Symfony/Component/Config/Tests/Definition/ArrayNodeTest.php
vendored
Normal file
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Config\Tests\Definition;
|
||||
|
||||
use Symfony\Component\Config\Definition\ArrayNode;
|
||||
|
||||
class ArrayNodeTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @expectedException Symfony\Component\Config\Definition\Exception\InvalidTypeException
|
||||
*/
|
||||
public function testNormalizeThrowsExceptionWhenFalseIsNotAllowed()
|
||||
{
|
||||
$node = new ArrayNode('root');
|
||||
$node->normalize(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* normalize() should protect against child values with no corresponding node
|
||||
*/
|
||||
public function testExceptionThrownOnUnrecognizedChild()
|
||||
{
|
||||
$node = new ArrayNode('root');
|
||||
|
||||
try {
|
||||
$node->normalize(array('foo' => 'bar'));
|
||||
$this->fail('An exception should have been throw for a bad child node');
|
||||
} catch (\Exception $e) {
|
||||
$this->assertInstanceOf('Symfony\Component\Config\Definition\Exception\InvalidConfigurationException', $e);
|
||||
$this->assertEquals('Unrecognized options "foo" under "root"', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests that no exception is thrown for an unrecognized child if the
|
||||
* ignoreExtraKeys option is set to true.
|
||||
*
|
||||
* Related to testExceptionThrownOnUnrecognizedChild
|
||||
*/
|
||||
public function testIgnoreExtraKeysNoException()
|
||||
{
|
||||
$node = new ArrayNode('roo');
|
||||
$node->setIgnoreExtraKeys(true);
|
||||
|
||||
$node->normalize(array('foo' => 'bar'));
|
||||
$this->assertTrue(true, 'No exception was thrown when setIgnoreExtraKeys is true');
|
||||
}
|
||||
}
|
||||
60
core/vendor/symfony/config/Symfony/Component/Config/Tests/Definition/BooleanNodeTest.php
vendored
Normal file
60
core/vendor/symfony/config/Symfony/Component/Config/Tests/Definition/BooleanNodeTest.php
vendored
Normal file
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Config\Tests\Definition;
|
||||
|
||||
use Symfony\Component\Config\Definition\BooleanNode;
|
||||
|
||||
class BooleanNodeTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @dataProvider getValidValues
|
||||
*/
|
||||
public function testNormalize($value)
|
||||
{
|
||||
$node = new BooleanNode('test');
|
||||
$this->assertSame($value, $node->normalize($value));
|
||||
}
|
||||
|
||||
public function getValidValues()
|
||||
{
|
||||
return array(
|
||||
array(false),
|
||||
array(true),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getInvalidValues
|
||||
* @expectedException Symfony\Component\Config\Definition\Exception\InvalidTypeException
|
||||
*/
|
||||
public function testNormalizeThrowsExceptionOnInvalidValues($value)
|
||||
{
|
||||
$node = new BooleanNode('test');
|
||||
$node->normalize($value);
|
||||
}
|
||||
|
||||
public function getInvalidValues()
|
||||
{
|
||||
return array(
|
||||
array(null),
|
||||
array(''),
|
||||
array('foo'),
|
||||
array(0),
|
||||
array(1),
|
||||
array(0.0),
|
||||
array(0.1),
|
||||
array(array()),
|
||||
array(array('foo' => 'bar')),
|
||||
array(new \stdClass()),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,159 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Config\Tests\Definition\Builder;
|
||||
|
||||
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
|
||||
use Symfony\Component\Config\Definition\Builder\ScalarNodeDefinition;
|
||||
use Symfony\Component\Config\Definition\Exception\InvalidDefinitionException;
|
||||
|
||||
class ArrayNodeDefinitionTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testAppendingSomeNode()
|
||||
{
|
||||
$parent = new ArrayNodeDefinition('root');
|
||||
$child = new ScalarNodeDefinition('child');
|
||||
|
||||
$parent
|
||||
->children()
|
||||
->scalarNode('foo')->end()
|
||||
->scalarNode('bar')->end()
|
||||
->end()
|
||||
->append($child);
|
||||
|
||||
$this->assertCount(3, $this->getField($parent, 'children'));
|
||||
$this->assertTrue(in_array($child, $this->getField($parent, 'children')));
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException Symfony\Component\Config\Definition\Exception\InvalidDefinitionException
|
||||
* @dataProvider providePrototypeNodeSpecificCalls
|
||||
*/
|
||||
public function testPrototypeNodeSpecificOption($method, $args)
|
||||
{
|
||||
$node = new ArrayNodeDefinition('root');
|
||||
|
||||
call_user_func_array(array($node, $method), $args);
|
||||
|
||||
$node->getNode();
|
||||
}
|
||||
|
||||
public function providePrototypeNodeSpecificCalls()
|
||||
{
|
||||
return array(
|
||||
array('defaultValue', array(array())),
|
||||
array('addDefaultChildrenIfNoneSet', array()),
|
||||
array('requiresAtLeastOneElement', array()),
|
||||
array('useAttributeAsKey', array('foo'))
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException Symfony\Component\Config\Definition\Exception\InvalidDefinitionException
|
||||
*/
|
||||
public function testConcreteNodeSpecificOption()
|
||||
{
|
||||
$node = new ArrayNodeDefinition('root');
|
||||
$node->addDefaultsIfNotSet()->prototype('array');
|
||||
$node->getNode();
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException Symfony\Component\Config\Definition\Exception\InvalidDefinitionException
|
||||
*/
|
||||
public function testPrototypeNodesCantHaveADefaultValueWhenUsingDefaultChildren()
|
||||
{
|
||||
$node = new ArrayNodeDefinition('root');
|
||||
$node
|
||||
->defaultValue(array())
|
||||
->addDefaultChildrenIfNoneSet('foo')
|
||||
->prototype('array')
|
||||
;
|
||||
$node->getNode();
|
||||
}
|
||||
|
||||
public function testPrototypedArrayNodeDefaultWhenUsingDefaultChildren()
|
||||
{
|
||||
$node = new ArrayNodeDefinition('root');
|
||||
$node
|
||||
->addDefaultChildrenIfNoneSet()
|
||||
->prototype('array')
|
||||
;
|
||||
$tree = $node->getNode();
|
||||
$this->assertEquals(array(array()), $tree->getDefaultValue());
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providePrototypedArrayNodeDefaults
|
||||
*/
|
||||
public function testPrototypedArrayNodeDefault($args, $shouldThrowWhenUsingAttrAsKey, $shouldThrowWhenNotUsingAttrAsKey, $defaults)
|
||||
{
|
||||
$node = new ArrayNodeDefinition('root');
|
||||
$node
|
||||
->addDefaultChildrenIfNoneSet($args)
|
||||
->prototype('array')
|
||||
;
|
||||
|
||||
try {
|
||||
$tree = $node->getNode();
|
||||
$this->assertFalse($shouldThrowWhenNotUsingAttrAsKey);
|
||||
$this->assertEquals($defaults, $tree->getDefaultValue());
|
||||
} catch (InvalidDefinitionException $e) {
|
||||
$this->assertTrue($shouldThrowWhenNotUsingAttrAsKey);
|
||||
}
|
||||
|
||||
$node = new ArrayNodeDefinition('root');
|
||||
$node
|
||||
->useAttributeAsKey('attr')
|
||||
->addDefaultChildrenIfNoneSet($args)
|
||||
->prototype('array')
|
||||
;
|
||||
|
||||
try {
|
||||
$tree = $node->getNode();
|
||||
$this->assertFalse($shouldThrowWhenUsingAttrAsKey);
|
||||
$this->assertEquals($defaults, $tree->getDefaultValue());
|
||||
} catch (InvalidDefinitionException $e) {
|
||||
$this->assertTrue($shouldThrowWhenUsingAttrAsKey);
|
||||
}
|
||||
}
|
||||
|
||||
public function providePrototypedArrayNodeDefaults()
|
||||
{
|
||||
return array(
|
||||
array(null, true, false, array(array())),
|
||||
array(2, true, false, array(array(), array())),
|
||||
array('2', false, true, array('2' => array())),
|
||||
array('foo', false, true, array('foo' => array())),
|
||||
array(array('foo'), false, true, array('foo' => array())),
|
||||
array(array('foo', 'bar'), false, true, array('foo' => array(), 'bar' => array())),
|
||||
);
|
||||
}
|
||||
|
||||
public function testNestedPrototypedArrayNodes()
|
||||
{
|
||||
$node = new ArrayNodeDefinition('root');
|
||||
$node
|
||||
->addDefaultChildrenIfNoneSet()
|
||||
->prototype('array')
|
||||
->prototype('array')
|
||||
;
|
||||
$node->getNode();
|
||||
}
|
||||
|
||||
protected function getField($object, $field)
|
||||
{
|
||||
$reflection = new \ReflectionProperty($object, $field);
|
||||
$reflection->setAccessible(true);
|
||||
|
||||
return $reflection->getValue($object);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace Symfony\Component\Config\Tests\Definition\Builder;
|
||||
|
||||
use Symfony\Component\Config\Definition\Builder\EnumNodeDefinition;
|
||||
|
||||
class EnumNodeDefinitionTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @expectedException \InvalidArgumentException
|
||||
* @expectedExceptionMessage ->values() must be called with at least two distinct values.
|
||||
*/
|
||||
public function testNoDistinctValues()
|
||||
{
|
||||
$def = new EnumNodeDefinition('foo');
|
||||
$def->values(array('foo', 'foo'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \RuntimeException
|
||||
* @expectedExceptionMessage You must call ->values() on enum nodes.
|
||||
*/
|
||||
public function testNoValuesPassed()
|
||||
{
|
||||
$def = new EnumNodeDefinition('foo');
|
||||
$def->getNode();
|
||||
}
|
||||
|
||||
public function testGetNode()
|
||||
{
|
||||
$def = new EnumNodeDefinition('foo');
|
||||
$def->values(array('foo', 'bar'));
|
||||
|
||||
$node = $def->getNode();
|
||||
$this->assertEquals(array('foo', 'bar'), $node->getValues());
|
||||
}
|
||||
}
|
||||
211
core/vendor/symfony/config/Symfony/Component/Config/Tests/Definition/Builder/ExprBuilderTest.php
vendored
Normal file
211
core/vendor/symfony/config/Symfony/Component/Config/Tests/Definition/Builder/ExprBuilderTest.php
vendored
Normal file
@@ -0,0 +1,211 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Config\Tests\Definition\Builder;
|
||||
|
||||
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
|
||||
|
||||
class ExprBuilderTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
|
||||
public function testAlwaysExpression()
|
||||
{
|
||||
$test = $this->getTestBuilder()
|
||||
->always($this->returnClosure('new_value'))
|
||||
->end();
|
||||
|
||||
$this->assertFinalizedValueIs('new_value', $test);
|
||||
}
|
||||
|
||||
public function testIfTrueExpression()
|
||||
{
|
||||
$test = $this->getTestBuilder()
|
||||
->ifTrue()
|
||||
->then($this->returnClosure('new_value'))
|
||||
->end();
|
||||
$this->assertFinalizedValueIs('new_value', $test, array('key'=>true));
|
||||
|
||||
$test = $this->getTestBuilder()
|
||||
->ifTrue( function($v){ return true; })
|
||||
->then($this->returnClosure('new_value'))
|
||||
->end();
|
||||
$this->assertFinalizedValueIs('new_value', $test);
|
||||
|
||||
$test = $this->getTestBuilder()
|
||||
->ifTrue( function($v){ return false; })
|
||||
->then($this->returnClosure('new_value'))
|
||||
->end();
|
||||
$this->assertFinalizedValueIs('value',$test);
|
||||
}
|
||||
|
||||
public function testIfStringExpression()
|
||||
{
|
||||
$test = $this->getTestBuilder()
|
||||
->ifString()
|
||||
->then($this->returnClosure('new_value'))
|
||||
->end();
|
||||
$this->assertFinalizedValueIs('new_value', $test);
|
||||
|
||||
$test = $this->getTestBuilder()
|
||||
->ifString()
|
||||
->then($this->returnClosure('new_value'))
|
||||
->end();
|
||||
$this->assertFinalizedValueIs(45, $test, array('key'=>45));
|
||||
|
||||
}
|
||||
|
||||
public function testIfNullExpression()
|
||||
{
|
||||
$test = $this->getTestBuilder()
|
||||
->ifNull()
|
||||
->then($this->returnClosure('new_value'))
|
||||
->end();
|
||||
$this->assertFinalizedValueIs('new_value', $test, array('key'=>null));
|
||||
|
||||
$test = $this->getTestBuilder()
|
||||
->ifNull()
|
||||
->then($this->returnClosure('new_value'))
|
||||
->end();
|
||||
$this->assertFinalizedValueIs('value', $test);
|
||||
}
|
||||
|
||||
public function testIfArrayExpression()
|
||||
{
|
||||
$test = $this->getTestBuilder()
|
||||
->ifArray()
|
||||
->then($this->returnClosure('new_value'))
|
||||
->end();
|
||||
$this->assertFinalizedValueIs('new_value', $test, array('key'=>array()));
|
||||
|
||||
$test = $this->getTestBuilder()
|
||||
->ifArray()
|
||||
->then($this->returnClosure('new_value'))
|
||||
->end();
|
||||
$this->assertFinalizedValueIs('value', $test);
|
||||
}
|
||||
|
||||
public function testIfInArrayExpression()
|
||||
{
|
||||
$test = $this->getTestBuilder()
|
||||
->ifInArray(array('foo', 'bar', 'value'))
|
||||
->then($this->returnClosure('new_value'))
|
||||
->end();
|
||||
$this->assertFinalizedValueIs('new_value', $test);
|
||||
|
||||
$test = $this->getTestBuilder()
|
||||
->ifInArray(array('foo', 'bar'))
|
||||
->then($this->returnClosure('new_value'))
|
||||
->end();
|
||||
$this->assertFinalizedValueIs('value', $test);
|
||||
}
|
||||
|
||||
public function testIfNotInArrayExpression()
|
||||
{
|
||||
$test = $this->getTestBuilder()
|
||||
->ifNotInArray(array('foo', 'bar'))
|
||||
->then($this->returnClosure('new_value'))
|
||||
->end();
|
||||
$this->assertFinalizedValueIs('new_value', $test);
|
||||
|
||||
$test = $this->getTestBuilder()
|
||||
->ifNotInArray(array('foo', 'bar', 'value_from_config' ))
|
||||
->then($this->returnClosure('new_value'))
|
||||
->end();
|
||||
$this->assertFinalizedValueIs('new_value', $test);
|
||||
}
|
||||
|
||||
public function testThenEmptyArrayExpression()
|
||||
{
|
||||
$test = $this->getTestBuilder()
|
||||
->ifString()
|
||||
->thenEmptyArray()
|
||||
->end();
|
||||
$this->assertFinalizedValueIs(array(), $test);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException Symfony\Component\Config\Definition\Exception\InvalidConfigurationException
|
||||
*/
|
||||
public function testThenInvalid()
|
||||
{
|
||||
$test = $this->getTestBuilder()
|
||||
->ifString()
|
||||
->thenInvalid('Invalid value')
|
||||
->end();
|
||||
$this->finalizeTestBuilder($test);
|
||||
}
|
||||
|
||||
public function testThenUnsetExpression()
|
||||
{
|
||||
$test = $this->getTestBuilder()
|
||||
->ifString()
|
||||
->thenUnset()
|
||||
->end();
|
||||
$this->assertEquals(array(), $this->finalizeTestBuilder($test));
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a test treebuilder with a variable node, and init the validation
|
||||
* @return TreeBuilder
|
||||
*/
|
||||
protected function getTestBuilder()
|
||||
{
|
||||
$builder = new TreeBuilder();
|
||||
|
||||
return $builder
|
||||
->root('test')
|
||||
->children()
|
||||
->variableNode('key')
|
||||
->validate()
|
||||
;
|
||||
}
|
||||
|
||||
/**
|
||||
* Close the validation process and finalize with the given config
|
||||
* @param TreeBuilder $testBuilder The tree builder to finalize
|
||||
* @param array $config The config you want to use for the finalization, if nothing provided
|
||||
* a simple array('key'=>'value') will be used
|
||||
* @return array The finalized config values
|
||||
*/
|
||||
protected function finalizeTestBuilder($testBuilder, $config=null)
|
||||
{
|
||||
return $testBuilder
|
||||
->end()
|
||||
->end()
|
||||
->end()
|
||||
->buildTree()
|
||||
->finalize($config === null ? array('key'=>'value') : $config)
|
||||
;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a closure that will return the given value
|
||||
* @param $val The value that the closure must return
|
||||
* @return Closure
|
||||
*/
|
||||
protected function returnClosure($val)
|
||||
{
|
||||
return function($v) use ($val) {
|
||||
return $val;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Assert that the given test builder, will return the given value
|
||||
* @param mixed $value The value to test
|
||||
* @param TreeBuilder $treeBuilder The tree builder to finalize
|
||||
* @param mixed $config The config values that new to be finalized
|
||||
*/
|
||||
protected function assertFinalizedValueIs($value, $treeBuilder, $config=null)
|
||||
{
|
||||
$this->assertEquals(array('key'=>$value), $this->finalizeTestBuilder($treeBuilder, $config));
|
||||
}
|
||||
}
|
||||
83
core/vendor/symfony/config/Symfony/Component/Config/Tests/Definition/Builder/NodeBuilderTest.php
vendored
Normal file
83
core/vendor/symfony/config/Symfony/Component/Config/Tests/Definition/Builder/NodeBuilderTest.php
vendored
Normal file
@@ -0,0 +1,83 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Config\Tests\Definition\Builder;
|
||||
|
||||
use Symfony\Component\Config\Definition\Builder\NodeBuilder as BaseNodeBuilder;
|
||||
use Symfony\Component\Config\Definition\Builder\VariableNodeDefinition as BaseVariableNodeDefinition;
|
||||
|
||||
class NodeBuilderTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @expectedException \RuntimeException
|
||||
*/
|
||||
public function testThrowsAnExceptionWhenTryingToCreateANonRegisteredNodeType()
|
||||
{
|
||||
$builder = new BaseNodeBuilder();
|
||||
$builder->node('', 'foobar');
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \RuntimeException
|
||||
*/
|
||||
public function testThrowsAnExceptionWhenTheNodeClassIsNotFound()
|
||||
{
|
||||
$builder = new BaseNodeBuilder();
|
||||
$builder
|
||||
->setNodeClass('noclasstype', '\\foo\\bar\\noclass')
|
||||
->node('', 'noclasstype');
|
||||
}
|
||||
|
||||
public function testAddingANewNodeType()
|
||||
{
|
||||
$class = __NAMESPACE__.'\\SomeNodeDefinition';
|
||||
|
||||
$builder = new BaseNodeBuilder();
|
||||
$node = $builder
|
||||
->setNodeClass('newtype', $class)
|
||||
->node('', 'newtype');
|
||||
|
||||
$this->assertEquals(get_class($node), $class);
|
||||
}
|
||||
|
||||
public function testOverridingAnExistingNodeType()
|
||||
{
|
||||
$class = __NAMESPACE__.'\\SomeNodeDefinition';
|
||||
|
||||
$builder = new BaseNodeBuilder();
|
||||
$node = $builder
|
||||
->setNodeClass('variable', $class)
|
||||
->node('', 'variable');
|
||||
|
||||
$this->assertEquals(get_class($node), $class);
|
||||
}
|
||||
|
||||
public function testNodeTypesAreNotCaseSensitive()
|
||||
{
|
||||
$builder = new BaseNodeBuilder();
|
||||
|
||||
$node1 = $builder->node('', 'VaRiAbLe');
|
||||
$node2 = $builder->node('', 'variable');
|
||||
|
||||
$this->assertEquals(get_class($node1), get_class($node2));
|
||||
|
||||
$builder->setNodeClass('CuStOm', __NAMESPACE__.'\\SomeNodeDefinition');
|
||||
|
||||
$node1 = $builder->node('', 'CUSTOM');
|
||||
$node2 = $builder->node('', 'custom');
|
||||
|
||||
$this->assertEquals(get_class($node1), get_class($node2));
|
||||
}
|
||||
}
|
||||
|
||||
class SomeNodeDefinition extends BaseVariableNodeDefinition
|
||||
{
|
||||
}
|
||||
127
core/vendor/symfony/config/Symfony/Component/Config/Tests/Definition/Builder/TreeBuilderTest.php
vendored
Normal file
127
core/vendor/symfony/config/Symfony/Component/Config/Tests/Definition/Builder/TreeBuilderTest.php
vendored
Normal file
@@ -0,0 +1,127 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Config\Tests\Definition\Builder;
|
||||
|
||||
use Symfony\Component\Config\Tests\Definition\Builder\NodeBuilder as CustomNodeBuilder;
|
||||
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
|
||||
use Symfony\Component\Config\Definition\Builder\NodeBuilder;
|
||||
|
||||
require __DIR__.'/../../Fixtures/Builder/NodeBuilder.php';
|
||||
require __DIR__.'/../../Fixtures/Builder/BarNodeDefinition.php';
|
||||
require __DIR__.'/../../Fixtures/Builder/VariableNodeDefinition.php';
|
||||
|
||||
class TreeBuilderTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testUsingACustomNodeBuilder()
|
||||
{
|
||||
$builder = new TreeBuilder();
|
||||
$root = $builder->root('custom', 'array', new CustomNodeBuilder());
|
||||
|
||||
$nodeBuilder = $root->children();
|
||||
|
||||
$this->assertEquals(get_class($nodeBuilder), 'Symfony\Component\Config\Tests\Definition\Builder\NodeBuilder');
|
||||
|
||||
$nodeBuilder = $nodeBuilder->arrayNode('deeper')->children();
|
||||
|
||||
$this->assertEquals(get_class($nodeBuilder), 'Symfony\Component\Config\Tests\Definition\Builder\NodeBuilder');
|
||||
}
|
||||
|
||||
public function testOverrideABuiltInNodeType()
|
||||
{
|
||||
$builder = new TreeBuilder();
|
||||
$root = $builder->root('override', 'array', new CustomNodeBuilder());
|
||||
|
||||
$definition = $root->children()->variableNode('variable');
|
||||
|
||||
$this->assertEquals(get_class($definition), 'Symfony\Component\Config\Tests\Definition\Builder\VariableNodeDefinition');
|
||||
}
|
||||
|
||||
public function testAddANodeType()
|
||||
{
|
||||
$builder = new TreeBuilder();
|
||||
$root = $builder->root('override', 'array', new CustomNodeBuilder());
|
||||
|
||||
$definition = $root->children()->barNode('variable');
|
||||
|
||||
$this->assertEquals(get_class($definition), 'Symfony\Component\Config\Tests\Definition\Builder\BarNodeDefinition');
|
||||
}
|
||||
|
||||
public function testCreateABuiltInNodeTypeWithACustomNodeBuilder()
|
||||
{
|
||||
$builder = new TreeBuilder();
|
||||
$root = $builder->root('builtin', 'array', new CustomNodeBuilder());
|
||||
|
||||
$definition = $root->children()->booleanNode('boolean');
|
||||
|
||||
$this->assertEquals(get_class($definition), 'Symfony\Component\Config\Definition\Builder\BooleanNodeDefinition');
|
||||
}
|
||||
|
||||
public function testPrototypedArrayNodeUseTheCustomNodeBuilder()
|
||||
{
|
||||
$builder = new TreeBuilder();
|
||||
$root = $builder->root('override', 'array', new CustomNodeBuilder());
|
||||
|
||||
$root->prototype('bar')->end();
|
||||
}
|
||||
|
||||
public function testAnExtendedNodeBuilderGetsPropagatedToTheChildren()
|
||||
{
|
||||
$builder = new TreeBuilder();
|
||||
|
||||
$builder->root('propagation')
|
||||
->children()
|
||||
->setNodeClass('extended', 'Symfony\Component\Config\Tests\Definition\Builder\VariableNodeDefinition')
|
||||
->node('foo', 'extended')->end()
|
||||
->arrayNode('child')
|
||||
->children()
|
||||
->node('foo', 'extended')
|
||||
->end()
|
||||
->end()
|
||||
->end()
|
||||
->end();
|
||||
}
|
||||
|
||||
public function testDefinitionInfoGetsTransferredToNode()
|
||||
{
|
||||
$builder = new TreeBuilder();
|
||||
|
||||
$builder->root('test')->info('root info')
|
||||
->children()
|
||||
->node('child', 'variable')->info('child info')->defaultValue('default')
|
||||
->end()
|
||||
->end();
|
||||
|
||||
$tree = $builder->buildTree();
|
||||
$children = $tree->getChildren();
|
||||
|
||||
$this->assertEquals('root info', $tree->getInfo());
|
||||
$this->assertEquals('child info', $children['child']->getInfo());
|
||||
}
|
||||
|
||||
public function testDefinitionExampleGetsTransferredToNode()
|
||||
{
|
||||
$builder = new TreeBuilder();
|
||||
|
||||
$builder->root('test')
|
||||
->example(array('key' => 'value'))
|
||||
->children()
|
||||
->node('child', 'variable')->info('child info')->defaultValue('default')->example('example')
|
||||
->end()
|
||||
->end();
|
||||
|
||||
$tree = $builder->buildTree();
|
||||
$children = $tree->getChildren();
|
||||
|
||||
$this->assertTrue(is_array($tree->getExample()));
|
||||
$this->assertEquals('example', $children['child']->getExample());
|
||||
}
|
||||
}
|
||||
41
core/vendor/symfony/config/Symfony/Component/Config/Tests/Definition/EnumNodeTest.php
vendored
Normal file
41
core/vendor/symfony/config/Symfony/Component/Config/Tests/Definition/EnumNodeTest.php
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Config\Tests\Definition;
|
||||
|
||||
use Symfony\Component\Config\Definition\EnumNode;
|
||||
|
||||
class EnumNodeTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testFinalizeValue()
|
||||
{
|
||||
$node = new EnumNode('foo', null, array('foo', 'bar'));
|
||||
$this->assertSame('foo', $node->finalize('foo'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \InvalidArgumentException
|
||||
*/
|
||||
public function testConstructionWithOneValue()
|
||||
{
|
||||
new EnumNode('foo', null, array('foo', 'foo'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException Symfony\Component\Config\Definition\Exception\InvalidConfigurationException
|
||||
* @expectedExceptionMessage The value "foobar" is not allowed for path "foo". Permissible values: "foo", "bar"
|
||||
*/
|
||||
public function testFinalizeWithInvalidValue()
|
||||
{
|
||||
$node = new EnumNode('foo', null, array('foo', 'bar'));
|
||||
$node->finalize('foobar');
|
||||
}
|
||||
}
|
||||
73
core/vendor/symfony/config/Symfony/Component/Config/Tests/Definition/FinalizationTest.php
vendored
Normal file
73
core/vendor/symfony/config/Symfony/Component/Config/Tests/Definition/FinalizationTest.php
vendored
Normal file
@@ -0,0 +1,73 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Config\Tests\Definition;
|
||||
|
||||
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
|
||||
use Symfony\Component\Config\Definition\Processor;
|
||||
use Symfony\Component\Config\Definition\NodeInterface;
|
||||
|
||||
class FinalizationTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testUnsetKeyWithDeepHierarchy()
|
||||
{
|
||||
$tb = new TreeBuilder();
|
||||
$tree = $tb
|
||||
->root('config', 'array')
|
||||
->children()
|
||||
->node('level1', 'array')
|
||||
->canBeUnset()
|
||||
->children()
|
||||
->node('level2', 'array')
|
||||
->canBeUnset()
|
||||
->children()
|
||||
->node('somevalue', 'scalar')->end()
|
||||
->node('anothervalue', 'scalar')->end()
|
||||
->end()
|
||||
->end()
|
||||
->node('level1_scalar', 'scalar')->end()
|
||||
->end()
|
||||
->end()
|
||||
->end()
|
||||
->end()
|
||||
->buildTree()
|
||||
;
|
||||
|
||||
$a = array(
|
||||
'level1' => array(
|
||||
'level2' => array(
|
||||
'somevalue' => 'foo',
|
||||
'anothervalue' => 'bar',
|
||||
),
|
||||
'level1_scalar' => 'foo',
|
||||
),
|
||||
);
|
||||
|
||||
$b = array(
|
||||
'level1' => array(
|
||||
'level2' => false,
|
||||
),
|
||||
);
|
||||
|
||||
$this->assertEquals(array(
|
||||
'level1' => array(
|
||||
'level1_scalar' => 'foo',
|
||||
),
|
||||
), $this->process($tree, array($a, $b)));
|
||||
}
|
||||
|
||||
protected function process(NodeInterface $tree, array $configs)
|
||||
{
|
||||
$processor = new Processor();
|
||||
|
||||
return $processor->process($tree, $configs);
|
||||
}
|
||||
}
|
||||
195
core/vendor/symfony/config/Symfony/Component/Config/Tests/Definition/MergeTest.php
vendored
Normal file
195
core/vendor/symfony/config/Symfony/Component/Config/Tests/Definition/MergeTest.php
vendored
Normal file
@@ -0,0 +1,195 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Config\Tests\Definition;
|
||||
|
||||
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
|
||||
|
||||
class MergeTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @expectedException Symfony\Component\Config\Definition\Exception\ForbiddenOverwriteException
|
||||
*/
|
||||
public function testForbiddenOverwrite()
|
||||
{
|
||||
$tb = new TreeBuilder();
|
||||
$tree = $tb
|
||||
->root('root', 'array')
|
||||
->children()
|
||||
->node('foo', 'scalar')
|
||||
->cannotBeOverwritten()
|
||||
->end()
|
||||
->end()
|
||||
->end()
|
||||
->buildTree()
|
||||
;
|
||||
|
||||
$a = array(
|
||||
'foo' => 'bar',
|
||||
);
|
||||
|
||||
$b = array(
|
||||
'foo' => 'moo',
|
||||
);
|
||||
|
||||
$tree->merge($a, $b);
|
||||
}
|
||||
|
||||
public function testUnsetKey()
|
||||
{
|
||||
$tb = new TreeBuilder();
|
||||
$tree = $tb
|
||||
->root('root', 'array')
|
||||
->children()
|
||||
->node('foo', 'scalar')->end()
|
||||
->node('bar', 'scalar')->end()
|
||||
->node('unsettable', 'array')
|
||||
->canBeUnset()
|
||||
->children()
|
||||
->node('foo', 'scalar')->end()
|
||||
->node('bar', 'scalar')->end()
|
||||
->end()
|
||||
->end()
|
||||
->node('unsetted', 'array')
|
||||
->canBeUnset()
|
||||
->prototype('scalar')->end()
|
||||
->end()
|
||||
->end()
|
||||
->end()
|
||||
->buildTree()
|
||||
;
|
||||
|
||||
$a = array(
|
||||
'foo' => 'bar',
|
||||
'unsettable' => array(
|
||||
'foo' => 'a',
|
||||
'bar' => 'b',
|
||||
),
|
||||
'unsetted' => false,
|
||||
);
|
||||
|
||||
$b = array(
|
||||
'foo' => 'moo',
|
||||
'bar' => 'b',
|
||||
'unsettable' => false,
|
||||
'unsetted' => array('a', 'b'),
|
||||
);
|
||||
|
||||
$this->assertEquals(array(
|
||||
'foo' => 'moo',
|
||||
'bar' => 'b',
|
||||
'unsettable' => false,
|
||||
'unsetted' => array('a', 'b'),
|
||||
), $tree->merge($a, $b));
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException Symfony\Component\Config\Definition\Exception\InvalidConfigurationException
|
||||
*/
|
||||
public function testDoesNotAllowNewKeysInSubsequentConfigs()
|
||||
{
|
||||
$tb = new TreeBuilder();
|
||||
$tree = $tb
|
||||
->root('config', 'array')
|
||||
->children()
|
||||
->node('test', 'array')
|
||||
->disallowNewKeysInSubsequentConfigs()
|
||||
->useAttributeAsKey('key')
|
||||
->prototype('array')
|
||||
->children()
|
||||
->node('value', 'scalar')->end()
|
||||
->end()
|
||||
->end()
|
||||
->end()
|
||||
->end()
|
||||
->end()
|
||||
->buildTree();
|
||||
|
||||
$a = array(
|
||||
'test' => array(
|
||||
'a' => array('value' => 'foo')
|
||||
)
|
||||
);
|
||||
|
||||
$b = array(
|
||||
'test' => array(
|
||||
'b' => array('value' => 'foo')
|
||||
)
|
||||
);
|
||||
|
||||
$tree->merge($a, $b);
|
||||
}
|
||||
|
||||
public function testPerformsNoDeepMerging()
|
||||
{
|
||||
$tb = new TreeBuilder();
|
||||
|
||||
$tree = $tb
|
||||
->root('config', 'array')
|
||||
->children()
|
||||
->node('no_deep_merging', 'array')
|
||||
->performNoDeepMerging()
|
||||
->children()
|
||||
->node('foo', 'scalar')->end()
|
||||
->node('bar', 'scalar')->end()
|
||||
->end()
|
||||
->end()
|
||||
->end()
|
||||
->end()
|
||||
->buildTree()
|
||||
;
|
||||
|
||||
$a = array(
|
||||
'no_deep_merging' => array(
|
||||
'foo' => 'a',
|
||||
'bar' => 'b',
|
||||
),
|
||||
);
|
||||
|
||||
$b = array(
|
||||
'no_deep_merging' => array(
|
||||
'c' => 'd',
|
||||
)
|
||||
);
|
||||
|
||||
$this->assertEquals(array(
|
||||
'no_deep_merging' => array(
|
||||
'c' => 'd',
|
||||
)
|
||||
), $tree->merge($a, $b));
|
||||
}
|
||||
|
||||
public function testPrototypeWithoutAKeyAttribute()
|
||||
{
|
||||
$tb = new TreeBuilder();
|
||||
|
||||
$tree = $tb
|
||||
->root('config', 'array')
|
||||
->children()
|
||||
->arrayNode('append_elements')
|
||||
->prototype('scalar')->end()
|
||||
->end()
|
||||
->end()
|
||||
->end()
|
||||
->buildTree()
|
||||
;
|
||||
|
||||
$a = array(
|
||||
'append_elements' => array('a', 'b'),
|
||||
);
|
||||
|
||||
$b = array(
|
||||
'append_elements' => array('c', 'd'),
|
||||
);
|
||||
|
||||
$this->assertEquals(array('append_elements' => array('a', 'b', 'c', 'd')), $tree->merge($a, $b));
|
||||
}
|
||||
}
|
||||
210
core/vendor/symfony/config/Symfony/Component/Config/Tests/Definition/NormalizationTest.php
vendored
Normal file
210
core/vendor/symfony/config/Symfony/Component/Config/Tests/Definition/NormalizationTest.php
vendored
Normal file
@@ -0,0 +1,210 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Config\Tests\Definition;
|
||||
|
||||
use Symfony\Component\Config\Definition\NodeInterface;
|
||||
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
|
||||
|
||||
class NormalizerTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @dataProvider getEncoderTests
|
||||
*/
|
||||
public function testNormalizeEncoders($denormalized)
|
||||
{
|
||||
$tb = new TreeBuilder();
|
||||
$tree = $tb
|
||||
->root('root_name', 'array')
|
||||
->fixXmlConfig('encoder')
|
||||
->children()
|
||||
->node('encoders', 'array')
|
||||
->useAttributeAsKey('class')
|
||||
->prototype('array')
|
||||
->beforeNormalization()->ifString()->then(function($v) { return array('algorithm' => $v); })->end()
|
||||
->children()
|
||||
->node('algorithm', 'scalar')->end()
|
||||
->end()
|
||||
->end()
|
||||
->end()
|
||||
->end()
|
||||
->end()
|
||||
->buildTree()
|
||||
;
|
||||
|
||||
$normalized = array(
|
||||
'encoders' => array(
|
||||
'foo' => array('algorithm' => 'plaintext'),
|
||||
),
|
||||
);
|
||||
|
||||
$this->assertNormalized($tree, $denormalized, $normalized);
|
||||
}
|
||||
|
||||
public function getEncoderTests()
|
||||
{
|
||||
$configs = array();
|
||||
|
||||
// XML
|
||||
$configs[] = array(
|
||||
'encoder' => array(
|
||||
array('class' => 'foo', 'algorithm' => 'plaintext'),
|
||||
),
|
||||
);
|
||||
|
||||
// XML when only one element of this type
|
||||
$configs[] = array(
|
||||
'encoder' => array('class' => 'foo', 'algorithm' => 'plaintext'),
|
||||
);
|
||||
|
||||
// YAML/PHP
|
||||
$configs[] = array(
|
||||
'encoders' => array(
|
||||
array('class' => 'foo', 'algorithm' => 'plaintext'),
|
||||
),
|
||||
);
|
||||
|
||||
// YAML/PHP
|
||||
$configs[] = array(
|
||||
'encoders' => array(
|
||||
'foo' => 'plaintext',
|
||||
),
|
||||
);
|
||||
|
||||
// YAML/PHP
|
||||
$configs[] = array(
|
||||
'encoders' => array(
|
||||
'foo' => array('algorithm' => 'plaintext'),
|
||||
),
|
||||
);
|
||||
|
||||
return array_map(function($v) {
|
||||
return array($v);
|
||||
}, $configs);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getAnonymousKeysTests
|
||||
*/
|
||||
public function testAnonymousKeysArray($denormalized)
|
||||
{
|
||||
$tb = new TreeBuilder();
|
||||
$tree = $tb
|
||||
->root('root', 'array')
|
||||
->children()
|
||||
->node('logout', 'array')
|
||||
->fixXmlConfig('handler')
|
||||
->children()
|
||||
->node('handlers', 'array')
|
||||
->prototype('scalar')->end()
|
||||
->end()
|
||||
->end()
|
||||
->end()
|
||||
->end()
|
||||
->end()
|
||||
->buildTree()
|
||||
;
|
||||
|
||||
$normalized = array('logout' => array('handlers' => array('a', 'b', 'c')));
|
||||
|
||||
$this->assertNormalized($tree, $denormalized, $normalized);
|
||||
}
|
||||
|
||||
public function getAnonymousKeysTests()
|
||||
{
|
||||
$configs = array();
|
||||
|
||||
$configs[] = array(
|
||||
'logout' => array(
|
||||
'handlers' => array('a', 'b', 'c'),
|
||||
),
|
||||
);
|
||||
|
||||
$configs[] = array(
|
||||
'logout' => array(
|
||||
'handler' => array('a', 'b', 'c'),
|
||||
),
|
||||
);
|
||||
|
||||
return array_map(function($v) { return array($v); }, $configs);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getNumericKeysTests
|
||||
*/
|
||||
public function testNumericKeysAsAttributes($denormalized)
|
||||
{
|
||||
$normalized = array(
|
||||
'thing' => array(42 => array('foo', 'bar'), 1337 => array('baz', 'qux')),
|
||||
);
|
||||
|
||||
$this->assertNormalized($this->getNumericKeysTestTree(), $denormalized, $normalized);
|
||||
}
|
||||
|
||||
public function getNumericKeysTests()
|
||||
{
|
||||
$configs = array();
|
||||
|
||||
$configs[] = array(
|
||||
'thing' => array(
|
||||
42 => array('foo', 'bar'), 1337 => array('baz', 'qux'),
|
||||
),
|
||||
);
|
||||
|
||||
$configs[] = array(
|
||||
'thing' => array(
|
||||
array('foo', 'bar', 'id' => 42), array('baz', 'qux', 'id' => 1337),
|
||||
),
|
||||
);
|
||||
|
||||
return array_map(function($v) { return array($v); }, $configs);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException Symfony\Component\Config\Definition\Exception\InvalidConfigurationException
|
||||
* @expectedExceptionMessage The attribute "id" must be set for path "root.thing".
|
||||
*/
|
||||
public function testNonAssociativeArrayThrowsExceptionIfAttributeNotSet()
|
||||
{
|
||||
$denormalized = array(
|
||||
'thing' => array(
|
||||
array('foo', 'bar'), array('baz', 'qux')
|
||||
)
|
||||
);
|
||||
|
||||
$this->assertNormalized($this->getNumericKeysTestTree(), $denormalized, array());
|
||||
}
|
||||
|
||||
public static function assertNormalized(NodeInterface $tree, $denormalized, $normalized)
|
||||
{
|
||||
self::assertSame($normalized, $tree->normalize($denormalized));
|
||||
}
|
||||
|
||||
private function getNumericKeysTestTree()
|
||||
{
|
||||
$tb = new TreeBuilder();
|
||||
$tree = $tb
|
||||
->root('root', 'array')
|
||||
->children()
|
||||
->node('thing', 'array')
|
||||
->useAttributeAsKey('id')
|
||||
->prototype('array')
|
||||
->prototype('scalar')->end()
|
||||
->end()
|
||||
->end()
|
||||
->end()
|
||||
->end()
|
||||
->buildTree()
|
||||
;
|
||||
|
||||
return $tree;
|
||||
}
|
||||
}
|
||||
51
core/vendor/symfony/config/Symfony/Component/Config/Tests/Definition/ProcessorTest.php
vendored
Normal file
51
core/vendor/symfony/config/Symfony/Component/Config/Tests/Definition/ProcessorTest.php
vendored
Normal file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Config\Tests\Definition;
|
||||
|
||||
use Symfony\Component\Config\Definition\Processor;
|
||||
|
||||
class ProcessorTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @dataProvider getKeyNormalizationTests
|
||||
*/
|
||||
public function testNormalizeKeys($denormalized, $normalized)
|
||||
{
|
||||
$this->assertSame($normalized, Processor::normalizeKeys($denormalized));
|
||||
}
|
||||
|
||||
public function getKeyNormalizationTests()
|
||||
{
|
||||
return array(
|
||||
array(
|
||||
array('foo-bar' => 'foo'),
|
||||
array('foo_bar' => 'foo'),
|
||||
),
|
||||
array(
|
||||
array('foo-bar_moo' => 'foo'),
|
||||
array('foo-bar_moo' => 'foo'),
|
||||
),
|
||||
array(
|
||||
array('foo-bar' => null, 'foo_bar' => 'foo'),
|
||||
array('foo-bar' => null, 'foo_bar' => 'foo'),
|
||||
),
|
||||
array(
|
||||
array('foo-bar' => array('foo-bar' => 'foo')),
|
||||
array('foo_bar' => array('foo_bar' => 'foo')),
|
||||
),
|
||||
array(
|
||||
array('foo_bar' => array('foo-bar' => 'foo')),
|
||||
array('foo_bar' => array('foo_bar' => 'foo')),
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
181
core/vendor/symfony/config/Symfony/Component/Config/Tests/Definition/PrototypedArrayNodeTest.php
vendored
Normal file
181
core/vendor/symfony/config/Symfony/Component/Config/Tests/Definition/PrototypedArrayNodeTest.php
vendored
Normal file
@@ -0,0 +1,181 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Config\Tests\Definition;
|
||||
|
||||
use Symfony\Component\Config\Definition\PrototypedArrayNode;
|
||||
use Symfony\Component\Config\Definition\ArrayNode;
|
||||
use Symfony\Component\Config\Definition\ScalarNode;
|
||||
|
||||
class PrototypedArrayNodeTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
|
||||
public function testGetDefaultValueReturnsAnEmptyArrayForPrototypes()
|
||||
{
|
||||
$node = new PrototypedArrayNode('root');
|
||||
$prototype = new ArrayNode(null, $node);
|
||||
$node->setPrototype($prototype);
|
||||
$this->assertEmpty($node->getDefaultValue());
|
||||
}
|
||||
|
||||
public function testGetDefaultValueReturnsDefaultValueForPrototypes()
|
||||
{
|
||||
$node = new PrototypedArrayNode('root');
|
||||
$prototype = new ArrayNode(null, $node);
|
||||
$node->setPrototype($prototype);
|
||||
$node->setDefaultValue(array ('test'));
|
||||
$this->assertEquals(array ('test'), $node->getDefaultValue());
|
||||
}
|
||||
|
||||
// a remapped key (e.g. "mapping" -> "mappings") should be unset after being used
|
||||
public function testRemappedKeysAreUnset()
|
||||
{
|
||||
$node = new ArrayNode('root');
|
||||
$mappingsNode = new PrototypedArrayNode('mappings');
|
||||
$node->addChild($mappingsNode);
|
||||
|
||||
// each item under mappings is just a scalar
|
||||
$prototype = new ScalarNode(null, $mappingsNode);
|
||||
$mappingsNode->setPrototype($prototype);
|
||||
|
||||
$remappings = array();
|
||||
$remappings[] = array('mapping', 'mappings');
|
||||
$node->setXmlRemappings($remappings);
|
||||
|
||||
$normalized = $node->normalize(array('mapping' => array('foo', 'bar')));
|
||||
$this->assertEquals(array('mappings' => array('foo', 'bar')), $normalized);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests that when a key attribute is mapped, that key is removed from the array:
|
||||
*
|
||||
* <things>
|
||||
* <option id="option1" value="foo">
|
||||
* <option id="option2" value="bar">
|
||||
* </things>
|
||||
*
|
||||
* The above should finally be mapped to an array that looks like this
|
||||
* (because "id" is the key attribute).
|
||||
*
|
||||
* array(
|
||||
* 'things' => array(
|
||||
* 'option1' => 'foo',
|
||||
* 'option2' => 'bar',
|
||||
* )
|
||||
* )
|
||||
*/
|
||||
public function testMappedAttributeKeyIsRemoved()
|
||||
{
|
||||
$node = new PrototypedArrayNode('root');
|
||||
$node->setKeyAttribute('id', true);
|
||||
|
||||
// each item under the root is an array, with one scalar item
|
||||
$prototype = new ArrayNode(null, $node);
|
||||
$prototype->addChild(new ScalarNode('foo'));
|
||||
$node->setPrototype($prototype);
|
||||
|
||||
$children = array();
|
||||
$children[] = array('id' => 'item_name', 'foo' => 'bar');
|
||||
$normalized = $node->normalize($children);
|
||||
|
||||
$expected = array();
|
||||
$expected['item_name'] = array('foo' => 'bar');
|
||||
$this->assertEquals($expected, $normalized);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the opposite of the testMappedAttributeKeyIsRemoved because
|
||||
* the removal can be toggled with an option.
|
||||
*/
|
||||
public function testMappedAttributeKeyNotRemoved()
|
||||
{
|
||||
$node = new PrototypedArrayNode('root');
|
||||
$node->setKeyAttribute('id', false);
|
||||
|
||||
// each item under the root is an array, with two scalar items
|
||||
$prototype = new ArrayNode(null, $node);
|
||||
$prototype->addChild(new ScalarNode('foo'));
|
||||
$prototype->addChild(new ScalarNode('id')); // the key attribute will remain
|
||||
$node->setPrototype($prototype);
|
||||
|
||||
$children = array();
|
||||
$children[] = array('id' => 'item_name', 'foo' => 'bar');
|
||||
$normalized = $node->normalize($children);
|
||||
|
||||
$expected = array();
|
||||
$expected['item_name'] = array('id' => 'item_name', 'foo' => 'bar');
|
||||
$this->assertEquals($expected, $normalized);
|
||||
}
|
||||
|
||||
public function testAddDefaultChildren()
|
||||
{
|
||||
$node = $this->getPrototypeNodeWithDefaultChildren();
|
||||
$node->setAddChildrenIfNoneSet();
|
||||
$this->assertTrue($node->hasDefaultValue());
|
||||
$this->assertEquals(array(array('foo' => 'bar')), $node->getDefaultValue());
|
||||
|
||||
$node = $this->getPrototypeNodeWithDefaultChildren();
|
||||
$node->setKeyAttribute('foobar');
|
||||
$node->setAddChildrenIfNoneSet();
|
||||
$this->assertTrue($node->hasDefaultValue());
|
||||
$this->assertEquals(array('defaults' => array('foo' => 'bar')), $node->getDefaultValue());
|
||||
|
||||
$node = $this->getPrototypeNodeWithDefaultChildren();
|
||||
$node->setKeyAttribute('foobar');
|
||||
$node->setAddChildrenIfNoneSet('defaultkey');
|
||||
$this->assertTrue($node->hasDefaultValue());
|
||||
$this->assertEquals(array('defaultkey' => array('foo' => 'bar')), $node->getDefaultValue());
|
||||
|
||||
$node = $this->getPrototypeNodeWithDefaultChildren();
|
||||
$node->setKeyAttribute('foobar');
|
||||
$node->setAddChildrenIfNoneSet(array('defaultkey'));
|
||||
$this->assertTrue($node->hasDefaultValue());
|
||||
$this->assertEquals(array('defaultkey' => array('foo' => 'bar')), $node->getDefaultValue());
|
||||
|
||||
$node = $this->getPrototypeNodeWithDefaultChildren();
|
||||
$node->setKeyAttribute('foobar');
|
||||
$node->setAddChildrenIfNoneSet(array('dk1', 'dk2'));
|
||||
$this->assertTrue($node->hasDefaultValue());
|
||||
$this->assertEquals(array('dk1' => array('foo' => 'bar'), 'dk2' => array('foo' => 'bar')), $node->getDefaultValue());
|
||||
|
||||
$node = $this->getPrototypeNodeWithDefaultChildren();
|
||||
$node->setAddChildrenIfNoneSet(array(5, 6));
|
||||
$this->assertTrue($node->hasDefaultValue());
|
||||
$this->assertEquals(array(0 => array('foo' => 'bar'), 1 => array('foo' => 'bar')), $node->getDefaultValue());
|
||||
|
||||
$node = $this->getPrototypeNodeWithDefaultChildren();
|
||||
$node->setAddChildrenIfNoneSet(2);
|
||||
$this->assertTrue($node->hasDefaultValue());
|
||||
$this->assertEquals(array(array('foo' => 'bar'), array('foo' => 'bar')), $node->getDefaultValue());
|
||||
}
|
||||
|
||||
public function testDefaultChildrenWinsOverDefaultValue()
|
||||
{
|
||||
$node = $this->getPrototypeNodeWithDefaultChildren();
|
||||
$node->setAddChildrenIfNoneSet();
|
||||
$node->setDefaultValue(array('bar' => 'foo'));
|
||||
$this->assertTrue($node->hasDefaultValue());
|
||||
$this->assertEquals(array(array('foo' => 'bar')), $node->getDefaultValue());
|
||||
}
|
||||
|
||||
protected function getPrototypeNodeWithDefaultChildren()
|
||||
{
|
||||
$node = new PrototypedArrayNode('root');
|
||||
$prototype = new ArrayNode(null, $node);
|
||||
$child = new ScalarNode('foo');
|
||||
$child->setDefaultValue('bar');
|
||||
$prototype->addChild($child);
|
||||
$prototype->setAddIfNotSet(true);
|
||||
$node->setPrototype($prototype);
|
||||
|
||||
return $node;
|
||||
}
|
||||
}
|
||||
60
core/vendor/symfony/config/Symfony/Component/Config/Tests/Definition/ScalarNodeTest.php
vendored
Normal file
60
core/vendor/symfony/config/Symfony/Component/Config/Tests/Definition/ScalarNodeTest.php
vendored
Normal file
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Config\Tests\Definition;
|
||||
|
||||
use Symfony\Component\Config\Definition\ScalarNode;
|
||||
|
||||
class ScalarNodeTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @dataProvider getValidValues
|
||||
*/
|
||||
public function testNormalize($value)
|
||||
{
|
||||
$node = new ScalarNode('test');
|
||||
$this->assertSame($value, $node->normalize($value));
|
||||
}
|
||||
|
||||
public function getValidValues()
|
||||
{
|
||||
return array(
|
||||
array(false),
|
||||
array(true),
|
||||
array(null),
|
||||
array(''),
|
||||
array('foo'),
|
||||
array(0),
|
||||
array(1),
|
||||
array(0.0),
|
||||
array(0.1),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getInvalidValues
|
||||
* @expectedException Symfony\Component\Config\Definition\Exception\InvalidTypeException
|
||||
*/
|
||||
public function testNormalizeThrowsExceptionOnInvalidValues($value)
|
||||
{
|
||||
$node = new ScalarNode('test');
|
||||
$node->normalize($value);
|
||||
}
|
||||
|
||||
public function getInvalidValues()
|
||||
{
|
||||
return array(
|
||||
array(array()),
|
||||
array(array('foo' => 'bar')),
|
||||
array(new \stdClass()),
|
||||
);
|
||||
}
|
||||
}
|
||||
107
core/vendor/symfony/config/Symfony/Component/Config/Tests/FileLocatorTest.php
vendored
Normal file
107
core/vendor/symfony/config/Symfony/Component/Config/Tests/FileLocatorTest.php
vendored
Normal file
@@ -0,0 +1,107 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Config\Tests;
|
||||
|
||||
use Symfony\Component\Config\FileLocator;
|
||||
|
||||
class FileLocatorTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @dataProvider getIsAbsolutePathTests
|
||||
*/
|
||||
public function testIsAbsolutePath($path)
|
||||
{
|
||||
$loader = new FileLocator(array());
|
||||
$r = new \ReflectionObject($loader);
|
||||
$m = $r->getMethod('isAbsolutePath');
|
||||
$m->setAccessible(true);
|
||||
|
||||
$this->assertTrue($m->invoke($loader, $path), '->isAbsolutePath() returns true for an absolute path');
|
||||
}
|
||||
|
||||
public function getIsAbsolutePathTests()
|
||||
{
|
||||
return array(
|
||||
array('/foo.xml'),
|
||||
array('c:\\\\foo.xml'),
|
||||
array('c:/foo.xml'),
|
||||
array('\\server\\foo.xml'),
|
||||
array('https://server/foo.xml'),
|
||||
array('phar://server/foo.xml'),
|
||||
);
|
||||
}
|
||||
|
||||
public function testLocate()
|
||||
{
|
||||
$loader = new FileLocator(__DIR__.'/Fixtures');
|
||||
|
||||
$this->assertEquals(
|
||||
__DIR__.DIRECTORY_SEPARATOR.'FileLocatorTest.php',
|
||||
$loader->locate('FileLocatorTest.php', __DIR__),
|
||||
'->locate() returns the absolute filename if the file exists in the given path'
|
||||
);
|
||||
|
||||
$this->assertEquals(
|
||||
__DIR__.'/Fixtures'.DIRECTORY_SEPARATOR.'foo.xml',
|
||||
$loader->locate('foo.xml', __DIR__),
|
||||
'->locate() returns the absolute filename if the file exists in one of the paths given in the constructor'
|
||||
);
|
||||
|
||||
$this->assertEquals(
|
||||
__DIR__.'/Fixtures'.DIRECTORY_SEPARATOR.'foo.xml',
|
||||
$loader->locate(__DIR__.'/Fixtures'.DIRECTORY_SEPARATOR.'foo.xml', __DIR__),
|
||||
'->locate() returns the absolute filename if the file exists in one of the paths given in the constructor'
|
||||
);
|
||||
|
||||
$loader = new FileLocator(array(__DIR__.'/Fixtures', __DIR__.'/Fixtures/Again'));
|
||||
|
||||
$this->assertEquals(
|
||||
array(__DIR__.'/Fixtures'.DIRECTORY_SEPARATOR.'foo.xml', __DIR__.'/Fixtures/Again'.DIRECTORY_SEPARATOR.'foo.xml'),
|
||||
$loader->locate('foo.xml', __DIR__, false),
|
||||
'->locate() returns an array of absolute filenames'
|
||||
);
|
||||
|
||||
$this->assertEquals(
|
||||
array(__DIR__.'/Fixtures'.DIRECTORY_SEPARATOR.'foo.xml', __DIR__.'/Fixtures/Again'.DIRECTORY_SEPARATOR.'foo.xml'),
|
||||
$loader->locate('foo.xml', __DIR__.'/Fixtures', false),
|
||||
'->locate() returns an array of absolute filenames'
|
||||
);
|
||||
|
||||
$loader = new FileLocator(__DIR__.'/Fixtures/Again');
|
||||
|
||||
$this->assertEquals(
|
||||
array(__DIR__.'/Fixtures'.DIRECTORY_SEPARATOR.'foo.xml', __DIR__.'/Fixtures/Again'.DIRECTORY_SEPARATOR.'foo.xml'),
|
||||
$loader->locate('foo.xml', __DIR__.'/Fixtures', false),
|
||||
'->locate() returns an array of absolute filenames'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \InvalidArgumentException
|
||||
*/
|
||||
public function testLocateThrowsAnExceptionIfTheFileDoesNotExists()
|
||||
{
|
||||
$loader = new FileLocator(array(__DIR__.'/Fixtures'));
|
||||
|
||||
$loader->locate('foobar.xml', __DIR__);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \InvalidArgumentException
|
||||
*/
|
||||
public function testLocateThrowsAnExceptionIfTheFileDoesNotExistsInAbsolutePath()
|
||||
{
|
||||
$loader = new FileLocator(array(__DIR__.'/Fixtures'));
|
||||
|
||||
$loader->locate(__DIR__.'/Fixtures/foobar.xml', __DIR__);
|
||||
}
|
||||
}
|
||||
0
core/vendor/symfony/config/Symfony/Component/Config/Tests/Fixtures/Again/foo.xml
vendored
Normal file
0
core/vendor/symfony/config/Symfony/Component/Config/Tests/Fixtures/Again/foo.xml
vendored
Normal file
21
core/vendor/symfony/config/Symfony/Component/Config/Tests/Fixtures/Builder/BarNodeDefinition.php
vendored
Normal file
21
core/vendor/symfony/config/Symfony/Component/Config/Tests/Fixtures/Builder/BarNodeDefinition.php
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Config\Tests\Definition\Builder;
|
||||
|
||||
use Symfony\Component\Config\Definition\Builder\NodeDefinition;
|
||||
|
||||
class BarNodeDefinition extends NodeDefinition
|
||||
{
|
||||
protected function createNode()
|
||||
{
|
||||
}
|
||||
}
|
||||
34
core/vendor/symfony/config/Symfony/Component/Config/Tests/Fixtures/Builder/NodeBuilder.php
vendored
Normal file
34
core/vendor/symfony/config/Symfony/Component/Config/Tests/Fixtures/Builder/NodeBuilder.php
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Config\Tests\Definition\Builder;
|
||||
|
||||
use Symfony\Component\Config\Definition\Builder\NodeBuilder as BaseNodeBuilder;
|
||||
|
||||
class NodeBuilder extends BaseNodeBuilder
|
||||
{
|
||||
public function barNode($name)
|
||||
{
|
||||
return $this->node($name, 'bar');
|
||||
}
|
||||
|
||||
protected function getNodeClass($type)
|
||||
{
|
||||
switch ($type) {
|
||||
case 'variable':
|
||||
return __NAMESPACE__.'\\'.ucfirst($type).'NodeDefinition';
|
||||
case 'bar':
|
||||
return __NAMESPACE__.'\\'.ucfirst($type).'NodeDefinition';
|
||||
default:
|
||||
return parent::getNodeClass($type);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Config\Tests\Definition\Builder;
|
||||
|
||||
use Symfony\Component\Config\Definition\Builder\VariableNodeDefinition as BaseVariableNodeDefinition;
|
||||
|
||||
class VariableNodeDefinition extends BaseVariableNodeDefinition
|
||||
{
|
||||
}
|
||||
0
core/vendor/symfony/config/Symfony/Component/Config/Tests/Fixtures/foo.xml
vendored
Normal file
0
core/vendor/symfony/config/Symfony/Component/Config/Tests/Fixtures/foo.xml
vendored
Normal file
83
core/vendor/symfony/config/Symfony/Component/Config/Tests/Loader/DelegatingLoaderTest.php
vendored
Normal file
83
core/vendor/symfony/config/Symfony/Component/Config/Tests/Loader/DelegatingLoaderTest.php
vendored
Normal file
@@ -0,0 +1,83 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Config\Tests\Loader;
|
||||
|
||||
use Symfony\Component\Config\Loader\LoaderResolver;
|
||||
use Symfony\Component\Config\Loader\DelegatingLoader;
|
||||
|
||||
class DelegatingLoaderTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @covers Symfony\Component\Config\Loader\DelegatingLoader::__construct
|
||||
*/
|
||||
public function testConstructor()
|
||||
{
|
||||
$loader = new DelegatingLoader($resolver = new LoaderResolver());
|
||||
$this->assertTrue(true, '__construct() takes a loader resolver as its first argument');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Symfony\Component\Config\Loader\DelegatingLoader::getResolver
|
||||
* @covers Symfony\Component\Config\Loader\DelegatingLoader::setResolver
|
||||
*/
|
||||
public function testGetSetResolver()
|
||||
{
|
||||
$resolver = new LoaderResolver();
|
||||
$loader = new DelegatingLoader($resolver);
|
||||
$this->assertSame($resolver, $loader->getResolver(), '->getResolver() gets the resolver loader');
|
||||
$loader->setResolver($resolver = new LoaderResolver());
|
||||
$this->assertSame($resolver, $loader->getResolver(), '->setResolver() sets the resolver loader');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Symfony\Component\Config\Loader\DelegatingLoader::supports
|
||||
*/
|
||||
public function testSupports()
|
||||
{
|
||||
$loader1 = $this->getMock('Symfony\Component\Config\Loader\LoaderInterface');
|
||||
$loader1->expects($this->once())->method('supports')->will($this->returnValue(true));
|
||||
$loader = new DelegatingLoader(new LoaderResolver(array($loader1)));
|
||||
$this->assertTrue($loader->supports('foo.xml'), '->supports() returns true if the resource is loadable');
|
||||
|
||||
$loader1 = $this->getMock('Symfony\Component\Config\Loader\LoaderInterface');
|
||||
$loader1->expects($this->once())->method('supports')->will($this->returnValue(false));
|
||||
$loader = new DelegatingLoader(new LoaderResolver(array($loader1)));
|
||||
$this->assertFalse($loader->supports('foo.foo'), '->supports() returns false if the resource is not loadable');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Symfony\Component\Config\Loader\DelegatingLoader::load
|
||||
*/
|
||||
public function testLoad()
|
||||
{
|
||||
$loader = $this->getMock('Symfony\Component\Config\Loader\LoaderInterface');
|
||||
$loader->expects($this->once())->method('supports')->will($this->returnValue(true));
|
||||
$loader->expects($this->once())->method('load');
|
||||
$resolver = new LoaderResolver(array($loader));
|
||||
$loader = new DelegatingLoader($resolver);
|
||||
|
||||
$loader->load('foo');
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException Symfony\Component\Config\Exception\FileLoaderLoadException
|
||||
*/
|
||||
public function testLoadThrowsAnExceptionIfTheResourceCannotBeLoaded()
|
||||
{
|
||||
$loader = $this->getMock('Symfony\Component\Config\Loader\LoaderInterface');
|
||||
$loader->expects($this->once())->method('supports')->will($this->returnValue(false));
|
||||
$resolver = new LoaderResolver(array($loader));
|
||||
$loader = new DelegatingLoader($resolver);
|
||||
|
||||
$loader->load('foo');
|
||||
}
|
||||
}
|
||||
56
core/vendor/symfony/config/Symfony/Component/Config/Tests/Loader/LoaderResolverTest.php
vendored
Normal file
56
core/vendor/symfony/config/Symfony/Component/Config/Tests/Loader/LoaderResolverTest.php
vendored
Normal file
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Config\Tests\Loader;
|
||||
|
||||
use Symfony\Component\Config\Loader\LoaderResolver;
|
||||
|
||||
class LoaderResolverTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @covers Symfony\Component\Config\Loader\LoaderResolver::__construct
|
||||
*/
|
||||
public function testConstructor()
|
||||
{
|
||||
$resolver = new LoaderResolver(array(
|
||||
$loader = $this->getMock('Symfony\Component\Config\Loader\LoaderInterface'),
|
||||
));
|
||||
|
||||
$this->assertEquals(array($loader), $resolver->getLoaders(), '__construct() takes an array of loaders as its first argument');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Symfony\Component\Config\Loader\LoaderResolver::resolve
|
||||
*/
|
||||
public function testResolve()
|
||||
{
|
||||
$loader = $this->getMock('Symfony\Component\Config\Loader\LoaderInterface');
|
||||
$resolver = new LoaderResolver(array($loader));
|
||||
$this->assertFalse($resolver->resolve('foo.foo'), '->resolve() returns false if no loader is able to load the resource');
|
||||
|
||||
$loader = $this->getMock('Symfony\Component\Config\Loader\LoaderInterface');
|
||||
$loader->expects($this->once())->method('supports')->will($this->returnValue(true));
|
||||
$resolver = new LoaderResolver(array($loader));
|
||||
$this->assertEquals($loader, $resolver->resolve(function () {}), '->resolve() returns the loader for the given resource');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Symfony\Component\Config\Loader\LoaderResolver::getLoaders
|
||||
* @covers Symfony\Component\Config\Loader\LoaderResolver::addLoader
|
||||
*/
|
||||
public function testLoaders()
|
||||
{
|
||||
$resolver = new LoaderResolver();
|
||||
$resolver->addLoader($loader = $this->getMock('Symfony\Component\Config\Loader\LoaderInterface'));
|
||||
|
||||
$this->assertEquals(array($loader), $resolver->getLoaders(), 'addLoader() adds a loader');
|
||||
}
|
||||
}
|
||||
74
core/vendor/symfony/config/Symfony/Component/Config/Tests/Loader/LoaderTest.php
vendored
Normal file
74
core/vendor/symfony/config/Symfony/Component/Config/Tests/Loader/LoaderTest.php
vendored
Normal file
@@ -0,0 +1,74 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Config\Tests\Loader;
|
||||
|
||||
use Symfony\Component\Config\Loader\LoaderResolver;
|
||||
use Symfony\Component\Config\Loader\Loader;
|
||||
use Symfony\Component\Config\Exception\FileLoaderLoadException;
|
||||
|
||||
class LoaderTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @covers Symfony\Component\Config\Loader\Loader::getResolver
|
||||
* @covers Symfony\Component\Config\Loader\Loader::setResolver
|
||||
*/
|
||||
public function testGetSetResolver()
|
||||
{
|
||||
$resolver = new LoaderResolver();
|
||||
$loader = new ProjectLoader1();
|
||||
$loader->setResolver($resolver);
|
||||
$this->assertSame($resolver, $loader->getResolver(), '->setResolver() sets the resolver loader');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Symfony\Component\Config\Loader\Loader::resolve
|
||||
*/
|
||||
public function testResolve()
|
||||
{
|
||||
$loader1 = $this->getMock('Symfony\Component\Config\Loader\LoaderInterface');
|
||||
$loader1->expects($this->once())->method('supports')->will($this->returnValue(true));
|
||||
$resolver = new LoaderResolver(array($loader1));
|
||||
$loader = new ProjectLoader1();
|
||||
$loader->setResolver($resolver);
|
||||
|
||||
$this->assertSame($loader, $loader->resolve('foo.foo'), '->resolve() finds a loader');
|
||||
$this->assertSame($loader1, $loader->resolve('foo.xml'), '->resolve() finds a loader');
|
||||
|
||||
$loader1 = $this->getMock('Symfony\Component\Config\Loader\LoaderInterface');
|
||||
$loader1->expects($this->once())->method('supports')->will($this->returnValue(false));
|
||||
$resolver = new LoaderResolver(array($loader1));
|
||||
$loader = new ProjectLoader1();
|
||||
$loader->setResolver($resolver);
|
||||
try {
|
||||
$loader->resolve('FOOBAR');
|
||||
$this->fail('->resolve() throws a FileLoaderLoadException if the resource cannot be loaded');
|
||||
} catch (FileLoaderLoadException $e) {
|
||||
$this->assertInstanceOf('Symfony\Component\Config\Exception\FileLoaderLoadException', $e, '->resolve() throws a FileLoaderLoadException if the resource cannot be loaded');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class ProjectLoader1 extends Loader
|
||||
{
|
||||
public function load($resource, $type = null)
|
||||
{
|
||||
}
|
||||
|
||||
public function supports($resource, $type = null)
|
||||
{
|
||||
return is_string($resource) && 'foo' === pathinfo($resource, PATHINFO_EXTENSION);
|
||||
}
|
||||
|
||||
public function getType()
|
||||
{
|
||||
}
|
||||
}
|
||||
171
core/vendor/symfony/config/Symfony/Component/Config/Tests/Resource/DirectoryResourceTest.php
vendored
Normal file
171
core/vendor/symfony/config/Symfony/Component/Config/Tests/Resource/DirectoryResourceTest.php
vendored
Normal file
@@ -0,0 +1,171 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Config\Tests\Resource;
|
||||
|
||||
use Symfony\Component\Config\Resource\DirectoryResource;
|
||||
|
||||
class DirectoryResourceTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
protected $directory;
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
$this->directory = sys_get_temp_dir().'/symfonyDirectoryIterator';
|
||||
if (!file_exists($this->directory)) {
|
||||
mkdir($this->directory);
|
||||
}
|
||||
touch($this->directory.'/tmp.xml');
|
||||
}
|
||||
|
||||
protected function tearDown()
|
||||
{
|
||||
if (!is_dir($this->directory)) {
|
||||
return;
|
||||
}
|
||||
$this->removeDirectory($this->directory);
|
||||
}
|
||||
|
||||
protected function removeDirectory($directory)
|
||||
{
|
||||
$iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($directory), \RecursiveIteratorIterator::CHILD_FIRST);
|
||||
foreach ($iterator as $path) {
|
||||
if (preg_match('#/\.\.?$#', $path->__toString())) {
|
||||
continue;
|
||||
}
|
||||
if ($path->isDir()) {
|
||||
rmdir($path->__toString());
|
||||
} else {
|
||||
unlink($path->__toString());
|
||||
}
|
||||
}
|
||||
rmdir($directory);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Symfony\Component\Config\Resource\DirectoryResource::getResource
|
||||
*/
|
||||
public function testGetResource()
|
||||
{
|
||||
$resource = new DirectoryResource($this->directory);
|
||||
$this->assertEquals($this->directory, $resource->getResource(), '->getResource() returns the path to the resource');
|
||||
}
|
||||
|
||||
public function testGetPattern()
|
||||
{
|
||||
$resource = new DirectoryResource('foo', 'bar');
|
||||
$this->assertEquals('bar', $resource->getPattern());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Symfony\Component\Config\Resource\DirectoryResource::isFresh
|
||||
*/
|
||||
public function testIsFresh()
|
||||
{
|
||||
$resource = new DirectoryResource($this->directory);
|
||||
$this->assertTrue($resource->isFresh(time() + 10), '->isFresh() returns true if the resource has not changed');
|
||||
$this->assertFalse($resource->isFresh(time() - 86400), '->isFresh() returns false if the resource has been updated');
|
||||
|
||||
$resource = new DirectoryResource('/____foo/foobar'.rand(1, 999999));
|
||||
$this->assertFalse($resource->isFresh(time()), '->isFresh() returns false if the resource does not exist');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Symfony\Component\Config\Resource\DirectoryResource::isFresh
|
||||
*/
|
||||
public function testIsFreshUpdateFile()
|
||||
{
|
||||
$resource = new DirectoryResource($this->directory);
|
||||
touch($this->directory.'/tmp.xml', time() + 20);
|
||||
$this->assertFalse($resource->isFresh(time() + 10), '->isFresh() returns false if an existing file is modified');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Symfony\Component\Config\Resource\DirectoryResource::isFresh
|
||||
*/
|
||||
public function testIsFreshNewFile()
|
||||
{
|
||||
$resource = new DirectoryResource($this->directory);
|
||||
touch($this->directory.'/new.xml', time() + 20);
|
||||
$this->assertFalse($resource->isFresh(time() + 10), '->isFresh() returns false if a new file is added');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Symfony\Component\Config\Resource\DirectoryResource::isFresh
|
||||
*/
|
||||
public function testIsFreshDeleteFile()
|
||||
{
|
||||
$resource = new DirectoryResource($this->directory);
|
||||
unlink($this->directory.'/tmp.xml');
|
||||
$this->assertFalse($resource->isFresh(time()), '->isFresh() returns false if an existing file is removed');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Symfony\Component\Config\Resource\DirectoryResource::isFresh
|
||||
*/
|
||||
public function testIsFreshDeleteDirectory()
|
||||
{
|
||||
$resource = new DirectoryResource($this->directory);
|
||||
$this->removeDirectory($this->directory);
|
||||
$this->assertFalse($resource->isFresh(time()), '->isFresh() returns false if the whole resource is removed');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Symfony\Component\Config\Resource\DirectoryResource::isFresh
|
||||
*/
|
||||
public function testIsFreshCreateFileInSubdirectory()
|
||||
{
|
||||
$subdirectory = $this->directory.'/subdirectory';
|
||||
mkdir($subdirectory);
|
||||
|
||||
$resource = new DirectoryResource($this->directory);
|
||||
$this->assertTrue($resource->isFresh(time() + 10), '->isFresh() returns true if an unmodified subdirectory exists');
|
||||
|
||||
touch($subdirectory.'/newfile.xml', time() + 20);
|
||||
$this->assertFalse($resource->isFresh(time() + 10), '->isFresh() returns false if a new file in a subdirectory is added');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Symfony\Component\Config\Resource\DirectoryResource::isFresh
|
||||
*/
|
||||
public function testIsFreshModifySubdirectory()
|
||||
{
|
||||
$resource = new DirectoryResource($this->directory);
|
||||
|
||||
$subdirectory = $this->directory.'/subdirectory';
|
||||
mkdir($subdirectory);
|
||||
touch($subdirectory, time() + 20);
|
||||
|
||||
$this->assertFalse($resource->isFresh(time() + 10), '->isFresh() returns false if a subdirectory is modified (e.g. a file gets deleted)');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Symfony\Component\Config\Resource\DirectoryResource::isFresh
|
||||
*/
|
||||
public function testFilterRegexListNoMatch()
|
||||
{
|
||||
$resource = new DirectoryResource($this->directory, '/\.(foo|xml)$/');
|
||||
|
||||
touch($this->directory.'/new.bar', time() + 20);
|
||||
$this->assertTrue($resource->isFresh(time() + 10), '->isFresh() returns true if a new file not matching the filter regex is created');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Symfony\Component\Config\Resource\DirectoryResource::isFresh
|
||||
*/
|
||||
public function testFilterRegexListMatch()
|
||||
{
|
||||
$resource = new DirectoryResource($this->directory, '/\.(foo|xml)$/');
|
||||
|
||||
touch($this->directory.'/new.xml', time() + 20);
|
||||
$this->assertFalse($resource->isFresh(time() + 10), '->isFresh() returns false if an new file matching the filter regex is created ');
|
||||
}
|
||||
}
|
||||
52
core/vendor/symfony/config/Symfony/Component/Config/Tests/Resource/FileResourceTest.php
vendored
Normal file
52
core/vendor/symfony/config/Symfony/Component/Config/Tests/Resource/FileResourceTest.php
vendored
Normal file
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Config\Tests\Resource;
|
||||
|
||||
use Symfony\Component\Config\Resource\FileResource;
|
||||
|
||||
class FileResourceTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
protected $resource;
|
||||
protected $file;
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
$this->file = sys_get_temp_dir().'/tmp.xml';
|
||||
touch($this->file);
|
||||
$this->resource = new FileResource($this->file);
|
||||
}
|
||||
|
||||
protected function tearDown()
|
||||
{
|
||||
unlink($this->file);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Symfony\Component\Config\Resource\FileResource::getResource
|
||||
*/
|
||||
public function testGetResource()
|
||||
{
|
||||
$this->assertEquals(realpath($this->file), $this->resource->getResource(), '->getResource() returns the path to the resource');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Symfony\Component\Config\Resource\FileResource::isFresh
|
||||
*/
|
||||
public function testIsFresh()
|
||||
{
|
||||
$this->assertTrue($this->resource->isFresh(time() + 10), '->isFresh() returns true if the resource has not changed');
|
||||
$this->assertFalse($this->resource->isFresh(time() - 86400), '->isFresh() returns false if the resource has been updated');
|
||||
|
||||
$resource = new FileResource('/____foo/foobar'.rand(1, 999999));
|
||||
$this->assertFalse($resource->isFresh(time()), '->isFresh() returns false if the resource does not exist');
|
||||
}
|
||||
}
|
||||
18
core/vendor/symfony/config/Symfony/Component/Config/Tests/bootstrap.php
vendored
Normal file
18
core/vendor/symfony/config/Symfony/Component/Config/Tests/bootstrap.php
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
spl_autoload_register(function ($class) {
|
||||
if (0 === strpos(ltrim($class, '/'), 'Symfony\Component\Config')) {
|
||||
if (file_exists($file = __DIR__.'/../'.substr(str_replace('\\', '/', $class), strlen('Symfony\Component\Config')).'.php')) {
|
||||
require_once $file;
|
||||
}
|
||||
}
|
||||
});
|
||||
31
core/vendor/symfony/config/Symfony/Component/Config/composer.json
vendored
Normal file
31
core/vendor/symfony/config/Symfony/Component/Config/composer.json
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
{
|
||||
"name": "symfony/config",
|
||||
"type": "library",
|
||||
"description": "Symfony Config Component",
|
||||
"keywords": [],
|
||||
"homepage": "http://symfony.com",
|
||||
"license": "MIT",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Fabien Potencier",
|
||||
"email": "fabien@symfony.com"
|
||||
},
|
||||
{
|
||||
"name": "Symfony Community",
|
||||
"homepage": "http://symfony.com/contributors"
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": ">=5.3.3"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-0": { "Symfony\\Component\\Config": "" }
|
||||
},
|
||||
"target-dir": "Symfony/Component/Config",
|
||||
"minimum-stability": "dev",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "2.1-dev"
|
||||
}
|
||||
}
|
||||
}
|
||||
30
core/vendor/symfony/config/Symfony/Component/Config/phpunit.xml.dist
vendored
Normal file
30
core/vendor/symfony/config/Symfony/Component/Config/phpunit.xml.dist
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<phpunit backupGlobals="false"
|
||||
backupStaticAttributes="false"
|
||||
colors="true"
|
||||
convertErrorsToExceptions="true"
|
||||
convertNoticesToExceptions="true"
|
||||
convertWarningsToExceptions="true"
|
||||
processIsolation="false"
|
||||
stopOnFailure="false"
|
||||
syntaxCheck="false"
|
||||
bootstrap="Tests/bootstrap.php"
|
||||
>
|
||||
<testsuites>
|
||||
<testsuite name="Symfony Config Component Test Suite">
|
||||
<directory>./Tests/</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
|
||||
<filter>
|
||||
<whitelist>
|
||||
<directory>./</directory>
|
||||
<exclude>
|
||||
<directory>./Resources</directory>
|
||||
<directory>./Tests</directory>
|
||||
<directory>./vendor</directory>
|
||||
</exclude>
|
||||
</whitelist>
|
||||
</filter>
|
||||
</phpunit>
|
||||
Reference in New Issue
Block a user