1 | <?php |
||
27 | class XliffLoader extends XliffFileLoader |
||
28 | { |
||
29 | /** |
||
30 | * @var SymfonyPort|null |
||
31 | */ |
||
32 | private $sfPort; |
||
33 | |||
34 | /** |
||
35 | * {@inheritdoc} |
||
36 | */ |
||
37 | 6 | public function load($resource, $locale, $domain = 'messages') |
|
57 | |||
58 | /** |
||
59 | * @param string $content xml content |
||
60 | * @param MessageCatalogue $catalogue |
||
61 | * @param string $domain |
||
62 | */ |
||
63 | 12 | public function extractFromContent($content, MessageCatalogue $catalogue, $domain) |
|
100 | |||
101 | /** |
||
102 | * Loads an XML file. |
||
103 | * |
||
104 | * Taken and modified from Symfony\Component\Config\Util\XmlUtils |
||
105 | * |
||
106 | * @author Fabien Potencier <[email protected]> |
||
107 | * @author Martin Hasoň <[email protected]> |
||
108 | * |
||
109 | * @param string $content An XML file path |
||
110 | * |
||
111 | * @return \DOMDocument |
||
112 | * |
||
113 | * @throws \InvalidArgumentException When loading of XML file returns error |
||
114 | */ |
||
115 | 12 | private function loadFileContent($content) |
|
116 | { |
||
117 | 12 | if ('' === trim($content)) { |
|
118 | 1 | throw new \InvalidArgumentException('Content does not contain valid XML, it is empty.'); |
|
119 | } |
||
120 | |||
121 | 11 | $internalErrors = libxml_use_internal_errors(true); |
|
122 | 11 | $disableEntities = libxml_disable_entity_loader(true); |
|
123 | 11 | libxml_clear_errors(); |
|
124 | |||
125 | 11 | $dom = new \DOMDocument(); |
|
126 | 11 | $dom->validateOnParse = true; |
|
127 | 11 | if (!$dom->loadXML($content, LIBXML_NONET | (defined('LIBXML_COMPACT') ? LIBXML_COMPACT : 0))) { |
|
128 | 1 | libxml_disable_entity_loader($disableEntities); |
|
129 | |||
130 | 1 | throw new \InvalidArgumentException(implode("\n", static::getXmlErrors($internalErrors))); |
|
131 | } |
||
132 | |||
133 | 10 | $dom->normalizeDocument(); |
|
134 | |||
135 | 10 | libxml_use_internal_errors($internalErrors); |
|
136 | 10 | libxml_disable_entity_loader($disableEntities); |
|
137 | |||
138 | 10 | foreach ($dom->childNodes as $child) { |
|
139 | 10 | if (XML_DOCUMENT_TYPE_NODE === $child->nodeType) { |
|
140 | throw new \InvalidArgumentException('Document types are not allowed.'); |
||
141 | } |
||
142 | } |
||
143 | |||
144 | 10 | libxml_clear_errors(); |
|
145 | 10 | libxml_use_internal_errors($internalErrors); |
|
146 | |||
147 | 10 | return $dom; |
|
148 | } |
||
149 | |||
150 | 1 | private function getXmlErrors($internalErrors) |
|
170 | } |
||
171 |
This method has been deprecated. The supplier of the class has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.