Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?PHP
- try
- {
- $ILLI = ILLI::init();
- ILLI::appendStaticInstance('TEST_LOADERS', 'Test/Loader/foo.php', array('foo' => 'bar', 'baz'));
- }
- catch(ILLI_Exception $e)
- {
- print $e->getErrorMessage(ILLI_System_Exception_Export::XML);
- }
- /* output: */
- <?xml version="1.0"?>
- <illi:exception xmlns="http://www.w3.org/2005/Atom" xmlns:illi="http://www.w3.org/2005/Atom">
- <messages>
- <message exception="ILLI_Exception_FileContentExpected" errorcode="0x00010504" level="1">
- <thrown file="/var/www/usr/luc/terminal2/web/dev/ILLI/rev.2.0.0-0/VENDOR/ILLI/Class.php" line="00000134"/>
- <message><![CDATA[Class-file /var/www/usr/luc/terminal2/web/dev/ILLI/rev.2.0.0-0/VENDOR/Test/Loader/foo.php is empty or class-name TEST_LOADERS is invalid.]]></message>
- </message>
- <message exception="ILLI_Exception_SystemStaticInstanceLoad" errorcode="0x00010602" level="2">
- <thrown file="/var/www/usr/luc/terminal2/web/dev/ILLI/rev.2.0.0-0/VENDOR/ILLI/Class.php" line="00000139"/>
- <message><![CDATA[Unable to load instance TEST_LOADERS.]]></message>
- </message>
- <message exception="ILLI_Exception_SystemStaticInstanceAppend" errorcode="0x00010603" level="3">
- <thrown file="/var/www/usr/luc/terminal2/web/dev/ILLI/rev.2.0.0-0/VENDOR/ILLI/Class.php" line="00000098"/>
- <message><![CDATA[Unable to append static instance TEST_LOADERS.]]></message>
- </message>
- </messages>
- <traces>
- <trace>
- <despatcher method="ILLI::appendStaticInstance()" class="ILLI" type="::" function="appendStaticInstance"/>
- <location file="/var/www/usr/luc/terminal2/web/dev/index.php" line="40"/>
- <arguments>
- <argument parameter="1"><![CDATA[
- string(12) "TEST_LOADERS"
- ]]></argument>
- <argument parameter="2"><![CDATA[
- string(19) "Test/Loader/foo.php"
- ]]></argument>
- <argument parameter="3"><![CDATA[
- array(2) {
- ["foo"]=>
- string(3) "bar"
- [0]=>
- string(3) "baz"
- }
- ]]></argument>
- </arguments>
- </trace>
- <trace>
- <despatcher method="ILLI->loadStaticInstances()" class="ILLI" type="->" function="loadStaticInstances"/>
- <location file="/var/www/usr/luc/terminal2/web/dev/ILLI/rev.2.0.0-0/VENDOR/ILLI/Class.php" line="93"/>
- <arguments/>
- </trace>
- </traces>
- </illi:exception>
- /* class */
- <?PHP
- CLASS ILLI_System_Exception_Export_Type_Xml EXTENDS ILLI_System_Exception_Export_Type_Abstract
- {
- private $DOM = NULL;
- private $DOM_MESSAGES = NULL;
- private $DOM_TRACES = NULL;
- private function get_XML()
- {
- if($this->DOM instanceOf DOMDocument)
- return $this->DOM;
- $this->DOM = new DOMDocument;
- $this->DOM->formatOutput = true;
- $this->DOM->preserveWhiteSpace = true;
- $this->DOM->validateOnParse = true;
- return $this->DOM;
- }
- private function get_XMLMessages()
- {
- if(NULL === $this->DOM_MESSAGES)
- $this->DOM_MESSAGES = $this->get_XML()->createElement("messages");
- return $this->DOM_MESSAGES;
- }
- private function get_XMLTraces()
- {
- if(NULL === $this->DOM_TRACES)
- $this->DOM_TRACES = $this->get_XML()->createElement("traces");
- return $this->DOM_TRACES;
- }
- protected function parseMessages(ILLI_System_Exception_Export_Queue_Messages $queue)
- {
- $messages = $this->get_XMLMessages();
- foreach($queue->get() as $item)
- {
- $message = $this->get_XML()->createElement('message');
- $message->setAttribute('exception', $item->getExceptionClass());
- $message->setAttribute('errorcode', $item->getErrorCode());
- $message->setAttribute('level', $item->getErrorLevel());
- $thrown = $this->get_XML()->createElement('thrown');
- $thrown->setAttribute('file', $item->getFile());
- $thrown->setAttribute('line', $item->getLine());
- $messagetext = $this->get_XML()->createElement('message');
- $messagetext->appendChild(new DOMCdataSection($item->getMessage()));
- $message->appendChild($thrown);
- $message->appendChild($messagetext);
- $messages->appendChild($message);
- }
- return $messages;
- }
- protected function parseTraces(ILLI_System_Exception_Export_Queue_Traces $queue)
- {
- $traces = $this->get_XMLTraces();
- foreach($queue->get() as $item)
- {
- $trace = $this->get_XML()->createElement('trace');
- $traces->appendChild($trace);
- $despatcher = $this->get_XML()->createElement('despatcher');
- $trace->appendChild($despatcher);
- $location = $this->get_XML()->createElement('location');
- $trace->appendChild($location);
- $arguments = $this->get_XML()->createElement('arguments');
- $trace->appendChild($arguments);
- $despatcher->setAttribute('method', $item->getClass().$item->getType().$item->getFunction().'()');
- $despatcher->setAttribute('class', $item->getClass());
- $despatcher->setAttribute('type', $item->getType());
- $despatcher->setAttribute('function', $item->getFunction());
- $location->setAttribute('file', $item->getFile());
- $location->setAttribute('line', $item->getLine());
- $p = 0;
- foreach($item->getArgs() as $arg)
- {
- $p++;
- ob_start();
- var_dump($arg);
- $arg = "\n".ob_get_clean();
- $argument = $this->get_XML()->createElement('argument');
- $arguments->appendChild($argument);
- $argument->setAttribute('parameter', $p);
- $argument->appendChild(new DOMCdataSection($arg));
- }
- }
- return $traces;
- }
- protected function parseExportException($parsedMessages, $parsedTraces)
- {
- $root = $this->get_XML()->createElement('illi:exception');
- $root->setAttribute('xmlns', 'http://www.w3.org/2005/Atom');
- $root->setAttribute('xmlns:illi', 'http://www.w3.org/2005/Atom');
- $root->appendChild($this->get_XMLMessages());
- $root->appendChild($this->get_XMLTraces());
- $this->get_XML()->appendChild($root);
- return $this->get_XML()->saveXML();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement