@@ -38,26 +38,11 @@ class YamlFileLoader extends FileLoader
38
38
public function loadClassMetadata (ClassMetadataInterface $ classMetadata )
39
39
{
40
40
if (null === $ this ->classes ) {
41
- if (!stream_is_local ($ this ->file )) {
42
- throw new MappingException (sprintf ('This is not a local file "%s". ' , $ this ->file ));
43
- }
44
-
45
- if (null === $ this ->yamlParser ) {
46
- $ this ->yamlParser = new Parser ();
47
- }
48
-
49
- $ classes = $ this ->yamlParser ->parse (file_get_contents ($ this ->file ));
50
-
51
- if (empty ($ classes )) {
52
- return false ;
53
- }
54
-
55
- // not an array
56
- if (!is_array ($ classes )) {
57
- throw new MappingException (sprintf ('The file "%s" must contain a YAML array. ' , $ this ->file ));
58
- }
41
+ $ this ->classes = $ this ->getClassesFromYaml ();
42
+ }
59
43
60
- $ this ->classes = $ classes ;
44
+ if (!$ this ->classes ) {
45
+ return false ;
61
46
}
62
47
63
48
if (isset ($ this ->classes [$ classMetadata ->getName ()])) {
@@ -103,4 +88,41 @@ public function loadClassMetadata(ClassMetadataInterface $classMetadata)
103
88
104
89
return false ;
105
90
}
91
+
92
+ /**
93
+ * Return the names of the classes mapped in this file.
94
+ *
95
+ * @return string[] The classes names
96
+ */
97
+ public function getMappedClasses ()
98
+ {
99
+ if (null === $ this ->classes ) {
100
+ $ this ->classes = $ this ->getClassesFromYaml ();
101
+ }
102
+
103
+ return array_keys ($ this ->classes );
104
+ }
105
+
106
+ private function getClassesFromYaml ()
107
+ {
108
+ if (!stream_is_local ($ this ->file )) {
109
+ throw new MappingException (sprintf ('This is not a local file "%s". ' , $ this ->file ));
110
+ }
111
+
112
+ if (null === $ this ->yamlParser ) {
113
+ $ this ->yamlParser = new Parser ();
114
+ }
115
+
116
+ $ classes = $ this ->yamlParser ->parse (file_get_contents ($ this ->file ));
117
+
118
+ if (empty ($ classes )) {
119
+ return array ();
120
+ }
121
+
122
+ if (!is_array ($ classes )) {
123
+ throw new MappingException (sprintf ('The file "%s" must contain a YAML array. ' , $ this ->file ));
124
+ }
125
+
126
+ return $ classes ;
127
+ }
106
128
}
0 commit comments