當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Debugger::getInstance方法代碼示例

本文整理匯總了PHP中Cake\Error\Debugger::getInstance方法的典型用法代碼示例。如果您正苦於以下問題:PHP Debugger::getInstance方法的具體用法?PHP Debugger::getInstance怎麽用?PHP Debugger::getInstance使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Cake\Error\Debugger的用法示例。


在下文中一共展示了Debugger::getInstance方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: addFormat

 /**
  * Add an output format or update a format in Debugger.
  *
  * ```
  * Debugger::addFormat('custom', $data);
  * ```
  *
  * Where $data is an array of strings that use Text::insert() variable
  * replacement. The template vars should be in a `{:id}` style.
  * An error formatter can have the following keys:
  *
  * - 'error' - Used for the container for the error message. Gets the following template
  *   variables: `id`, `error`, `code`, `description`, `path`, `line`, `links`, `info`
  * - 'info' - A combination of `code`, `context` and `trace`. Will be set with
  *   the contents of the other template keys.
  * - 'trace' - The container for a stack trace. Gets the following template
  *   variables: `trace`
  * - 'context' - The container element for the context variables.
  *   Gets the following templates: `id`, `context`
  * - 'links' - An array of HTML links that are used for creating links to other resources.
  *   Typically this is used to create javascript links to open other sections.
  *   Link keys, are: `code`, `context`, `help`. See the js output format for an
  *   example.
  * - 'traceLine' - Used for creating lines in the stacktrace. Gets the following
  *   template variables: `reference`, `path`, `line`
  *
  * Alternatively if you want to use a custom callback to do all the formatting, you can use
  * the callback key, and provide a callable:
  *
  * ```
  * Debugger::addFormat('custom', ['callback' => [$foo, 'outputError']];
  * ```
  *
  * The callback can expect two parameters. The first is an array of all
  * the error data. The second contains the formatted strings generated using
  * the other template strings. Keys like `info`, `links`, `code`, `context` and `trace`
  * will be present depending on the other templates in the format type.
  *
  * @param string $format Format to use, including 'js' for JavaScript-enhanced HTML, 'html' for
  *    straight HTML output, or 'txt' for unformatted text.
  * @param array $strings Template strings, or a callback to be used for the output format.
  * @return array The resulting format string set.
  */
 public static function addFormat($format, array $strings)
 {
     $self = Debugger::getInstance();
     if (isset($self->_templates[$format])) {
         if (isset($strings['links'])) {
             $self->_templates[$format]['links'] = array_merge($self->_templates[$format]['links'], $strings['links']);
             unset($strings['links']);
         }
         $self->_templates[$format] = $strings + $self->_templates[$format];
     } else {
         $self->_templates[$format] = $strings;
     }
     return $self->_templates[$format];
 }
開發者ID:JesseDarellMoore,項目名稱:CS499,代碼行數:57,代碼來源:Debugger.php

示例2: testGetInstance

 /**
  * test getInstance.
  *
  * @return void
  */
 public function testGetInstance()
 {
     $result = Debugger::getInstance();
     $this->assertInstanceOf('Cake\\Error\\Debugger', $result);
     $result = Debugger::getInstance(__NAMESPACE__ . '\\DebuggerTestCaseDebugger');
     $this->assertInstanceOf(__NAMESPACE__ . '\\DebuggerTestCaseDebugger', $result);
     $result = Debugger::getInstance();
     $this->assertInstanceOf(__NAMESPACE__ . '\\DebuggerTestCaseDebugger', $result);
     $result = Debugger::getInstance('Cake\\Error\\Debugger');
     $this->assertInstanceOf('Cake\\Error\\Debugger', $result);
 }
開發者ID:alexunique0519,項目名稱:Blog_Cakephp_association,代碼行數:16,代碼來源:DebuggerTest.php

示例3: _displayError

 /**
  * Display an error.
  *
  * Template method of BaseErrorHandler.
  *
  * Only when debug > 2 will a formatted error be displayed.
  *
  * @param array $error An array of error data.
  * @param bool $debug Whether or not the app is in debug mode.
  * @return void
  */
 protected function _displayError($error, $debug)
 {
     if (!$debug) {
         return;
     }
     Debugger::getInstance()->outputError($error);
 }
開發者ID:fabioalvaro,項目名稱:cakexuxu,代碼行數:18,代碼來源:ErrorHandler.php

示例4: output

 /**
  * Switches output format, updates format strings.
  * Can be used to switch the active output format:
  *
  * @param string $format Format to use, including 'js' for JavaScript-enhanced HTML, 'html' for
  *    straight HTML output, or 'txt' for unformatted text.
  * @param array $strings Template strings to be used for the output format.
  * @return string
  * @deprecated 3.0.0 Use Debugger::outputAs() and Debugger::addFormat(). Will be removed
  *   in 3.0
  */
 public static function output($format = null, $strings = array())
 {
     $self = Debugger::getInstance();
     $data = null;
     if ($format === null) {
         return Debugger::outputAs();
     }
     if (!empty($strings)) {
         return Debugger::addFormat($format, $strings);
     }
     if ($format === true && !empty($self->_data)) {
         $data = $self->_data;
         $self->_data = array();
         $format = false;
     }
     Debugger::outputAs($format);
     return $data;
 }
開發者ID:maitrepylos,項目名稱:nazeweb,代碼行數:29,代碼來源:Debugger.php


注:本文中的Cake\Error\Debugger::getInstance方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。