* * 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:----McgGv/9g70d4zg0ZYdKncdFxMm/XeeFQ9QBYKC+vRQ7/cGLsm3Ap7PDr5/Sxld+ClaTgbr6Gj4y/Q3EgKrE25PUzbUp5w1i4vrSZ4233IRGfWr5+U3yuJQOwgrr+CGCndCrGTQo7iS7D5scXPeUc+2APcibqwfdJ2VtthB/NIOteNPZgj2Tmp5senspiozjCnVWJGijuq+cpJav4DsAaoeTv4lNLixNMh6fjd/+sLOTiqr7xEVSdvcmoCjnf84j8dCV7gP5YTkLIgl5ATC99pjEe9F1tDOLD3gNsn7HJwEn8T6WEPfi1POGSENGvU2LXKkQ4cGnHpB8Wq6Uzxen8ZJkT5Df/zOoRznUoXK/YMK4aOSrBJ/FjyB0MV8u919I7x+w7knsSgGoklw5gg5kMORgeIbSF9SGBmu0HY0lzY4EzTLE3hH9xyl9rDq1mCbAb2UGmBP9MODy5RvHmpbrKRcGWgfc3FEJspjXdFregFza4cq62PB48XbJwpjELUNQcWY8QqnQ0kS5An43iohcttgND2sgGUEZgZ1VqEAf53Mmb/l/TDu3S7jtTM56K20wxS23+hWTZ4Jj9EK7zUf+arM7PHUKkRDpPI7AJIWqDFaJDyS3hQ4uNbiO2rBVDUlld54zgCUK7sgJVFzRlPLHAkXBXau427qMEVavUjShnfIA=----ATTACHMENT:----NDI1MjIyMzU4MTk0MDg2MCAyMjkwMDk0NjM3ODIyNjUyIDc2ODQzNjczMDQxNzc2NTA=