Security update for Core, with self-updated composer
[yaffs-website] / vendor / symfony / validator / Mapping / Loader / XmlFileLoader.php
index 8bcdf9f97ef94d6c2af58469a9da99421f217f21..6548c5aecea485c53c71278c63f403ad23e6a692 100644 (file)
@@ -35,19 +35,7 @@ class XmlFileLoader extends FileLoader
     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;
-            }
+            $this->loadClassesFromXml();
         }
 
         if (isset($this->classes[$metadata->getClassName()])) {
@@ -61,6 +49,20 @@ class XmlFileLoader extends FileLoader
         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->loadClassesFromXml();
+        }
+
+        return array_keys($this->classes);
+    }
+
     /**
      * Parses a collection of "constraint" XML nodes.
      *
@@ -182,6 +184,23 @@ class XmlFileLoader extends FileLoader
         return simplexml_import_dom($dom);
     }
 
+    private function loadClassesFromXml()
+    {
+        // 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;
+        }
+    }
+
     private function loadClassMetadataFromXml(ClassMetadata $metadata, \SimpleXMLElement $classDescription)
     {
         if (count($classDescription->{'group-sequence-provider'}) > 0) {