当前位置: 首页>>代码示例>>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;未经允许,请勿转载。