|
|
@@ -19,9 +19,8 @@
|
|
|
namespace Cake\Utility;
|
|
|
|
|
|
use Cake\Core\Configure;
|
|
|
-use Cake\Network\Error;
|
|
|
+use Cake\Network\Error\SocketException;
|
|
|
use Cake\Network\Http\Client;
|
|
|
-use Cake\Utility\Error\XmlException;
|
|
|
use \DOMDocument;
|
|
|
|
|
|
/**
|
|
|
@@ -105,16 +104,16 @@ class Xml {
|
|
|
$socket = new Client(['redirect' => 10]);
|
|
|
$response = $socket->get($input);
|
|
|
if (!$response->isOk()) {
|
|
|
- throw new XmlException('XML cannot be read.');
|
|
|
+ throw new Error\XmlException('XML cannot be read.');
|
|
|
}
|
|
|
return static::_loadXml($response->body, $options);
|
|
|
} catch (SocketException $e) {
|
|
|
- throw new XmlException('XML cannot be read.');
|
|
|
+ throw new Error\XmlException('XML cannot be read.');
|
|
|
}
|
|
|
} elseif (!is_string($input)) {
|
|
|
- throw new XmlException('Invalid input.');
|
|
|
+ throw new Error\XmlException('Invalid input.');
|
|
|
}
|
|
|
- throw new XmlException('XML cannot be read.');
|
|
|
+ throw new Error\XmlException('XML cannot be read.');
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -146,7 +145,7 @@ class Xml {
|
|
|
}
|
|
|
libxml_use_internal_errors($internalErrors);
|
|
|
if ($xml === null) {
|
|
|
- throw new XmlException('Xml cannot be read.');
|
|
|
+ throw new Error\XmlException('Xml cannot be read.');
|
|
|
}
|
|
|
return $xml;
|
|
|
}
|
|
|
@@ -191,11 +190,11 @@ class Xml {
|
|
|
*/
|
|
|
public static function fromArray(array $input, $options = array()) {
|
|
|
if (!is_array($input) || count($input) !== 1) {
|
|
|
- throw new XmlException('Invalid input.');
|
|
|
+ throw new Error\XmlException('Invalid input.');
|
|
|
}
|
|
|
$key = key($input);
|
|
|
if (is_int($key)) {
|
|
|
- throw new XmlException('The key of input must be alphanumeric');
|
|
|
+ throw new Error\XmlException('The key of input must be alphanumeric');
|
|
|
}
|
|
|
|
|
|
if (!is_array($options)) {
|
|
|
@@ -272,7 +271,7 @@ class Xml {
|
|
|
}
|
|
|
} else {
|
|
|
if ($key[0] === '@') {
|
|
|
- throw new XmlException('Invalid array');
|
|
|
+ throw new Error\XmlException('Invalid array');
|
|
|
}
|
|
|
if (is_numeric(implode('', array_keys($value)))) { // List
|
|
|
foreach ($value as $item) {
|
|
|
@@ -285,7 +284,7 @@ class Xml {
|
|
|
}
|
|
|
}
|
|
|
} else {
|
|
|
- throw new XmlException('Invalid array');
|
|
|
+ throw new Error\XmlException('Invalid array');
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -336,7 +335,7 @@ class Xml {
|
|
|
$obj = simplexml_import_dom($obj);
|
|
|
}
|
|
|
if (!($obj instanceof \SimpleXMLElement)) {
|
|
|
- throw new XmlException('The input is not instance of SimpleXMLElement, DOMDocument or DOMNode.');
|
|
|
+ throw new Error\XmlException('The input is not instance of SimpleXMLElement, DOMDocument or DOMNode.');
|
|
|
}
|
|
|
$result = array();
|
|
|
$namespaces = array_merge(array('' => ''), $obj->getNamespaces(true));
|