本文整理汇总了PHP中Zend_Wildfire_Channel_HttpHeaders类的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Wildfire_Channel_HttpHeaders类的具体用法?PHP Zend_Wildfire_Channel_HttpHeaders怎么用?PHP Zend_Wildfire_Channel_HttpHeaders使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Zend_Wildfire_Channel_HttpHeaders类的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: __exit
function __exit()
{
$front = Zend_Controller_Front::getInstance();
$channel = Zend_Wildfire_Channel_HttpHeaders::getInstance();
//$channel->setRequest(new Zend_Controller_Request_Http());
//$channel->setResponse(new Zend_Controller_Response_Http());
$channel->getResponse();
$channel->getRequest();
$channel->flush();
$channel->getResponse()->sendHeaders();
//xdebug_get_code_coverage();
}
示例10: array
$profiler->setEnabled(true);
$db = Zend_Db::factory('PDO_SQLITE', array('dbname' => ':memory:'));
$db->setProfiler($profiler);
Zend_Registry::set('db', $db);
$controller = Zend_Controller_Front::getInstance();
$controller->setParam('useDefaultControllerAlways', true);
$controller->setParam('noViewRenderer', true);
$controller->setControllerDirectory(dirname(dirname(dirname(dirname(__FILE__)))) . '/application/controllers/Boot/Zend-Db-Profiler-Firebug');
$controller->dispatch();
print 'Test Doc Example with Controller';
break;
case 'WithoutController':
$profiler = new Zend_Db_Profiler_Firebug('All DB Queries');
$profiler->setEnabled(true);
$db = Zend_Db::factory('PDO_SQLITE', array('dbname' => ':memory:'));
$db->setProfiler($profiler);
$request = new Zend_Controller_Request_Http();
$response = new Zend_Controller_Response_Http();
$channel = Zend_Wildfire_Channel_HttpHeaders::getInstance();
$channel->setRequest($request);
$channel->setResponse($response);
$db->getConnection()->exec('CREATE TABLE foo (
id INTEGNER NOT NULL,
col1 VARCHAR(10) NOT NULL
)');
$db->insert('foo', array('id' => 1, 'col1' => 'original'));
$channel->flush();
$response->sendHeaders();
print 'Test Doc Example without Controller';
break;
}
示例11: 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));
}
}
}
示例12: getResponse
/**
* getResponse
*
* <p>convert the $_response array to json and set the application mine type json</p>
*/
public function getResponse()
{
if (Zend_Registry::get('config')->kebab->logging->enable && Zend_Registry::get('config')->kebab->logging->firebug->enable) {
Zend_Wildfire_Channel_HttpHeaders::getInstance()->flush();
}
//KBBTODO We should write an adapter for array, xml in future
$jsonHelper = new Zend_Controller_Action_Helper_Json();
$jsonHelper->direct($this->_response);
}
示例13: testNoQueriesAfterFiltering
/**
* @group ZF-6395
*/
public function testNoQueriesAfterFiltering()
{
$channel = Zend_Wildfire_Channel_HttpHeaders::getInstance();
$protocol = $channel->getProtocol(Zend_Wildfire_Plugin_FirePhp::PROTOCOL_URI);
$profiler = $this->_profiler->setEnabled(true);
$profiler->setFilterQueryType(Zend_Db_Profiler::INSERT | Zend_Db_Profiler::UPDATE);
$this->_db->fetchAll('select * from foo');
Zend_Wildfire_Channel_HttpHeaders::getInstance()->flush();
$messages = $protocol->getMessages();
$this->assertFalse($messages);
}
示例14: _sendFatalResponse
protected static function _sendFatalResponse()
{
// Clean any previous output from buffer
while (ob_get_level() > 0) {
ob_end_clean();
}
// Send firephp headers
if (APPLICATION_ENV == 'development') {
try {
$request = new Zend_Controller_Request_Http();
$response = new Zend_Controller_Response_Http();
$headers = Zend_Wildfire_Channel_HttpHeaders::getInstance();
$headers->setResponse($response);
$headers->setRequest($request);
$headers->flush();
$response->setBody(file_get_contents(APPLICATION_PATH . '/application/offline.html'));
$response->sendHeaders();
$response->sendResponse();
die(1);
} catch (Exception $e) {
// Will fall through to stuff below
}
}
// Send normal error message
echo file_get_contents(APPLICATION_PATH . '/application/offline.html');
die(1);
}
示例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) **"}}]]]');
}