Added the zend framework 2 library, the path is specified in line no.26 in zend_modul...
[openemr.git] / interface / modules / zend_modules / library / Zend / Log / Formatter / ErrorHandler.php
blob334ac0c489aa4d3dd0dd0871f6197902437b6da9
1 <?php
2 /**
3 * Zend Framework (http://framework.zend.com/)
5 * @link http://github.com/zendframework/zf2 for the canonical source repository
6 * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
7 * @license http://framework.zend.com/license/new-bsd New BSD License
8 */
10 namespace Zend\Log\Formatter;
12 use DateTime;
14 class ErrorHandler extends Simple
16 const DEFAULT_FORMAT = '%timestamp% %priorityName% (%priority%) %message% (errno %extra[errno]%) in %extra[file]% on line %extra[line]%';
18 /**
19 * This method formats the event for the PHP Error Handler.
21 * @param array $event
22 * @return string
24 public function format($event)
26 $output = $this->format;
28 if (isset($event['timestamp']) && $event['timestamp'] instanceof DateTime) {
29 $event['timestamp'] = $event['timestamp']->format($this->getDateTimeFormat());
32 foreach ($this->buildReplacementsFromArray($event) as $name => $value) {
33 $output = str_replace("%$name%", $value, $output);
36 return $output;
39 /**
40 * Flatten the multi-dimensional $event array into a single dimensional
41 * array
43 * @param array $event
44 * @param string $key
45 * @return array
47 protected function buildReplacementsFromArray($event, $key = null)
49 $result = array();
50 foreach ($event as $index => $value) {
51 $nextIndex = $key === null ? $index : $key . '[' . $index . ']';
52 if ($value === null) {
53 continue;
55 if (! is_array($value)) {
56 if ($key === null) {
57 $result[$nextIndex] = $value;
58 } else {
59 if (! is_object($value) || method_exists($value, "__toString")) {
60 $result[$nextIndex] = $value;
63 } else {
64 $result = array_merge($result, $this->buildReplacementsFromArray($value, $nextIndex));
67 return $result;