schema
3 years ago
AbstractLoader.php
4 years ago
AnnotationLoader.php
1 year ago
AutoMappingTrait.php
1 year ago
FileLoader.php
4 years ago
FilesLoader.php
4 years ago
LoaderChain.php
4 years ago
LoaderInterface.php
4 years ago
PropertyInfoLoader.php
1 year ago
StaticMethodLoader.php
4 years ago
XmlFileLoader.php
4 years ago
XmlFilesLoader.php
4 years ago
YamlFileLoader.php
4 years ago
YamlFilesLoader.php
4 years ago
index.php
3 years ago
AbstractLoader.php
30 lines
| 1 | <?php |
| 2 | namespace MailPoetVendor\Symfony\Component\Validator\Mapping\Loader; |
| 3 | if (!defined('ABSPATH')) exit; |
| 4 | use MailPoetVendor\Symfony\Component\Validator\Constraint; |
| 5 | use MailPoetVendor\Symfony\Component\Validator\Exception\MappingException; |
| 6 | abstract class AbstractLoader implements LoaderInterface |
| 7 | { |
| 8 | public const DEFAULT_NAMESPACE = '\\Symfony\\Component\\Validator\\Constraints\\'; |
| 9 | protected $namespaces = []; |
| 10 | protected function addNamespaceAlias(string $alias, string $namespace) |
| 11 | { |
| 12 | $this->namespaces[$alias] = $namespace; |
| 13 | } |
| 14 | protected function newConstraint(string $name, $options = null) |
| 15 | { |
| 16 | if (\str_contains($name, '\\') && \class_exists($name)) { |
| 17 | $className = $name; |
| 18 | } elseif (\str_contains($name, ':')) { |
| 19 | [$prefix, $className] = \explode(':', $name, 2); |
| 20 | if (!isset($this->namespaces[$prefix])) { |
| 21 | throw new MappingException(\sprintf('Undefined namespace prefix "%s".', $prefix)); |
| 22 | } |
| 23 | $className = $this->namespaces[$prefix] . $className; |
| 24 | } else { |
| 25 | $className = self::DEFAULT_NAMESPACE . $name; |
| 26 | } |
| 27 | return new $className($options); |
| 28 | } |
| 29 | } |
| 30 |