本文整理汇总了PHP中Zend_Wildfire_Channel_HttpHeaders::getInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Wildfire_Channel_HttpHeaders::getInstance方法的具体用法?PHP Zend_Wildfire_Channel_HttpHeaders::getInstance怎么用?PHP Zend_Wildfire_Channel_HttpHeaders::getInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Wildfire_Channel_HttpHeaders
的用法示例。
在下文中一共展示了Zend_Wildfire_Channel_HttpHeaders::getInstance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: sendJson
/**
* Encode JSON response and immediately send
*
* @param mixed $data
* @param boolean|array $keepLayouts
* NOTE: if boolean, establish $keepLayouts to true|false
* if array, admit params for Zend_Json::encode as enableJsonExprFinder=>true|false
* if $keepLayouts and parmas for Zend_Json::encode are required
* then, the array can contains a 'keepLayout'=>true|false
* that will not be passed to Zend_Json::encode method but will be passed
* to Zend_View_Helper_Json
* @param bool $wrap
* @return string|void
*/
public function sendJson($data, $keepLayouts = false, $wrap = true)
{
if (!is_array($data)) {
return parent::sendJson($data, $keepLayouts);
}
if (isset($data['success']) && !is_bool($data['success'])) {
$data['success'] = (bool) $data['success'];
}
if ($wrap) {
$messages = Axis::message()->getAll();
// if (isset(false === $data['success']) && $data['success']) {
// unset($messages['success']);
// }
$data = array_merge(array('messages' => $messages), $data);
}
if ($this->_data) {
$data = array_merge_recursive($this->_data, $data);
}
$data = $this->encodeJson($data, $keepLayouts);
$response = $this->getResponse();
$response->setBody($data);
if (!$this->suppressExit) {
Zend_Wildfire_Channel_HttpHeaders::getInstance()->flush();
//Axis_FirePhp
$response->sendResponse();
exit;
}
return $data;
}
示例2: getChannel
public static function getChannel()
{
if (!self::$channel) {
self::$channel = \Zend_Wildfire_Channel_HttpHeaders::getInstance();
}
return self::$channel;
}
示例3: testNoQueries
public function testNoQueries()
{
$channel = Zend_Wildfire_Channel_HttpHeaders::getInstance();
$protocol = $channel->getProtocol(Zend_Wildfire_Plugin_FirePhp::PROTOCOL_URI);
Zend_Wildfire_Channel_HttpHeaders::getInstance()->flush();
// call plugin postDispatch to record profiler data
$this->_plugin->dispatchLoopShutdown();
$messages = $protocol->getMessages();
$this->assertFalse($messages);
}
示例4: start
public static function start($config, $db)
{
self::$_config = $config;
if (self::$_config['Zend_Db_Profiler_Firebug'] == false) {
return;
}
$profiler = new Zend_Db_Profiler_Firebug('All DB Queries');
$profiler->setEnabled(true);
$db->setProfiler($profiler);
$request = new Zend_Controller_Request_Http();
self::$_response = new Zend_Controller_Response_Http();
self::$_channel = Zend_Wildfire_Channel_HttpHeaders::getInstance();
self::$_channel->setRequest($request);
self::$_channel->setResponse(self::$_response);
ob_start();
}
示例5: sendToFirebug
/**
* send to Firebug
*
* @param $content
*/
public function sendToFirebug($content)
{
$writer = new Zend_Log_Writer_Firebug();
$logger = new Zend_Log($writer);
$request = new Zend_Controller_Request_Http();
$response = new Zend_Controller_Response_Http();
$channel = Zend_Wildfire_Channel_HttpHeaders::getInstance();
$channel->setRequest($request);
$channel->setResponse($response);
// Start output buffering
ob_start();
$logger->log($content, Zend_Log::INFO);
// Flush log data to browser
$channel->flush();
$response->sendHeaders();
}
示例6: test2PhpAction
public function test2PhpAction()
{
Zend_Registry::get('logger')->debug('Test Logging Message');
$this->view->json('Sample Json Data');
$this->getHelper('Json')->suppressExit = true;
$this->getHelper('Json')->sendJson('Test JSON data');
Zend_Wildfire_Channel_HttpHeaders::getInstance()->flush();
$this->getHelper('Json')->getResponse()->sendResponse();
exit;
/*
Zend_Registry::get('logger')->debug('Test Logging Message');
$this->view->json('Sample Json Data');
$viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer');
$viewRenderer->setNoRender(true);
*/
}
示例7: display
/**
* Display profiling results and flush output buffer
*/
public function display()
{
$firebugMessage = new Zend_Wildfire_Plugin_FirePhp_TableMessage($this->_renderCaption());
$firebugMessage->setHeader(array_keys($this->_getColumns()));
foreach ($this->_getTimers() as $timerId) {
$row = array();
foreach ($this->_getColumns() as $columnId) {
$row[] = $this->_renderColumnValue($timerId, $columnId);
}
$firebugMessage->addRow($row);
}
Zend_Wildfire_Plugin_FirePhp::getInstance()->send($firebugMessage);
// setup the wildfire channel
$firebugChannel = Zend_Wildfire_Channel_HttpHeaders::getInstance();
$firebugChannel->setRequest($this->_request ? $this->_request : new Zend_Controller_Request_Http());
$firebugChannel->setResponse($this->_response ? $this->_response : new Zend_Controller_Response_Http());
// flush the wildfire headers into the response object
$firebugChannel->flush();
// send the response headers
$firebugChannel->getResponse()->sendHeaders();
ob_end_flush();
}
示例8: display
/**
* Display profiling results and flush output buffer
*
* @param Stat $stat
* @return void
*/
public function display(Stat $stat)
{
$firebugMessage = new \Zend_Wildfire_Plugin_FirePhp_TableMessage($this->_renderCaption());
$firebugMessage->setHeader(array_keys($this->_columns));
foreach ($this->_getTimerIds($stat) as $timerId) {
$row = array();
foreach ($this->_columns as $column) {
$row[] = $this->_renderColumnValue($stat->fetch($timerId, $column), $column);
}
$firebugMessage->addRow($row);
}
\Zend_Wildfire_Plugin_FirePhp::send($firebugMessage);
// setup the wildfire channel
$firebugChannel = \Zend_Wildfire_Channel_HttpHeaders::getInstance();
$firebugChannel->setRequest($this->getRequest());
$firebugChannel->setResponse($this->getResponse());
// flush the wildfire headers into the response object
$firebugChannel->flush();
// send the response headers
$firebugChannel->getResponse()->sendHeaders();
ob_end_flush();
}
示例9: testAdvancedLogging
/**
* @group ZF-4934
*/
public function testAdvancedLogging()
{
Zend_Wildfire_Plugin_FirePhp::getInstance()->setOption('maxTraceDepth', 0);
$message = 'This is a log message!';
$label = 'Test Label';
$table = array('Summary line for the table', array(array('Column 1', 'Column 2'), array('Row 1 c 1', ' Row 1 c 2'), array('Row 2 c 1', ' Row 2 c 2')));
$this->_logger->addPriority('TRACE', 8);
$this->_logger->addPriority('TABLE', 9);
$this->_writer->setPriorityStyle(8, 'TRACE');
$this->_writer->setPriorityStyle(9, 'TABLE');
$this->_logger->trace($message);
$this->_logger->table($table);
try {
throw new Exception('Test Exception');
} catch (Exception $e) {
$this->_logger->err($e);
}
try {
Zend_Wildfire_Plugin_FirePhp::send($message, $label, 'UNKNOWN');
$this->fail('Should not be able to log with undefined log style');
} catch (Exception $e) {
// success
}
$channel = Zend_Wildfire_Channel_HttpHeaders::getInstance();
$protocol = $channel->getProtocol(Zend_Wildfire_Plugin_FirePhp::PROTOCOL_URI);
$messages = array(Zend_Wildfire_Plugin_FirePhp::STRUCTURE_URI_FIREBUGCONSOLE => array(Zend_Wildfire_Plugin_FirePhp::PLUGIN_URI => array(1 => '[{"Type":"TABLE"},["Summary line for the table",[["Column 1","Column 2"],["Row 1 c 1"," Row 1 c 2"],["Row 2 c 1"," Row 2 c 2"]]]]')));
$qued_messages = $protocol->getMessages();
unset($qued_messages[Zend_Wildfire_Plugin_FirePhp::STRUCTURE_URI_FIREBUGCONSOLE][Zend_Wildfire_Plugin_FirePhp::PLUGIN_URI][0]);
unset($qued_messages[Zend_Wildfire_Plugin_FirePhp::STRUCTURE_URI_FIREBUGCONSOLE][Zend_Wildfire_Plugin_FirePhp::PLUGIN_URI][2]);
$this->assertEquals(serialize($qued_messages), serialize($messages));
}
示例10: setFirebugChannel
/**
* Setter method for the channel property. If no channel given
* a new instance of the Zend_Wildfire_Channel_HttpHeaders will be used.
*
* @param Zend_Wildfire_Channel_HttpHeaders $channel
*/
public function setFirebugChannel($channel = null)
{
if ($channel === null) {
$channel = Zend_Wildfire_Channel_HttpHeaders::getInstance();
}
$this->channel = $channel;
}
示例11: _toFirebug
public static function _toFirebug()
{
$timers = self::getTimers();
$rows = array();
$rows[] = array('Name', 'Time', 'Count', 'Real Mem', 'Emallac');
foreach ($timers as $name => $timer) {
$row = array();
$row[] = $name;
$row[] = number_format(self::fetch($name, 'sum'), 5);
$row[] = number_format(self::fetch($name, 'count'));
$row[] = number_format(self::fetch($name, 'realmem'));
$row[] = number_format(self::fetch($name, 'emalloc'));
$rows[] = $row;
}
$count = count($timers);
$table = array("App Profiling ({$count} total)", $rows);
Zend_Registry::get('log')->table($table);
Zend_Wildfire_Channel_HttpHeaders::getInstance()->flush();
}
示例12: testFileLineOffsets
/**
* @group ZF-10537
*/
public function testFileLineOffsets()
{
$firephp = Zend_Wildfire_Plugin_FirePhp::getInstance();
$channel = Zend_Wildfire_Channel_HttpHeaders::getInstance();
$protocol = $channel->getProtocol(Zend_Wildfire_Plugin_FirePhp::PROTOCOL_URI);
$firephp->setOption('includeLineNumbers', true);
$firephp->setOption('maxTraceDepth', 0);
$lines = array();
// NOTE: Do NOT separate the following pairs otherwise the line numbers will not match for the test
// Message number: 1
$lines[] = __LINE__ + 1;
$this->_logger->log('Hello World', Zend_Log::INFO);
// Message number: 2
$this->_logger->addPriority('TRACE', 8);
$this->_writer->setPriorityStyle(8, 'TRACE');
$lines[] = __LINE__ + 1;
$this->_logger->trace('Trace to here');
// Message number: 3
$this->_logger->addPriority('TABLE', 9);
$this->_writer->setPriorityStyle(9, 'TABLE');
$table = array('Summary line for the table', array(array('Column 1', 'Column 2'), array('Row 1 c 1', ' Row 1 c 2'), array('Row 2 c 1', ' Row 2 c 2')));
$lines[] = __LINE__ + 1;
$this->_logger->table($table);
// Message number: 4
$lines[] = __LINE__ + 1;
$this->_logger->info('Hello World');
$messages = $protocol->getMessages();
$messages = $messages[Zend_Wildfire_Plugin_FirePhp::STRUCTURE_URI_FIREBUGCONSOLE][Zend_Wildfire_Plugin_FirePhp::PLUGIN_URI];
for ($i = 0; $i < sizeof($messages); $i++) {
if (!preg_match_all('/FirebugTest\\.php","Line":' . $lines[$i] . '/', $messages[$i], $m)) {
$this->fail("File and line does not match for message number: " . ($i + 1));
}
}
}
示例13: run
public static function run()
{
self::setRequest();
$response = new Zend_Controller_Response_Http();
$channel = Zend_Wildfire_Channel_HttpHeaders::getInstance();
$channel->setRequest(self::$_request);
$channel->setResponse($response);
// Start output buffering
ob_start();
try {
self::prepare();
Lms_Debug::debug('Request URI: ' . $_SERVER['REQUEST_URI']);
try {
self::$_frontController->dispatch(self::$_request);
} catch (Exception $e) {
Lms_Debug::crit($e->getMessage());
Lms_Debug::crit($e->getTraceAsString());
}
self::close();
} catch (Exception $e) {
Lms_Debug::crit($e->getMessage());
Lms_Debug::crit($e->getTraceAsString());
}
// Flush log data to browser
$channel->flush();
$response->sendHeaders();
}
示例14: shutdown
/**
* Shutdown function to execute at the end of the request. This function
* is called automatically so there is no need to call it explicitly.
*/
public static function shutdown()
{
$error = error_get_last();
if ($error !== null && $error['type'] == E_ERROR) {
$e = new ErrorException($error['message'], $error['type'], 0, $error['file'], $error['line']);
self::showException($e);
}
if (self::$logger) {
self::$throwExceptionsOnError = false;
$queryCount = Curry_Propel::getQueryCount();
$generationTime = self::getExecutionTime();
self::log("Generation time: " . round($generationTime, 3) . "s", Zend_Log::NOTICE);
self::log("Peak memory usage: " . Curry_Util::humanReadableBytes(memory_get_peak_usage()), Zend_Log::NOTICE);
self::log("SQL query count: " . ($queryCount !== null ? $queryCount : 'n/a'), Zend_Log::NOTICE);
if (self::$writer instanceof Zend_Log_Writer_Firebug && !headers_sent()) {
// Flush log data to browser
$channel = Zend_Wildfire_Channel_HttpHeaders::getInstance();
$response = $channel->getResponse();
$channel->flush();
//$response->sendHeaders();
// send headers manually so http status (3xx) doesn't get overridden
foreach ($response->getRawHeaders() as $header) {
header($header);
}
foreach ($response->getHeaders() as $header) {
header($header['name'] . ': ' . $header['value'], $header['replace']);
}
}
}
}
示例15: testMaxObjectArrayDepth
/**
* @group ZF-5540
*/
public function testMaxObjectArrayDepth()
{
$this->_setupWithoutFrontController();
$firephp = Zend_Wildfire_Plugin_FirePhp::getInstance();
$channel = Zend_Wildfire_Channel_HttpHeaders::getInstance();
$protocol = $channel->getProtocol(Zend_Wildfire_Plugin_FirePhp::PROTOCOL_URI);
$firephp->setOption('maxObjectDepth', 2);
$firephp->setOption('maxArrayDepth', 1);
$obj = new Zend_Wildfire_WildfireTest_TestObject3();
$obj->testArray = array('val1', array('val2', array('Hello World')));
$obj->child = clone $obj;
$obj->child->child = clone $obj;
$firephp->send($obj);
$table = array();
$table[] = array('Col1', 'Col2');
$table[] = array($obj, $obj);
$firephp->send($table, 'Label', Zend_Wildfire_Plugin_FirePhp::TABLE);
$messages = $protocol->getMessages();
$message = $messages[Zend_Wildfire_Plugin_FirePhp::STRUCTURE_URI_FIREBUGCONSOLE][Zend_Wildfire_Plugin_FirePhp::PLUGIN_URI][0];
$this->assertEquals($message, '[{"Type":"LOG"},{"__className":"Zend_Wildfire_WildfireTest_TestObject3","public:name":"Name","public:value":"Value","undeclared:testArray":["val1","** Max Array Depth (1) **"],"undeclared:child":{"__className":"Zend_Wildfire_WildfireTest_TestObject3","public:name":"Name","public:value":"Value","undeclared:testArray":["val1","** Max Array Depth (1) **"],"undeclared:child":"** Max Object Depth (2) **"}}]');
$message = $messages[Zend_Wildfire_Plugin_FirePhp::STRUCTURE_URI_FIREBUGCONSOLE][Zend_Wildfire_Plugin_FirePhp::PLUGIN_URI][1];
$this->assertEquals($message, '[{"Type":"TABLE","Label":"Label"},[["Col1","Col2"],[{"__className":"Zend_Wildfire_WildfireTest_TestObject3","public:name":"Name","public:value":"Value","undeclared:testArray":["val1","** Max Array Depth (1) **"],"undeclared:child":{"__className":"Zend_Wildfire_WildfireTest_TestObject3","public:name":"Name","public:value":"Value","undeclared:testArray":["val1","** Max Array Depth (1) **"],"undeclared:child":"** Max Object Depth (2) **"}},{"__className":"Zend_Wildfire_WildfireTest_TestObject3","public:name":"Name","public:value":"Value","undeclared:testArray":["val1","** Max Array Depth (1) **"],"undeclared:child":{"__className":"Zend_Wildfire_WildfireTest_TestObject3","public:name":"Name","public:value":"Value","undeclared:testArray":["val1","** Max Array Depth (1) **"],"undeclared:child":"** Max Object Depth (2) **"}}]]]');
}