Ejemplo n.º 1
0
 public function format(Event $event)
 {
     $format = $this->getFormat();
     // Process timestamp
     preg_match('/%timestamp:(.*?)%/', $format, $matches);
     list($timestampTag, $timestampFormat) = $matches;
     $timestamp = date($timestampFormat, $event->getTimestamp());
     $format = str_replace($timestampTag, $timestamp, $format);
     // Process the other items
     $extras = array();
     foreach ($event->getExtras() as $name => $value) {
         $extras[] = $name . ': ' . $value;
     }
     $data = array('%extras%' => implode(', ', $extras), '%message%' => $event->getMessage(), '%picture%' => $event->getPicture(), '%title%' => $event->getTitle(), '%type%' => $event->getType());
     return strtr($format . $this->getEol(), $data);
 }
Ejemplo n.º 2
0
 public function format(Event $event)
 {
     $encoding = $this->getEncoding();
     $dom = new \DOMDocument('1.0', $encoding);
     $rootNode = $dom->appendChild(new \DOMElement('event'));
     $data = array('type' => $event->getType(), 'timestamp' => $event->getTimestamp(), 'title' => $event->getTitle(), 'message' => $event->getMessage(), 'picture' => $event->getPicture());
     foreach ($data as $name => $value) {
         $this->appendNode($rootNode, $name, $value);
     }
     $extrasNode = $rootNode->appendChild(new \DOMElement('extras'));
     foreach ($event->getExtras() as $name => $value) {
         $this->appendNode($extrasNode, $name, $value);
     }
     $xml = $dom->saveXML();
     // Remove XML protocol
     $xml = preg_replace('/<\\?xml version="1.0"( encoding="[^\\"]*")?\\?>\\n/u', '', $xml);
     return $xml;
 }
Ejemplo n.º 3
0
 public function format(Event $event)
 {
     $data = array('type' => $event->getType(), 'timestamp' => $event->getTimestamp(), 'title' => $event->getTitle(), 'message' => $event->getMessage(), 'picture' => $event->getPicture(), 'extras' => $event->getExtras());
     return json_encode($data);
 }