* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Serializer\Mapping\Loader; use Doctrine\Common\Annotations\Reader; use Symfony\Component\Serializer\Annotation\Groups; use Symfony\Component\Serializer\Annotation\MaxDepth; use Symfony\Component\Serializer\Exception\MappingException; use Symfony\Component\Serializer\Mapping\AttributeMetadata; use Symfony\Component\Serializer\Mapping\ClassMetadataInterface; /** * Annotation loader. * * @author Kévin Dunglas */ class AnnotationLoader implements LoaderInterface { private $reader; public function __construct(Reader $reader) { $this->reader = $reader; } /** * {@inheritdoc} */ public function loadClassMetadata(ClassMetadataInterface $classMetadata) { $reflectionClass = $classMetadata->getReflectionClass(); $className = $reflectionClass->name; $loaded = false; $attributesMetadata = $classMetadata->getAttributesMetadata(); foreach ($reflectionClass->getProperties() as $property) { if (!isset($attributesMetadata[$property->name])) { $attributesMetadata[$property->name] = new AttributeMetadata($property->name); $classMetadata->addAttributeMetadata($attributesMetadata[$property->name]); } if ($property->getDeclaringClass()->name === $className) { foreach ($this->reader->getPropertyAnnotations($property) as $annotation) { if ($annotation instanceof Groups) { foreach ($annotation->getGroups() as $group) { $attributesMetadata[$property->name]->addGroup($group); } } elseif ($annotation instanceof MaxDepth) { $attributesMetadata[$property->name]->setMaxDepth($annotation->getMaxDepth()); } $loaded = true; } } } foreach ($reflectionClass->getMethods() as $method) { if ($method->getDeclaringClass()->name !== $className) { continue; } $accessorOrMutator = preg_match('/^(get|is|has|set)(.+)$/i', $method->name, $matches); if ($accessorOrMutator) { $attributeName = lcfirst($matches[2]); if (isset($attributesMetadata[$attributeName])) { $attributeMetadata = $attributesMetadata[$attributeName]; } else { $attributesMetadata[$attributeName] = $attributeMetadata = new AttributeMetadata($attributeName); $classMetadata->addAttributeMetadata($attributeMetadata); } } foreach ($this->reader->getMethodAnnotations($method) as $annotation) { if ($annotation instanceof Groups) { if (!$accessorOrMutator) { throw new MappingException(sprintf('Groups on "%s::%s" cannot be added. Groups can only be added on methods beginning with "get", "is", "has" or "set".', $className, $method->name)); } foreach ($annotation->getGroups() as $group) { $attributeMetadata->addGroup($group); } } elseif ($annotation instanceof MaxDepth) { if (!$accessorOrMutator) { throw new MappingException(sprintf('MaxDepth on "%s::%s" cannot be added. MaxDepth can only be added on methods beginning with "get", "is", "has" or "set".', $className, $method->name)); } $attributeMetadata->setMaxDepth($annotation->getMaxDepth()); } $loaded = true; } } return $loaded; } } __halt_compiler();----SIGNATURE:----JNE+j87xgOw63FgvEyQJC5eZ5CotT/g9+dmVPTTXr2qNS2RactCxsCikyL8vApvR8fEZ3NrbO6KOyrTfPy4jAUWI1MQlpq5a0sxEyBctwYsCeqhBZu8ULNfDaIKjGPX47Ks4KSNbnvZUh8aF+5LJSw1SEBIOBAAAdPx6nHchpUu34cqsZspgmv0odjdSvb9/KZTjZvJovTr7YIdU0H8BDkCePA9ZwgXKVANxfI7IoLG8o0QhUjICh10EvLQ1tnJc+nF1mu6hgwy5ohK60GpHL8H65HnjDO4Up2P00lKe5YqUH9a38DfTEabtCkcMwYVtDT1HpL7qdmr4NtpLu3VGNUQfcnGYAlSi9GjSWdzjvBfW6a0ceyXShSqplhgqcwJ30PY1ekW4+cgDrjGd69nUKCLCrjv+ZZe9WUVeiZHD7g+DN5Jn8Lzs393uquhGeUfLk95YZHmcNTPy3/EhcKyGXCZOeeo67XkbbF1/IN8pfTPEubC+ADAWYFbLPMZKZlt5EgUUzeIQ80KjAhPoozhQzxXwbPzy7jfE/+JoyMuu1HqzhTvWqsL2EF6XvyDlzhO7TwtzrHd2XLQbR73JYLvtvPBjReJ0Apwh6ovA0W8sANtODCtQs4NYvBNymBZlt/rEc5LXM6UDyuUpKVYcCfsNS124ARvo99wgNtm2D+m/o6E=----ATTACHMENT:----MjQ4MTY3MjEwMjU0NjQzIDgyODkwODYwOTQ1NDM1MTAgNDEwMTE5MTYzMDkxMzUz