PageRenderTime 48ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/lib/Zend/Wildfire/Plugin/FirePhp.php

https://bitbucket.org/sunil_nextbits/magento2
PHP | 816 lines | 429 code | 126 blank | 261 comment | 90 complexity | 4c3aaad02716cf77c7709aaafb275679 MD5 | raw file
  1. <?php
  2. /**
  3. * Zend Framework
  4. *
  5. * LICENSE
  6. *
  7. * This source file is subject to the new BSD license that is bundled
  8. * with this package in the file LICENSE.txt.
  9. * It is also available through the world-wide-web at this URL:
  10. * http://framework.zend.com/license/new-bsd
  11. * If you did not receive a copy of the license and are unable to
  12. * obtain it through the world-wide-web, please send an email
  13. * to license@zend.com so we can send you a copy immediately.
  14. *
  15. * @category Zend
  16. * @package Zend_Wildfire
  17. * @subpackage Plugin
  18. * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
  19. * @license http://framework.zend.com/license/new-bsd New BSD License
  20. * @version $Id: FirePhp.php 23066 2010-10-09 23:29:20Z cadorn $
  21. */
  22. /** Zend_Controller_Request_Abstract */
  23. #require_once('Zend/Controller/Request/Abstract.php');
  24. /** Zend_Controller_Response_Abstract */
  25. #require_once('Zend/Controller/Response/Abstract.php');
  26. /** Zend_Wildfire_Channel_HttpHeaders */
  27. #require_once 'Zend/Wildfire/Channel/HttpHeaders.php';
  28. /** Zend_Wildfire_Protocol_JsonStream */
  29. #require_once 'Zend/Wildfire/Protocol/JsonStream.php';
  30. /** Zend_Wildfire_Plugin_Interface */
  31. #require_once 'Zend/Wildfire/Plugin/Interface.php';
  32. /**
  33. * Primary class for communicating with the FirePHP Firefox Extension.
  34. *
  35. * @category Zend
  36. * @package Zend_Wildfire
  37. * @subpackage Plugin
  38. * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
  39. * @license http://framework.zend.com/license/new-bsd New BSD License
  40. */
  41. class Zend_Wildfire_Plugin_FirePhp implements Zend_Wildfire_Plugin_Interface
  42. {
  43. /**
  44. * Plain log style.
  45. */
  46. const LOG = 'LOG';
  47. /**
  48. * Information style.
  49. */
  50. const INFO = 'INFO';
  51. /**
  52. * Warning style.
  53. */
  54. const WARN = 'WARN';
  55. /**
  56. * Error style that increments Firebug's error counter.
  57. */
  58. const ERROR = 'ERROR';
  59. /**
  60. * Trace style showing message and expandable full stack trace.
  61. */
  62. const TRACE = 'TRACE';
  63. /**
  64. * Exception style showing message and expandable full stack trace.
  65. * Also increments Firebug's error counter.
  66. */
  67. const EXCEPTION = 'EXCEPTION';
  68. /**
  69. * Table style showing summary line and expandable table
  70. */
  71. const TABLE = 'TABLE';
  72. /**
  73. * Dump variable to Server panel in Firebug Request Inspector
  74. */
  75. const DUMP = 'DUMP';
  76. /**
  77. * Start a group in the Firebug Console
  78. */
  79. const GROUP_START = 'GROUP_START';
  80. /**
  81. * End a group in the Firebug Console
  82. */
  83. const GROUP_END = 'GROUP_END';
  84. /**
  85. * The plugin URI for this plugin
  86. */
  87. const PLUGIN_URI = 'http://meta.firephp.org/Wildfire/Plugin/ZendFramework/FirePHP/1.6.2';
  88. /**
  89. * The protocol URI for this plugin
  90. */
  91. const PROTOCOL_URI = Zend_Wildfire_Protocol_JsonStream::PROTOCOL_URI;
  92. /**
  93. * The structure URI for the Dump structure
  94. */
  95. const STRUCTURE_URI_DUMP = 'http://meta.firephp.org/Wildfire/Structure/FirePHP/Dump/0.1';
  96. /**
  97. * The structure URI for the Firebug Console structure
  98. */
  99. const STRUCTURE_URI_FIREBUGCONSOLE = 'http://meta.firephp.org/Wildfire/Structure/FirePHP/FirebugConsole/0.1';
  100. /**
  101. * Singleton instance
  102. * @var Zend_Wildfire_Plugin_FirePhp
  103. */
  104. protected static $_instance = null;
  105. /**
  106. * Flag indicating whether FirePHP should send messages to the user-agent.
  107. * @var boolean
  108. */
  109. protected $_enabled = true;
  110. /**
  111. * The channel via which to send the encoded messages.
  112. * @var Zend_Wildfire_Channel_Interface
  113. */
  114. protected $_channel = null;
  115. /**
  116. * Messages that are buffered to be sent when protocol flushes
  117. * @var array
  118. */
  119. protected $_messages = array();
  120. /**
  121. * Options for the object
  122. * @var array
  123. */
  124. protected $_options = array(
  125. 'traceOffset' => 1, /* The offset in the trace which identifies the source of the message */
  126. 'maxTraceDepth' => 99, /* Maximum depth for stack traces */
  127. 'maxObjectDepth' => 10, /* The maximum depth to traverse objects when encoding */
  128. 'maxArrayDepth' => 20, /* The maximum depth to traverse nested arrays when encoding */
  129. 'includeLineNumbers' => true /* Whether to include line and file info for each message */
  130. );
  131. /**
  132. * Filters used to exclude object members when encoding
  133. * @var array
  134. */
  135. protected $_objectFilters = array();
  136. /**
  137. * A stack of objects used during encoding to detect recursion
  138. * @var array
  139. */
  140. protected $_objectStack = array();
  141. /**
  142. * Create singleton instance.
  143. *
  144. * @param string $class OPTIONAL Subclass of Zend_Wildfire_Plugin_FirePhp
  145. * @return Zend_Wildfire_Plugin_FirePhp Returns the singleton Zend_Wildfire_Plugin_FirePhp instance
  146. * @throws Zend_Wildfire_Exception
  147. */
  148. public static function init($class = null)
  149. {
  150. if (self::$_instance !== null) {
  151. #require_once 'Zend/Wildfire/Exception.php';
  152. throw new Zend_Wildfire_Exception('Singleton instance of Zend_Wildfire_Plugin_FirePhp already exists!');
  153. }
  154. if ($class !== null) {
  155. if (!is_string($class)) {
  156. #require_once 'Zend/Wildfire/Exception.php';
  157. throw new Zend_Wildfire_Exception('Third argument is not a class string');
  158. }
  159. if (!class_exists($class)) {
  160. #require_once 'Zend/Loader.php';
  161. Zend_Loader::loadClass($class);
  162. }
  163. self::$_instance = new $class();
  164. if (!self::$_instance instanceof Zend_Wildfire_Plugin_FirePhp) {
  165. self::$_instance = null;
  166. #require_once 'Zend/Wildfire/Exception.php';
  167. throw new Zend_Wildfire_Exception('Invalid class to third argument. Must be subclass of Zend_Wildfire_Plugin_FirePhp.');
  168. }
  169. } else {
  170. self::$_instance = new self();
  171. }
  172. return self::$_instance;
  173. }
  174. /**
  175. * Constructor
  176. * @return void
  177. */
  178. protected function __construct()
  179. {
  180. $this->_channel = Zend_Wildfire_Channel_HttpHeaders::getInstance();
  181. $this->_channel->getProtocol(self::PROTOCOL_URI)->registerPlugin($this);
  182. }
  183. /**
  184. * Get or create singleton instance
  185. *
  186. * @param $skipCreate boolean True if an instance should not be created
  187. * @return Zend_Wildfire_Plugin_FirePhp
  188. */
  189. public static function getInstance($skipCreate=false)
  190. {
  191. if (self::$_instance===null && $skipCreate!==true) {
  192. return self::init();
  193. }
  194. return self::$_instance;
  195. }
  196. /**
  197. * Destroys the singleton instance
  198. *
  199. * Primarily used for testing.
  200. *
  201. * @return void
  202. */
  203. public static function destroyInstance()
  204. {
  205. self::$_instance = null;
  206. }
  207. /**
  208. * Enable or disable sending of messages to user-agent.
  209. * If disabled all headers to be sent will be removed.
  210. *
  211. * @param boolean $enabled Set to TRUE to enable sending of messages.
  212. * @return boolean The previous value.
  213. */
  214. public function setEnabled($enabled)
  215. {
  216. $previous = $this->_enabled;
  217. $this->_enabled = $enabled;
  218. if (!$this->_enabled) {
  219. $this->_messages = array();
  220. $this->_channel->getProtocol(self::PROTOCOL_URI)->clearMessages($this);
  221. }
  222. return $previous;
  223. }
  224. /**
  225. * Determine if logging to user-agent is enabled.
  226. *
  227. * @return boolean Returns TRUE if logging is enabled.
  228. */
  229. public function getEnabled()
  230. {
  231. return $this->_enabled;
  232. }
  233. /**
  234. * Set a single option
  235. *
  236. * @param string $key The name of the option
  237. * @param mixed $value The value of the option
  238. * @return mixed The previous value of the option
  239. */
  240. public function setOption($key, $value)
  241. {
  242. if (!array_key_exists($key,$this->_options)) {
  243. throw new Zend_Wildfire_Exception('Option with name "'.$key.'" does not exist!');
  244. }
  245. $previous = $this->_options[$key];
  246. $this->_options[$key] = $value;
  247. return $previous;
  248. }
  249. /**
  250. * Retrieve a single option
  251. *
  252. * @param string $key The name of the option
  253. * @return mixed The value of the option
  254. */
  255. public function getOption($key)
  256. {
  257. if (!array_key_exists($key,$this->_options)) {
  258. throw new Zend_Wildfire_Exception('Option with name "'.$key.'" does not exist!');
  259. }
  260. return $this->_options[$key];
  261. }
  262. /**
  263. * Retrieve all options
  264. *
  265. * @return array All options
  266. */
  267. public function getOptions()
  268. {
  269. return $this->_options;
  270. }
  271. /**
  272. * Specify a filter to be used when encoding an object
  273. *
  274. * Filters are used to exclude object members.
  275. *
  276. * @param string $Class The class name of the object
  277. * @param array $Filter An array of members to exclude
  278. * @return void
  279. */
  280. public function setObjectFilter($class, $filter) {
  281. $this->_objectFilters[$class] = $filter;
  282. }
  283. /**
  284. * Starts a group in the Firebug Console
  285. *
  286. * @param string $title The title of the group
  287. * @return TRUE if the group instruction was added to the response headers or buffered.
  288. */
  289. public static function group($title)
  290. {
  291. return self::send(null, $title, self::GROUP_START);
  292. }
  293. /**
  294. * Ends a group in the Firebug Console
  295. *
  296. * @return TRUE if the group instruction was added to the response headers or buffered.
  297. */
  298. public static function groupEnd()
  299. {
  300. return self::send(null, null, self::GROUP_END);
  301. }
  302. /**
  303. * Logs variables to the Firebug Console
  304. * via HTTP response headers and the FirePHP Firefox Extension.
  305. *
  306. * @param mixed $var The variable to log.
  307. * @param string $label OPTIONAL Label to prepend to the log event.
  308. * @param string $style OPTIONAL Style of the log event.
  309. * @param array $options OPTIONAL Options to change how messages are processed and sent
  310. * @return boolean Returns TRUE if the variable was added to the response headers or buffered.
  311. * @throws Zend_Wildfire_Exception
  312. */
  313. public static function send($var, $label=null, $style=null, $options=array())
  314. {
  315. $firephp = self::getInstance();
  316. if (!$firephp->getEnabled()) {
  317. return false;
  318. }
  319. if ($var instanceof Zend_Wildfire_Plugin_FirePhp_Message) {
  320. if ($var->getBuffered()) {
  321. if (!in_array($var, self::$_instance->_messages)) {
  322. self::$_instance->_messages[] = $var;
  323. }
  324. return true;
  325. }
  326. if ($var->getDestroy()) {
  327. return false;
  328. }
  329. $style = $var->getStyle();
  330. $label = $var->getLabel();
  331. $options = $var->getOptions();
  332. $var = $var->getMessage();
  333. }
  334. if (!self::$_instance->_channel->isReady()) {
  335. return false;
  336. }
  337. foreach ($options as $name => $value) {
  338. if ($value===null) {
  339. unset($options[$name]);
  340. }
  341. }
  342. $options = array_merge($firephp->getOptions(), $options);
  343. $trace = null;
  344. $skipFinalEncode = false;
  345. $meta = array();
  346. $meta['Type'] = $style;
  347. if ($var instanceof Exception) {
  348. $eTrace = $var->getTrace();
  349. $eTrace = array_splice($eTrace, 0, $options['maxTraceDepth']);
  350. $var = array('Class'=>get_class($var),
  351. 'Message'=>$var->getMessage(),
  352. 'File'=>$var->getFile(),
  353. 'Line'=>$var->getLine(),
  354. 'Type'=>'throw',
  355. 'Trace'=>$firephp->_encodeTrace($eTrace));
  356. $meta['Type'] = self::EXCEPTION;
  357. $skipFinalEncode = true;
  358. } else
  359. if ($meta['Type']==self::TRACE) {
  360. if (!$label && $var) {
  361. $label = $var;
  362. $var = null;
  363. }
  364. if (!$trace) {
  365. $trace = $firephp->_getStackTrace(array_merge($options,
  366. array('maxTraceDepth'=>$options['maxTraceDepth']+1)));
  367. }
  368. $var = array('Class'=>$trace[0]['class'],
  369. 'Type'=>$trace[0]['type'],
  370. 'Function'=>$trace[0]['function'],
  371. 'Message'=>$label,
  372. 'File'=>isset($trace[0]['file'])?$trace[0]['file']:'',
  373. 'Line'=>isset($trace[0]['line'])?$trace[0]['line']:'',
  374. 'Args'=>isset($trace[0]['args'])?$firephp->_encodeObject($trace[0]['args']):'',
  375. 'Trace'=>$firephp->_encodeTrace(array_splice($trace,1)));
  376. $skipFinalEncode = true;
  377. } else
  378. if ($meta['Type']==self::TABLE) {
  379. $var = $firephp->_encodeTable($var);
  380. $skipFinalEncode = true;
  381. } else {
  382. if ($meta['Type']===null) {
  383. $meta['Type'] = self::LOG;
  384. }
  385. }
  386. if ($label!=null) {
  387. $meta['Label'] = $label;
  388. }
  389. switch ($meta['Type']) {
  390. case self::LOG:
  391. case self::INFO:
  392. case self::WARN:
  393. case self::ERROR:
  394. case self::EXCEPTION:
  395. case self::TRACE:
  396. case self::TABLE:
  397. case self::DUMP:
  398. case self::GROUP_START:
  399. case self::GROUP_END:
  400. break;
  401. default:
  402. #require_once 'Zend/Wildfire/Exception.php';
  403. throw new Zend_Wildfire_Exception('Log style "'.$meta['Type'].'" not recognized!');
  404. break;
  405. }
  406. if ($meta['Type'] != self::DUMP && $options['includeLineNumbers']) {
  407. if (!isset($meta['File']) || !isset($meta['Line'])) {
  408. if (!$trace) {
  409. $trace = $firephp->_getStackTrace(array_merge($options,
  410. array('maxTraceDepth'=>$options['maxTraceDepth']+1)));
  411. }
  412. $meta['File'] = isset($trace[0]['file'])?$trace[0]['file']:'';
  413. $meta['Line'] = isset($trace[0]['line'])?$trace[0]['line']:'';
  414. }
  415. } else {
  416. unset($meta['File']);
  417. unset($meta['Line']);
  418. }
  419. if ($meta['Type'] == self::DUMP) {
  420. return $firephp->_recordMessage(self::STRUCTURE_URI_DUMP,
  421. array('key'=>$meta['Label'],
  422. 'data'=>$var),
  423. $skipFinalEncode);
  424. } else {
  425. return $firephp->_recordMessage(self::STRUCTURE_URI_FIREBUGCONSOLE,
  426. array('data'=>$var,
  427. 'meta'=>$meta),
  428. $skipFinalEncode);
  429. }
  430. }
  431. /**
  432. * Gets a stack trace
  433. *
  434. * @param array $options Options to change how the stack trace is returned
  435. * @return array The stack trace
  436. */
  437. protected function _getStackTrace($options)
  438. {
  439. $trace = debug_backtrace();
  440. $trace = array_splice($trace, $options['traceOffset']);
  441. if (!count($trace)) {
  442. return $trace;
  443. }
  444. if (isset($options['fixZendLogOffsetIfApplicable']) && $options['fixZendLogOffsetIfApplicable']) {
  445. if (count($trace) >=3 &&
  446. isset($trace[0]['file']) && substr($trace[0]['file'], -7, 7)=='Log.php' &&
  447. isset($trace[1]['function']) && $trace[1]['function']=='__call') {
  448. $trace = array_splice($trace, 2);
  449. }
  450. }
  451. return array_splice($trace, 0, $options['maxTraceDepth']);
  452. }
  453. /**
  454. * Record a message with the given data in the given structure
  455. *
  456. * @param string $structure The structure to be used for the data
  457. * @param array $data The data to be recorded
  458. * @param boolean $skipEncode TRUE if variable encoding should be skipped
  459. * @return boolean Returns TRUE if message was recorded
  460. * @throws Zend_Wildfire_Exception
  461. */
  462. protected function _recordMessage($structure, $data, $skipEncode=false)
  463. {
  464. switch($structure) {
  465. case self::STRUCTURE_URI_DUMP:
  466. if (!isset($data['key'])) {
  467. #require_once 'Zend/Wildfire/Exception.php';
  468. throw new Zend_Wildfire_Exception('You must supply a key.');
  469. }
  470. if (!array_key_exists('data',$data)) {
  471. #require_once 'Zend/Wildfire/Exception.php';
  472. throw new Zend_Wildfire_Exception('You must supply data.');
  473. }
  474. $value = $data['data'];
  475. if (!$skipEncode) {
  476. $value = $this->_encodeObject($data['data']);
  477. }
  478. return $this->_channel->getProtocol(self::PROTOCOL_URI)->
  479. recordMessage($this,
  480. $structure,
  481. array($data['key']=>$value));
  482. case self::STRUCTURE_URI_FIREBUGCONSOLE:
  483. if (!isset($data['meta']) ||
  484. !is_array($data['meta']) ||
  485. !array_key_exists('Type',$data['meta'])) {
  486. #require_once 'Zend/Wildfire/Exception.php';
  487. throw new Zend_Wildfire_Exception('You must supply a "Type" in the meta information.');
  488. }
  489. if (!array_key_exists('data',$data)) {
  490. #require_once 'Zend/Wildfire/Exception.php';
  491. throw new Zend_Wildfire_Exception('You must supply data.');
  492. }
  493. $value = $data['data'];
  494. if (!$skipEncode) {
  495. $value = $this->_encodeObject($data['data']);
  496. }
  497. return $this->_channel->getProtocol(self::PROTOCOL_URI)->
  498. recordMessage($this,
  499. $structure,
  500. array($data['meta'],
  501. $value));
  502. default:
  503. #require_once 'Zend/Wildfire/Exception.php';
  504. throw new Zend_Wildfire_Exception('Structure of name "'.$structure.'" is not recognized.');
  505. break;
  506. }
  507. return false;
  508. }
  509. /**
  510. * Encodes a table by encoding each row and column with _encodeObject()
  511. *
  512. * @param array $Table The table to be encoded
  513. * @return array
  514. */
  515. protected function _encodeTable($table)
  516. {
  517. if (!$table) {
  518. return $table;
  519. }
  520. for ($i=0 ; $i<count($table) ; $i++) {
  521. if (is_array($table[$i])) {
  522. for ($j=0 ; $j<count($table[$i]) ; $j++) {
  523. $table[$i][$j] = $this->_encodeObject($table[$i][$j]);
  524. }
  525. }
  526. }
  527. return $table;
  528. }
  529. /**
  530. * Encodes a trace by encoding all "args" with _encodeObject()
  531. *
  532. * @param array $Trace The trace to be encoded
  533. * @return array The encoded trace
  534. */
  535. protected function _encodeTrace($trace)
  536. {
  537. if (!$trace) {
  538. return $trace;
  539. }
  540. for ($i=0 ; $i<sizeof($trace) ; $i++) {
  541. if (isset($trace[$i]['args'])) {
  542. $trace[$i]['args'] = $this->_encodeObject($trace[$i]['args']);
  543. }
  544. }
  545. return $trace;
  546. }
  547. /**
  548. * Encode an object by generating an array containing all object members.
  549. *
  550. * All private and protected members are included. Some meta info about
  551. * the object class is added.
  552. *
  553. * @param mixed $object The object/array/value to be encoded
  554. * @return array The encoded object
  555. */
  556. protected function _encodeObject($object, $objectDepth = 1, $arrayDepth = 1)
  557. {
  558. $return = array();
  559. if (is_resource($object)) {
  560. return '** '.(string)$object.' **';
  561. } else
  562. if (is_object($object)) {
  563. if ($objectDepth > $this->_options['maxObjectDepth']) {
  564. return '** Max Object Depth ('.$this->_options['maxObjectDepth'].') **';
  565. }
  566. foreach ($this->_objectStack as $refVal) {
  567. if ($refVal === $object) {
  568. return '** Recursion ('.get_class($object).') **';
  569. }
  570. }
  571. array_push($this->_objectStack, $object);
  572. $return['__className'] = $class = get_class($object);
  573. $reflectionClass = new ReflectionClass($class);
  574. $properties = array();
  575. foreach ( $reflectionClass->getProperties() as $property) {
  576. $properties[$property->getName()] = $property;
  577. }
  578. $members = (array)$object;
  579. foreach ($properties as $just_name => $property) {
  580. $name = $raw_name = $just_name;
  581. if ($property->isStatic()) {
  582. $name = 'static:'.$name;
  583. }
  584. if ($property->isPublic()) {
  585. $name = 'public:'.$name;
  586. } else
  587. if ($property->isPrivate()) {
  588. $name = 'private:'.$name;
  589. $raw_name = "\0".$class."\0".$raw_name;
  590. } else
  591. if ($property->isProtected()) {
  592. $name = 'protected:'.$name;
  593. $raw_name = "\0".'*'."\0".$raw_name;
  594. }
  595. if (!(isset($this->_objectFilters[$class])
  596. && is_array($this->_objectFilters[$class])
  597. && in_array($just_name,$this->_objectFilters[$class]))) {
  598. if (array_key_exists($raw_name,$members)
  599. && !$property->isStatic()) {
  600. $return[$name] = $this->_encodeObject($members[$raw_name], $objectDepth + 1, 1);
  601. } else {
  602. if (method_exists($property,'setAccessible')) {
  603. $property->setAccessible(true);
  604. $return[$name] = $this->_encodeObject($property->getValue($object), $objectDepth + 1, 1);
  605. } else
  606. if ($property->isPublic()) {
  607. $return[$name] = $this->_encodeObject($property->getValue($object), $objectDepth + 1, 1);
  608. } else {
  609. $return[$name] = '** Need PHP 5.3 to get value **';
  610. }
  611. }
  612. } else {
  613. $return[$name] = '** Excluded by Filter **';
  614. }
  615. }
  616. // Include all members that are not defined in the class
  617. // but exist in the object
  618. foreach($members as $just_name => $value) {
  619. $name = $raw_name = $just_name;
  620. if ($name{0} == "\0") {
  621. $parts = explode("\0", $name);
  622. $name = $parts[2];
  623. }
  624. if (!isset($properties[$name])) {
  625. $name = 'undeclared:'.$name;
  626. if (!(isset($this->objectFilters[$class])
  627. && is_array($this->objectFilters[$class])
  628. && in_array($just_name,$this->objectFilters[$class]))) {
  629. $return[$name] = $this->_encodeObject($value, $objectDepth + 1, 1);
  630. } else {
  631. $return[$name] = '** Excluded by Filter **';
  632. }
  633. }
  634. }
  635. array_pop($this->_objectStack);
  636. } elseif (is_array($object)) {
  637. if ($arrayDepth > $this->_options['maxArrayDepth']) {
  638. return '** Max Array Depth ('.$this->_options['maxArrayDepth'].') **';
  639. }
  640. foreach ($object as $key => $val) {
  641. // Encoding the $GLOBALS PHP array causes an infinite loop
  642. // if the recursion is not reset here as it contains
  643. // a reference to itself. This is the only way I have come up
  644. // with to stop infinite recursion in this case.
  645. if ($key=='GLOBALS'
  646. && is_array($val)
  647. && array_key_exists('GLOBALS',$val)) {
  648. $val['GLOBALS'] = '** Recursion (GLOBALS) **';
  649. }
  650. $return[$key] = $this->_encodeObject($val, 1, $arrayDepth + 1);
  651. }
  652. } else {
  653. return $object;
  654. }
  655. return $return;
  656. }
  657. /*
  658. * Zend_Wildfire_Plugin_Interface
  659. */
  660. /**
  661. * Get the unique indentifier for this plugin.
  662. *
  663. * @return string Returns the URI of the plugin.
  664. */
  665. public function getUri()
  666. {
  667. return self::PLUGIN_URI;
  668. }
  669. /**
  670. * Flush any buffered data.
  671. *
  672. * @param string $protocolUri The URI of the protocol that should be flushed to
  673. * @return void
  674. */
  675. public function flushMessages($protocolUri)
  676. {
  677. if (!$this->_messages || $protocolUri!=self::PROTOCOL_URI) {
  678. return;
  679. }
  680. foreach( $this->_messages as $message ) {
  681. if (!$message->getDestroy()) {
  682. $this->send($message->getMessage(),
  683. $message->getLabel(),
  684. $message->getStyle(),
  685. $message->getOptions());
  686. }
  687. }
  688. $this->_messages = array();
  689. }
  690. }