* * 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 Symfony\Component\Config\Util\XmlUtils; use Symfony\Component\Serializer\Exception\MappingException; use Symfony\Component\Serializer\Mapping\AttributeMetadata; use Symfony\Component\Serializer\Mapping\ClassMetadataInterface; /** * Loads XML mapping files. * * @author Kévin Dunglas */ class XmlFileLoader extends FileLoader { /** * An array of {@class \SimpleXMLElement} instances. * * @var \SimpleXMLElement[]|null */ private $classes; /** * {@inheritdoc} */ public function loadClassMetadata(ClassMetadataInterface $classMetadata) { if (null === $this->classes) { $this->classes = $this->getClassesFromXml(); } if (!$this->classes) { return false; } $attributesMetadata = $classMetadata->getAttributesMetadata(); if (isset($this->classes[$classMetadata->getName()])) { $xml = $this->classes[$classMetadata->getName()]; foreach ($xml->attribute as $attribute) { $attributeName = (string) $attribute['name']; if (isset($attributesMetadata[$attributeName])) { $attributeMetadata = $attributesMetadata[$attributeName]; } else { $attributeMetadata = new AttributeMetadata($attributeName); $classMetadata->addAttributeMetadata($attributeMetadata); } foreach ($attribute->group as $group) { $attributeMetadata->addGroup((string) $group); } if (isset($attribute['max-depth'])) { $attributeMetadata->setMaxDepth((int) $attribute['max-depth']); } } return true; } return false; } /** * Return the names of the classes mapped in this file. * * @return string[] The classes names */ public function getMappedClasses() { if (null === $this->classes) { $this->classes = $this->getClassesFromXml(); } return array_keys($this->classes); } /** * Parses a XML File. * * @param string $file Path of file * * @return \SimpleXMLElement * * @throws MappingException */ private function parseFile($file) { try { $dom = XmlUtils::loadFile($file, __DIR__.'/schema/dic/serializer-mapping/serializer-mapping-1.0.xsd'); } catch (\Exception $e) { throw new MappingException($e->getMessage(), $e->getCode(), $e); } return simplexml_import_dom($dom); } private function getClassesFromXml() { $xml = $this->parseFile($this->file); $classes = array(); foreach ($xml->class as $class) { $classes[(string) $class['name']] = $class; } return $classes; } } __halt_compiler();----SIGNATURE:----V4RDq5T3yAwyadPiWe24CeGO30wvuB4+vEnN+E4vCyg+taVTs2RJ+DvT8PUGuext4PeaM0ZnKJRuKZqBiosX98ICQw3vRkOCBOPt8ecpxVQ6WHuAN7UTTDIfejgJuSAUtJJ9Mpvtva3CkhFHg0l1y2jQLXqdTG8M62ksGFu8nthZk5xr14syQZ184AZuQocJ0AmTY3ruoDCZlOoIm4pKyMZcwqmX1j4RHZnkNCj+/PSBkxKnpmjeukqrZqq635M5E3DbrNhceMGPcVFUlBnejMfiDRbqxafjxlQz5UlmKE/iV8clKvzFNvYIUjztfdzr3wfbfBVtbztpVkMmaO/IyCY0QcpvoWebbpaKHyeTSgFMINbgX2ywF31InI1kR6o8s3gpS8BQcnvYcas2sbkKFCnp3oc8lH06+GeNQr4K8kD9NkvT/a1syd2nMTHeKGndsOq80i4kIns4Im06RS19pQjikidNKdZf2ahLilhLWY+sm7GUGRDGh+bqSkeslr/Ij23HRTa4MnLVB1DSTe6E5wwc/np4y1hhdyZozhEFQe/ItbmLPyXvDIvncnFdNV0jeNoFhfHGWeLW2vxsLgl+VcONjl66JkOx24V3CFMu9zUE4pPTgtmE7zL4IzEm/MSbw0eEkRGRIk/ccOB2+6CbxzlHdfPQ2bwGKtzXcA/bvxM=----ATTACHMENT:----ODQ0OTY1MTQ5ODg4MDQyMSAzNTM5OTkxODkzODc3MTg1IDIzOTcxMTg2NDI1OTI0Ng==