Move into nested docroot
This commit is contained in:
parent
83a0d3a149
commit
c8b70abde9
13405 changed files with 0 additions and 0 deletions
91
web/vendor/symfony/validator/Mapping/Loader/AbstractLoader.php
vendored
Normal file
91
web/vendor/symfony/validator/Mapping/Loader/AbstractLoader.php
vendored
Normal file
|
@ -0,0 +1,91 @@
|
|||
<?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\Validator\Mapping\Loader;
|
||||
|
||||
use Symfony\Component\Validator\Constraint;
|
||||
use Symfony\Component\Validator\Exception\MappingException;
|
||||
|
||||
/**
|
||||
* Base loader for validation metadata.
|
||||
*
|
||||
* This loader supports the loading of constraints from Symfony's default
|
||||
* namespace (see {@link DEFAULT_NAMESPACE}) using the short class names of
|
||||
* those constraints. Constraints can also be loaded using their fully
|
||||
* qualified class names. At last, namespace aliases can be defined to load
|
||||
* constraints with the syntax "alias:ShortName".
|
||||
*
|
||||
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||
*/
|
||||
abstract class AbstractLoader implements LoaderInterface
|
||||
{
|
||||
/**
|
||||
* The namespace to load constraints from by default.
|
||||
*/
|
||||
const DEFAULT_NAMESPACE = '\\Symfony\\Component\\Validator\\Constraints\\';
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $namespaces = array();
|
||||
|
||||
/**
|
||||
* Adds a namespace alias.
|
||||
*
|
||||
* The namespace alias can be used to reference constraints from specific
|
||||
* namespaces in {@link newConstraint()}:
|
||||
*
|
||||
* $this->addNamespaceAlias('mynamespace', '\\Acme\\Package\\Constraints\\');
|
||||
*
|
||||
* $constraint = $this->newConstraint('mynamespace:NotNull');
|
||||
*
|
||||
* @param string $alias The alias
|
||||
* @param string $namespace The PHP namespace
|
||||
*/
|
||||
protected function addNamespaceAlias($alias, $namespace)
|
||||
{
|
||||
$this->namespaces[$alias] = $namespace;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new constraint instance for the given constraint name.
|
||||
*
|
||||
* @param string $name The constraint name. Either a constraint relative
|
||||
* to the default constraint namespace, or a fully
|
||||
* qualified class name. Alternatively, the constraint
|
||||
* may be preceded by a namespace alias and a colon.
|
||||
* The namespace alias must have been defined using
|
||||
* {@link addNamespaceAlias()}.
|
||||
* @param mixed $options The constraint options
|
||||
*
|
||||
* @return Constraint
|
||||
*
|
||||
* @throws MappingException If the namespace prefix is undefined
|
||||
*/
|
||||
protected function newConstraint($name, $options = null)
|
||||
{
|
||||
if (strpos($name, '\\') !== false && class_exists($name)) {
|
||||
$className = (string) $name;
|
||||
} elseif (strpos($name, ':') !== false) {
|
||||
list($prefix, $className) = explode(':', $name, 2);
|
||||
|
||||
if (!isset($this->namespaces[$prefix])) {
|
||||
throw new MappingException(sprintf('Undefined namespace prefix "%s"', $prefix));
|
||||
}
|
||||
|
||||
$className = $this->namespaces[$prefix].$className;
|
||||
} else {
|
||||
$className = self::DEFAULT_NAMESPACE.$name;
|
||||
}
|
||||
|
||||
return new $className($options);
|
||||
}
|
||||
}
|
95
web/vendor/symfony/validator/Mapping/Loader/AnnotationLoader.php
vendored
Normal file
95
web/vendor/symfony/validator/Mapping/Loader/AnnotationLoader.php
vendored
Normal file
|
@ -0,0 +1,95 @@
|
|||
<?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\Validator\Mapping\Loader;
|
||||
|
||||
use Doctrine\Common\Annotations\Reader;
|
||||
use Symfony\Component\Validator\Constraint;
|
||||
use Symfony\Component\Validator\Constraints\Callback;
|
||||
use Symfony\Component\Validator\Constraints\GroupSequence;
|
||||
use Symfony\Component\Validator\Constraints\GroupSequenceProvider;
|
||||
use Symfony\Component\Validator\Exception\MappingException;
|
||||
use Symfony\Component\Validator\Mapping\ClassMetadata;
|
||||
|
||||
/**
|
||||
* Loads validation metadata using a Doctrine annotation {@link Reader}.
|
||||
*
|
||||
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||
*/
|
||||
class AnnotationLoader implements LoaderInterface
|
||||
{
|
||||
/**
|
||||
* @var Reader
|
||||
*/
|
||||
protected $reader;
|
||||
|
||||
public function __construct(Reader $reader)
|
||||
{
|
||||
$this->reader = $reader;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function loadClassMetadata(ClassMetadata $metadata)
|
||||
{
|
||||
$reflClass = $metadata->getReflectionClass();
|
||||
$className = $reflClass->name;
|
||||
$success = false;
|
||||
|
||||
foreach ($this->reader->getClassAnnotations($reflClass) as $constraint) {
|
||||
if ($constraint instanceof GroupSequence) {
|
||||
$metadata->setGroupSequence($constraint->groups);
|
||||
} elseif ($constraint instanceof GroupSequenceProvider) {
|
||||
$metadata->setGroupSequenceProvider(true);
|
||||
} elseif ($constraint instanceof Constraint) {
|
||||
$metadata->addConstraint($constraint);
|
||||
}
|
||||
|
||||
$success = true;
|
||||
}
|
||||
|
||||
foreach ($reflClass->getProperties() as $property) {
|
||||
if ($property->getDeclaringClass()->name === $className) {
|
||||
foreach ($this->reader->getPropertyAnnotations($property) as $constraint) {
|
||||
if ($constraint instanceof Constraint) {
|
||||
$metadata->addPropertyConstraint($property->name, $constraint);
|
||||
}
|
||||
|
||||
$success = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($reflClass->getMethods() as $method) {
|
||||
if ($method->getDeclaringClass()->name === $className) {
|
||||
foreach ($this->reader->getMethodAnnotations($method) as $constraint) {
|
||||
if ($constraint instanceof Callback) {
|
||||
$constraint->callback = $method->getName();
|
||||
$constraint->methods = null;
|
||||
|
||||
$metadata->addConstraint($constraint);
|
||||
} elseif ($constraint instanceof Constraint) {
|
||||
if (preg_match('/^(get|is|has)(.+)$/i', $method->name, $matches)) {
|
||||
$metadata->addGetterConstraint(lcfirst($matches[2]), $constraint);
|
||||
} else {
|
||||
throw new MappingException(sprintf('The constraint on "%s::%s" cannot be added. Constraints can only be added on methods beginning with "get", "is" or "has".', $className, $method->name));
|
||||
}
|
||||
}
|
||||
|
||||
$success = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $success;
|
||||
}
|
||||
}
|
56
web/vendor/symfony/validator/Mapping/Loader/FileLoader.php
vendored
Normal file
56
web/vendor/symfony/validator/Mapping/Loader/FileLoader.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\Validator\Mapping\Loader;
|
||||
|
||||
use Symfony\Component\Validator\Exception\MappingException;
|
||||
|
||||
/**
|
||||
* Base loader for loading validation metadata from a file.
|
||||
*
|
||||
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||
*
|
||||
* @see YamlFileLoader
|
||||
* @see XmlFileLoader
|
||||
*/
|
||||
abstract class FileLoader extends AbstractLoader
|
||||
{
|
||||
/**
|
||||
* The file to load.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $file;
|
||||
|
||||
/**
|
||||
* Creates a new loader.
|
||||
*
|
||||
* @param string $file The mapping file to load
|
||||
*
|
||||
* @throws MappingException If the file does not exist or is not readable
|
||||
*/
|
||||
public function __construct($file)
|
||||
{
|
||||
if (!is_file($file)) {
|
||||
throw new MappingException(sprintf('The mapping file "%s" does not exist', $file));
|
||||
}
|
||||
|
||||
if (!is_readable($file)) {
|
||||
throw new MappingException(sprintf('The mapping file "%s" is not readable', $file));
|
||||
}
|
||||
|
||||
if (!stream_is_local($this->file)) {
|
||||
throw new MappingException(sprintf('The mapping file "%s" is not a local file', $file));
|
||||
}
|
||||
|
||||
$this->file = $file;
|
||||
}
|
||||
}
|
61
web/vendor/symfony/validator/Mapping/Loader/FilesLoader.php
vendored
Normal file
61
web/vendor/symfony/validator/Mapping/Loader/FilesLoader.php
vendored
Normal file
|
@ -0,0 +1,61 @@
|
|||
<?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\Validator\Mapping\Loader;
|
||||
|
||||
/**
|
||||
* Base loader for loading validation metadata from a list of files.
|
||||
*
|
||||
* @author Bulat Shakirzyanov <mallluhuct@gmail.com>
|
||||
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||
*
|
||||
* @see YamlFilesLoader
|
||||
* @see XmlFilesLoader
|
||||
*/
|
||||
abstract class FilesLoader extends LoaderChain
|
||||
{
|
||||
/**
|
||||
* Creates a new loader.
|
||||
*
|
||||
* @param array $paths An array of file paths
|
||||
*/
|
||||
public function __construct(array $paths)
|
||||
{
|
||||
parent::__construct($this->getFileLoaders($paths));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of file loaders for the given file paths.
|
||||
*
|
||||
* @param array $paths An array of file paths
|
||||
*
|
||||
* @return LoaderInterface[] The metadata loaders
|
||||
*/
|
||||
protected function getFileLoaders($paths)
|
||||
{
|
||||
$loaders = array();
|
||||
|
||||
foreach ($paths as $path) {
|
||||
$loaders[] = $this->getFileLoaderInstance($path);
|
||||
}
|
||||
|
||||
return $loaders;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a loader for the given file path.
|
||||
*
|
||||
* @param string $path The file path
|
||||
*
|
||||
* @return LoaderInterface The created loader
|
||||
*/
|
||||
abstract protected function getFileLoaderInstance($path);
|
||||
}
|
62
web/vendor/symfony/validator/Mapping/Loader/LoaderChain.php
vendored
Normal file
62
web/vendor/symfony/validator/Mapping/Loader/LoaderChain.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\Validator\Mapping\Loader;
|
||||
|
||||
use Symfony\Component\Validator\Exception\MappingException;
|
||||
use Symfony\Component\Validator\Mapping\ClassMetadata;
|
||||
|
||||
/**
|
||||
* Loads validation metadata from multiple {@link LoaderInterface} instances.
|
||||
*
|
||||
* Pass the loaders when constructing the chain. Once
|
||||
* {@link loadClassMetadata()} is called, that method will be called on all
|
||||
* loaders in the chain.
|
||||
*
|
||||
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||
*/
|
||||
class LoaderChain implements LoaderInterface
|
||||
{
|
||||
/**
|
||||
* @var LoaderInterface[]
|
||||
*/
|
||||
protected $loaders;
|
||||
|
||||
/**
|
||||
* @param LoaderInterface[] $loaders The metadata loaders to use
|
||||
*
|
||||
* @throws MappingException If any of the loaders has an invalid type
|
||||
*/
|
||||
public function __construct(array $loaders)
|
||||
{
|
||||
foreach ($loaders as $loader) {
|
||||
if (!$loader instanceof LoaderInterface) {
|
||||
throw new MappingException(sprintf('Class %s is expected to implement LoaderInterface', get_class($loader)));
|
||||
}
|
||||
}
|
||||
|
||||
$this->loaders = $loaders;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function loadClassMetadata(ClassMetadata $metadata)
|
||||
{
|
||||
$success = false;
|
||||
|
||||
foreach ($this->loaders as $loader) {
|
||||
$success = $loader->loadClassMetadata($metadata) || $success;
|
||||
}
|
||||
|
||||
return $success;
|
||||
}
|
||||
}
|
31
web/vendor/symfony/validator/Mapping/Loader/LoaderInterface.php
vendored
Normal file
31
web/vendor/symfony/validator/Mapping/Loader/LoaderInterface.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\Validator\Mapping\Loader;
|
||||
|
||||
use Symfony\Component\Validator\Mapping\ClassMetadata;
|
||||
|
||||
/**
|
||||
* Loads validation metadata into {@link ClassMetadata} instances.
|
||||
*
|
||||
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||
*/
|
||||
interface LoaderInterface
|
||||
{
|
||||
/**
|
||||
* Loads validation metadata into a {@link ClassMetadata} instance.
|
||||
*
|
||||
* @param ClassMetadata $metadata The metadata to load
|
||||
*
|
||||
* @return bool Whether the loader succeeded
|
||||
*/
|
||||
public function loadClassMetadata(ClassMetadata $metadata);
|
||||
}
|
71
web/vendor/symfony/validator/Mapping/Loader/StaticMethodLoader.php
vendored
Normal file
71
web/vendor/symfony/validator/Mapping/Loader/StaticMethodLoader.php
vendored
Normal file
|
@ -0,0 +1,71 @@
|
|||
<?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\Validator\Mapping\Loader;
|
||||
|
||||
use Symfony\Component\Validator\Exception\MappingException;
|
||||
use Symfony\Component\Validator\Mapping\ClassMetadata;
|
||||
|
||||
/**
|
||||
* Loads validation metadata by calling a static method on the loaded class.
|
||||
*
|
||||
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||
*/
|
||||
class StaticMethodLoader implements LoaderInterface
|
||||
{
|
||||
/**
|
||||
* The name of the method to call.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $methodName;
|
||||
|
||||
/**
|
||||
* Creates a new loader.
|
||||
*
|
||||
* @param string $methodName The name of the static method to call
|
||||
*/
|
||||
public function __construct($methodName = 'loadValidatorMetadata')
|
||||
{
|
||||
$this->methodName = $methodName;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function loadClassMetadata(ClassMetadata $metadata)
|
||||
{
|
||||
/** @var \ReflectionClass $reflClass */
|
||||
$reflClass = $metadata->getReflectionClass();
|
||||
|
||||
if (!$reflClass->isInterface() && $reflClass->hasMethod($this->methodName)) {
|
||||
$reflMethod = $reflClass->getMethod($this->methodName);
|
||||
|
||||
if ($reflMethod->isAbstract()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$reflMethod->isStatic()) {
|
||||
throw new MappingException(sprintf('The method %s::%s should be static', $reflClass->name, $this->methodName));
|
||||
}
|
||||
|
||||
if ($reflMethod->getDeclaringClass()->name != $reflClass->name) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$reflMethod->invoke(null, $metadata);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
213
web/vendor/symfony/validator/Mapping/Loader/XmlFileLoader.php
vendored
Normal file
213
web/vendor/symfony/validator/Mapping/Loader/XmlFileLoader.php
vendored
Normal file
|
@ -0,0 +1,213 @@
|
|||
<?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\Validator\Mapping\Loader;
|
||||
|
||||
use Symfony\Component\Config\Util\XmlUtils;
|
||||
use Symfony\Component\Validator\Exception\MappingException;
|
||||
use Symfony\Component\Validator\Mapping\ClassMetadata;
|
||||
|
||||
/**
|
||||
* Loads validation metadata from an XML file.
|
||||
*
|
||||
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||
*/
|
||||
class XmlFileLoader extends FileLoader
|
||||
{
|
||||
/**
|
||||
* The XML nodes of the mapping file.
|
||||
*
|
||||
* @var \SimpleXMLElement[]|null
|
||||
*/
|
||||
protected $classes;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function loadClassMetadata(ClassMetadata $metadata)
|
||||
{
|
||||
if (null === $this->classes) {
|
||||
// This method may throw an exception. Do not modify the class'
|
||||
// state before it completes
|
||||
$xml = $this->parseFile($this->file);
|
||||
|
||||
$this->classes = array();
|
||||
|
||||
foreach ($xml->namespace as $namespace) {
|
||||
$this->addNamespaceAlias((string) $namespace['prefix'], trim((string) $namespace));
|
||||
}
|
||||
|
||||
foreach ($xml->class as $class) {
|
||||
$this->classes[(string) $class['name']] = $class;
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($this->classes[$metadata->getClassName()])) {
|
||||
$classDescription = $this->classes[$metadata->getClassName()];
|
||||
|
||||
$this->loadClassMetadataFromXml($metadata, $classDescription);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses a collection of "constraint" XML nodes.
|
||||
*
|
||||
* @param \SimpleXMLElement $nodes The XML nodes
|
||||
*
|
||||
* @return array The Constraint instances
|
||||
*/
|
||||
protected function parseConstraints(\SimpleXMLElement $nodes)
|
||||
{
|
||||
$constraints = array();
|
||||
|
||||
foreach ($nodes as $node) {
|
||||
if (count($node) > 0) {
|
||||
if (count($node->value) > 0) {
|
||||
$options = $this->parseValues($node->value);
|
||||
} elseif (count($node->constraint) > 0) {
|
||||
$options = $this->parseConstraints($node->constraint);
|
||||
} elseif (count($node->option) > 0) {
|
||||
$options = $this->parseOptions($node->option);
|
||||
} else {
|
||||
$options = array();
|
||||
}
|
||||
} elseif (strlen((string) $node) > 0) {
|
||||
$options = XmlUtils::phpize(trim($node));
|
||||
} else {
|
||||
$options = null;
|
||||
}
|
||||
|
||||
$constraints[] = $this->newConstraint((string) $node['name'], $options);
|
||||
}
|
||||
|
||||
return $constraints;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses a collection of "value" XML nodes.
|
||||
*
|
||||
* @param \SimpleXMLElement $nodes The XML nodes
|
||||
*
|
||||
* @return array The values
|
||||
*/
|
||||
protected function parseValues(\SimpleXMLElement $nodes)
|
||||
{
|
||||
$values = array();
|
||||
|
||||
foreach ($nodes as $node) {
|
||||
if (count($node) > 0) {
|
||||
if (count($node->value) > 0) {
|
||||
$value = $this->parseValues($node->value);
|
||||
} elseif (count($node->constraint) > 0) {
|
||||
$value = $this->parseConstraints($node->constraint);
|
||||
} else {
|
||||
$value = array();
|
||||
}
|
||||
} else {
|
||||
$value = trim($node);
|
||||
}
|
||||
|
||||
if (isset($node['key'])) {
|
||||
$values[(string) $node['key']] = $value;
|
||||
} else {
|
||||
$values[] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
return $values;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses a collection of "option" XML nodes.
|
||||
*
|
||||
* @param \SimpleXMLElement $nodes The XML nodes
|
||||
*
|
||||
* @return array The options
|
||||
*/
|
||||
protected function parseOptions(\SimpleXMLElement $nodes)
|
||||
{
|
||||
$options = array();
|
||||
|
||||
foreach ($nodes as $node) {
|
||||
if (count($node) > 0) {
|
||||
if (count($node->value) > 0) {
|
||||
$value = $this->parseValues($node->value);
|
||||
} elseif (count($node->constraint) > 0) {
|
||||
$value = $this->parseConstraints($node->constraint);
|
||||
} else {
|
||||
$value = array();
|
||||
}
|
||||
} else {
|
||||
$value = XmlUtils::phpize($node);
|
||||
if (is_string($value)) {
|
||||
$value = trim($value);
|
||||
}
|
||||
}
|
||||
|
||||
$options[(string) $node['name']] = $value;
|
||||
}
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads the XML class descriptions from the given file.
|
||||
*
|
||||
* @param string $path The path of the XML file
|
||||
*
|
||||
* @return \SimpleXMLElement The class descriptions
|
||||
*
|
||||
* @throws MappingException If the file could not be loaded
|
||||
*/
|
||||
protected function parseFile($path)
|
||||
{
|
||||
try {
|
||||
$dom = XmlUtils::loadFile($path, __DIR__.'/schema/dic/constraint-mapping/constraint-mapping-1.0.xsd');
|
||||
} catch (\Exception $e) {
|
||||
throw new MappingException($e->getMessage(), $e->getCode(), $e);
|
||||
}
|
||||
|
||||
return simplexml_import_dom($dom);
|
||||
}
|
||||
|
||||
private function loadClassMetadataFromXml(ClassMetadata $metadata, \SimpleXMLElement $classDescription)
|
||||
{
|
||||
if (count($classDescription->{'group-sequence-provider'}) > 0) {
|
||||
$metadata->setGroupSequenceProvider(true);
|
||||
}
|
||||
|
||||
foreach ($classDescription->{'group-sequence'} as $groupSequence) {
|
||||
if (count($groupSequence->value) > 0) {
|
||||
$metadata->setGroupSequence($this->parseValues($groupSequence[0]->value));
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($this->parseConstraints($classDescription->constraint) as $constraint) {
|
||||
$metadata->addConstraint($constraint);
|
||||
}
|
||||
|
||||
foreach ($classDescription->property as $property) {
|
||||
foreach ($this->parseConstraints($property->constraint) as $constraint) {
|
||||
$metadata->addPropertyConstraint((string) $property['name'], $constraint);
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($classDescription->getter as $getter) {
|
||||
foreach ($this->parseConstraints($getter->constraint) as $constraint) {
|
||||
$metadata->addGetterConstraint((string) $getter['property'], $constraint);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
31
web/vendor/symfony/validator/Mapping/Loader/XmlFilesLoader.php
vendored
Normal file
31
web/vendor/symfony/validator/Mapping/Loader/XmlFilesLoader.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\Validator\Mapping\Loader;
|
||||
|
||||
/**
|
||||
* Loads validation metadata from a list of XML files.
|
||||
*
|
||||
* @author Bulat Shakirzyanov <mallluhuct@gmail.com>
|
||||
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||
*
|
||||
* @see FilesLoader
|
||||
*/
|
||||
class XmlFilesLoader extends FilesLoader
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getFileLoaderInstance($file)
|
||||
{
|
||||
return new XmlFileLoader($file);
|
||||
}
|
||||
}
|
178
web/vendor/symfony/validator/Mapping/Loader/YamlFileLoader.php
vendored
Normal file
178
web/vendor/symfony/validator/Mapping/Loader/YamlFileLoader.php
vendored
Normal file
|
@ -0,0 +1,178 @@
|
|||
<?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\Validator\Mapping\Loader;
|
||||
|
||||
use Symfony\Component\Validator\Mapping\ClassMetadata;
|
||||
use Symfony\Component\Yaml\Exception\ParseException;
|
||||
use Symfony\Component\Yaml\Parser as YamlParser;
|
||||
|
||||
/**
|
||||
* Loads validation metadata from a YAML file.
|
||||
*
|
||||
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||
*/
|
||||
class YamlFileLoader extends FileLoader
|
||||
{
|
||||
/**
|
||||
* An array of YAML class descriptions.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $classes = null;
|
||||
|
||||
/**
|
||||
* Caches the used YAML parser.
|
||||
*
|
||||
* @var YamlParser
|
||||
*/
|
||||
private $yamlParser;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function loadClassMetadata(ClassMetadata $metadata)
|
||||
{
|
||||
if (null === $this->classes) {
|
||||
if (null === $this->yamlParser) {
|
||||
$this->yamlParser = new YamlParser();
|
||||
}
|
||||
|
||||
$this->classes = $this->parseFile($this->file);
|
||||
|
||||
if (isset($this->classes['namespaces'])) {
|
||||
foreach ($this->classes['namespaces'] as $alias => $namespace) {
|
||||
$this->addNamespaceAlias($alias, $namespace);
|
||||
}
|
||||
|
||||
unset($this->classes['namespaces']);
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($this->classes[$metadata->getClassName()])) {
|
||||
$classDescription = $this->classes[$metadata->getClassName()];
|
||||
|
||||
$this->loadClassMetadataFromYaml($metadata, $classDescription);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses a collection of YAML nodes.
|
||||
*
|
||||
* @param array $nodes The YAML nodes
|
||||
*
|
||||
* @return array An array of values or Constraint instances
|
||||
*/
|
||||
protected function parseNodes(array $nodes)
|
||||
{
|
||||
$values = array();
|
||||
|
||||
foreach ($nodes as $name => $childNodes) {
|
||||
if (is_numeric($name) && is_array($childNodes) && 1 === count($childNodes)) {
|
||||
$options = current($childNodes);
|
||||
|
||||
if (is_array($options)) {
|
||||
$options = $this->parseNodes($options);
|
||||
}
|
||||
|
||||
$values[] = $this->newConstraint(key($childNodes), $options);
|
||||
} else {
|
||||
if (is_array($childNodes)) {
|
||||
$childNodes = $this->parseNodes($childNodes);
|
||||
}
|
||||
|
||||
$values[$name] = $childNodes;
|
||||
}
|
||||
}
|
||||
|
||||
return $values;
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads the YAML class descriptions from the given file.
|
||||
*
|
||||
* @param string $path The path of the YAML file
|
||||
*
|
||||
* @return array The class descriptions
|
||||
*
|
||||
* @throws \InvalidArgumentException If the file could not be loaded or did
|
||||
* not contain a YAML array
|
||||
*/
|
||||
private function parseFile($path)
|
||||
{
|
||||
try {
|
||||
$classes = $this->yamlParser->parse(file_get_contents($path));
|
||||
} catch (ParseException $e) {
|
||||
throw new \InvalidArgumentException(sprintf('The file "%s" does not contain valid YAML.', $path), 0, $e);
|
||||
}
|
||||
|
||||
// empty file
|
||||
if (null === $classes) {
|
||||
return array();
|
||||
}
|
||||
|
||||
// not an array
|
||||
if (!is_array($classes)) {
|
||||
throw new \InvalidArgumentException(sprintf('The file "%s" must contain a YAML array.', $this->file));
|
||||
}
|
||||
|
||||
return $classes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads the validation metadata from the given YAML class description.
|
||||
*
|
||||
* @param ClassMetadata $metadata The metadata to load
|
||||
* @param array $classDescription The YAML class description
|
||||
*/
|
||||
private function loadClassMetadataFromYaml(ClassMetadata $metadata, array $classDescription)
|
||||
{
|
||||
if (isset($classDescription['group_sequence_provider'])) {
|
||||
$metadata->setGroupSequenceProvider(
|
||||
(bool) $classDescription['group_sequence_provider']
|
||||
);
|
||||
}
|
||||
|
||||
if (isset($classDescription['group_sequence'])) {
|
||||
$metadata->setGroupSequence($classDescription['group_sequence']);
|
||||
}
|
||||
|
||||
if (isset($classDescription['constraints']) && is_array($classDescription['constraints'])) {
|
||||
foreach ($this->parseNodes($classDescription['constraints']) as $constraint) {
|
||||
$metadata->addConstraint($constraint);
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($classDescription['properties']) && is_array($classDescription['properties'])) {
|
||||
foreach ($classDescription['properties'] as $property => $constraints) {
|
||||
if (null !== $constraints) {
|
||||
foreach ($this->parseNodes($constraints) as $constraint) {
|
||||
$metadata->addPropertyConstraint($property, $constraint);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($classDescription['getters']) && is_array($classDescription['getters'])) {
|
||||
foreach ($classDescription['getters'] as $getter => $constraints) {
|
||||
if (null !== $constraints) {
|
||||
foreach ($this->parseNodes($constraints) as $constraint) {
|
||||
$metadata->addGetterConstraint($getter, $constraint);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
31
web/vendor/symfony/validator/Mapping/Loader/YamlFilesLoader.php
vendored
Normal file
31
web/vendor/symfony/validator/Mapping/Loader/YamlFilesLoader.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\Validator\Mapping\Loader;
|
||||
|
||||
/**
|
||||
* Loads validation metadata from a list of YAML files.
|
||||
*
|
||||
* @author Bulat Shakirzyanov <mallluhuct@gmail.com>
|
||||
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||
*
|
||||
* @see FilesLoader
|
||||
*/
|
||||
class YamlFilesLoader extends FilesLoader
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getFileLoaderInstance($file)
|
||||
{
|
||||
return new YamlFileLoader($file);
|
||||
}
|
||||
}
|
160
web/vendor/symfony/validator/Mapping/Loader/schema/dic/constraint-mapping/constraint-mapping-1.0.xsd
vendored
Normal file
160
web/vendor/symfony/validator/Mapping/Loader/schema/dic/constraint-mapping/constraint-mapping-1.0.xsd
vendored
Normal file
|
@ -0,0 +1,160 @@
|
|||
<?xml version="1.0" ?>
|
||||
|
||||
<xsd:schema xmlns="http://symfony.com/schema/dic/constraint-mapping"
|
||||
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
|
||||
targetNamespace="http://symfony.com/schema/dic/constraint-mapping"
|
||||
elementFormDefault="qualified">
|
||||
|
||||
<xsd:annotation>
|
||||
<xsd:documentation><![CDATA[
|
||||
Symfony Validator Constraint Mapping Schema, version 1.0
|
||||
Authors: Bernhard Schussek
|
||||
|
||||
A constraint mapping connects classes, properties and getters with
|
||||
validation constraints.
|
||||
]]></xsd:documentation>
|
||||
</xsd:annotation>
|
||||
|
||||
<xsd:element name="constraint-mapping" type="constraint-mapping" />
|
||||
|
||||
<xsd:complexType name="constraint-mapping">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation><![CDATA[
|
||||
The root element of the constraint mapping definition.
|
||||
]]></xsd:documentation>
|
||||
</xsd:annotation>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="namespace" type="namespace" minOccurs="0" maxOccurs="unbounded" />
|
||||
<xsd:element name="class" type="class" maxOccurs="unbounded" />
|
||||
</xsd:sequence>
|
||||
</xsd:complexType>
|
||||
|
||||
<xsd:complexType name="namespace">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation><![CDATA[
|
||||
Contains the abbreviation for a namespace.
|
||||
]]></xsd:documentation>
|
||||
</xsd:annotation>
|
||||
<xsd:simpleContent>
|
||||
<xsd:extension base="xsd:string">
|
||||
<xsd:attribute name="prefix" type="xsd:string" use="required" />
|
||||
</xsd:extension>
|
||||
</xsd:simpleContent>
|
||||
</xsd:complexType>
|
||||
|
||||
<xsd:complexType name="class">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation><![CDATA[
|
||||
Contains constraints for a single class.
|
||||
|
||||
Nested elements may be class constraints, property and/or getter
|
||||
definitions.
|
||||
]]></xsd:documentation>
|
||||
</xsd:annotation>
|
||||
<xsd:choice minOccurs="0" maxOccurs="unbounded">
|
||||
<xsd:element name="group-sequence-provider" type="group-sequence-provider" minOccurs="0" maxOccurs="1" />
|
||||
<xsd:element name="group-sequence" type="group-sequence" minOccurs="0" maxOccurs="1" />
|
||||
<xsd:element name="constraint" type="constraint" minOccurs="0" maxOccurs="unbounded" />
|
||||
<xsd:element name="property" type="property" minOccurs="0" maxOccurs="unbounded" />
|
||||
<xsd:element name="getter" type="getter" minOccurs="0" maxOccurs="unbounded" />
|
||||
</xsd:choice>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
|
||||
<xsd:complexType name="group-sequence">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation><![CDATA[
|
||||
Contains the group sequence of a class. Each group should be written
|
||||
into a "value" tag.
|
||||
]]></xsd:documentation>
|
||||
</xsd:annotation>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="value" minOccurs="1" maxOccurs="unbounded" />
|
||||
</xsd:sequence>
|
||||
</xsd:complexType>
|
||||
|
||||
<xsd:complexType name="group-sequence-provider">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation><![CDATA[
|
||||
Defines the name of the group sequence provider for a class.
|
||||
]]></xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:complexType>
|
||||
|
||||
<xsd:complexType name="property">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation><![CDATA[
|
||||
Contains constraints for a single property. The name of the property
|
||||
should be given in the "name" option.
|
||||
]]></xsd:documentation>
|
||||
</xsd:annotation>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="constraint" type="constraint" maxOccurs="unbounded" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
|
||||
<xsd:complexType name="getter">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation><![CDATA[
|
||||
Contains constraints for a getter method. The name of the corresponding
|
||||
property should be given in the "property" option.
|
||||
]]></xsd:documentation>
|
||||
</xsd:annotation>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="constraint" type="constraint" maxOccurs="unbounded" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="property" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
|
||||
<xsd:complexType name="constraint" mixed="true">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation><![CDATA[
|
||||
Contains a constraint definition. The name of the constraint should be
|
||||
given in the "name" option.
|
||||
|
||||
May contain a single value, multiple "constraint" elements,
|
||||
multiple "value" elements or multiple "option" elements.
|
||||
]]></xsd:documentation>
|
||||
</xsd:annotation>
|
||||
<xsd:choice minOccurs="0">
|
||||
<xsd:element name="constraint" type="constraint" minOccurs="1" maxOccurs="unbounded" />
|
||||
<xsd:element name="option" type="option" minOccurs="1" maxOccurs="unbounded" />
|
||||
<xsd:element name="value" type="value" minOccurs="1" maxOccurs="unbounded" />
|
||||
</xsd:choice>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
|
||||
<xsd:complexType name="option" mixed="true">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation><![CDATA[
|
||||
Contains a constraint option definition. The name of the option
|
||||
should be given in the "name" option.
|
||||
|
||||
May contain a single value, multiple "value" elements or multiple
|
||||
"constraint" elements.
|
||||
]]></xsd:documentation>
|
||||
</xsd:annotation>
|
||||
<xsd:choice minOccurs="0">
|
||||
<xsd:element name="constraint" type="constraint" minOccurs="1" maxOccurs="unbounded" />
|
||||
<xsd:element name="value" type="value" minOccurs="1" maxOccurs="unbounded" />
|
||||
</xsd:choice>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
|
||||
<xsd:complexType name="value" mixed="true">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation><![CDATA[
|
||||
A value of an element.
|
||||
|
||||
May contain a single value, multiple "value" elements or multiple
|
||||
"constraint" elements.
|
||||
]]></xsd:documentation>
|
||||
</xsd:annotation>
|
||||
<xsd:choice minOccurs="0">
|
||||
<xsd:element name="constraint" type="constraint" minOccurs="1" maxOccurs="unbounded" />
|
||||
<xsd:element name="value" type="value" minOccurs="1" maxOccurs="unbounded" />
|
||||
</xsd:choice>
|
||||
<xsd:attribute name="key" type="xsd:string" use="optional" />
|
||||
</xsd:complexType>
|
||||
</xsd:schema>
|
Reference in a new issue