本文整理汇总了PHP中Debugger::trimPath方法的典型用法代码示例。如果您正苦于以下问题:PHP Debugger::trimPath方法的具体用法?PHP Debugger::trimPath怎么用?PHP Debugger::trimPath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Debugger
的用法示例。
在下文中一共展示了Debugger::trimPath方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: beforeRenderFile
/**
* Sets a timer point before rendering a file.
*
* @param string $viewFile The view being rendered
*/
public function beforeRenderFile($viewFile)
{
if ($this->_renderComplete) {
return;
}
DebugTimer::start('render_' . basename($viewFile), __d('debug_kit', 'Rendering %s', Debugger::trimPath($viewFile)));
}
示例2: _render
/**
* Overload _render to capture filenames and time actual rendering of each view file
*
* @param string $___viewFn Filename of the view
* @param array $___dataForView Data to include in rendered view
* @return string Rendered output
* @access protected
*/
function _render($___viewFn, $___dataForView, $loadHelpers = true, $cached = false)
{
if (!isset($___dataForView['disableTimer'])) {
DebugKitDebugger::startTimer('render_' . basename($___viewFn), sprintf(__d('debug_kit', 'Rendering %s', true), Debugger::trimPath($___viewFn)));
}
$out = parent::_render($___viewFn, $___dataForView, $loadHelpers, $cached);
if (!isset($___dataForView['disableTimer'])) {
DebugKitDebugger::stopTimer('render_' . basename($___viewFn));
}
return $out;
}
示例3: testGetCallbacks
public function testGetCallbacks()
{
$listeners = array(array('callable' => array('SomeClass', 'someStaticMethod')), array('callable' => array($this, 'someInstanceMethod')), array('callable' => function () {
return 'Some Closure';
}));
$line = __LINE__;
$path = Debugger::trimPath(__FILE__);
$expected = array('SomeClass::someStaticMethod', 'CrudPanelTest::someInstanceMethod', $path . ':' . ($line - 5));
$return = $this->callProtectedMethod('_getCallbacks', array($listeners), $this->Panel);
$this->assertSame($expected, $return);
}
示例4: _render
/**
* Overload _render to capture filenames and time actual rendering of each view file
*
* @param string $___viewFn Filename of the view
* @param array $___dataForView Data to include in rendered view
* @return string Rendered output
*/
protected function _render($___viewFn, $___dataForView = array())
{
if (!isset($___dataForView['disableTimer'])) {
DebugTimer::start('render_' . basename($___viewFn), __d('debug_kit', 'Rendering %s', Debugger::trimPath($___viewFn)));
}
$out = parent::_render($___viewFn, $___dataForView);
if (!isset($___dataForView['disableTimer'])) {
DebugTimer::stop('render_' . basename($___viewFn));
}
return $out;
}
示例5: _render
/**
* Overload _render to capture filenames and time actual rendering of each view file
*
* @param string $___viewFn Filename of the view
* @param array $___dataForView Data to include in rendered view
* @return string Rendered output
* @access protected
*/
function _render($___viewFn, $___dataForView, $loadHelpers = true, $cached = false)
{
if (isset($this->_oldExtension) && strstr($___viewFn, '.debug_view')) {
$___viewFn = substr($___viewFn, 0, -10) . $this->_oldExtension;
}
if (!isset($___dataForView['disableTimer'])) {
DebugKitDebugger::startTimer('render_' . basename($___viewFn), sprintf(__('Rendering %s', true), Debugger::trimPath($___viewFn)));
}
$out = parent::_render($___viewFn, $___dataForView, $loadHelpers, $cached);
if (!isset($___dataForView['disableTimer'])) {
DebugKitDebugger::stopTimer('render_' . basename($___viewFn));
}
return $out;
}
示例6: read
/**
* Read a config file and return its contents.
*
* Keys with `.` will be treated as values in plugins. Instead of reading from
* the initialized path, plugin keys will be located using App::pluginPath().
*
*
* @param string $key The identifier to read from. If the key has a . it will be treated
* as a plugin prefix. path extension is not needed by default, but possible to specify
* your own extension, e.g. Configure::load('Hoge.yaml', new YamlReader);
* @return array Parsed configuration values.
* @throws ConfigureException when files doesn't exist or when files contain '..' as this could lead to abusive reads.
*/
public function read($key)
{
App::uses('Spyc', 'vendors');
if (!class_exists('Spyc')) {
App::uses('Spyc', 'YamlReader.vendors');
}
$filePath = $this->_getFilePath($key);
if (!file_exists($filePath)) {
$filePath .= ".{$this->ext}";
if (!file_exists($filePath)) {
throw new ConfigureException(__('Could not load configuration file: ') . Debugger::trimPath($filePath));
}
}
$config = Spyc::YAMLLoad($filePath);
if ($this->baseKey) {
$config = array($key => $config);
}
return $config;
}
示例7: handleError
/**
* override core one with the following enhancements/fixes:
* - 404s log to a different domain
* - IP, Referer and Browser-Infos are added for better error debugging/tracing
* 2011-12-21 ms
*/
public static function handleError($code, $description, $file = null, $line = null, $context = null)
{
if (error_reporting() === 0) {
return false;
}
$errorConfig = Configure::read('Error');
list($error, $log) = self::mapErrorCode($code);
$debug = Configure::read('debug');
if ($debug) {
$data = array('level' => $log, 'code' => $code, 'error' => $error, 'description' => $description, 'file' => $file, 'line' => $line, 'context' => $context, 'start' => 2, 'path' => Debugger::trimPath($file));
return Debugger::getInstance()->outputError($data);
} else {
$message = $error . ' (' . $code . '): ' . $description . ' in [' . $file . ', line ' . $line . ']';
if (!empty($errorConfig['trace'])) {
$trace = Debugger::trace(array('start' => 1, 'format' => 'log'));
$message .= "\nTrace:\n" . $trace . "\n";
$message .= self::traceDetails();
}
return CakeLog::write($log, $message);
}
}
示例8: testTrimPath
/**
* testTrimPath method
*
* @return void
*/
public function testTrimPath()
{
$this->assertEquals('APP' . DS, Debugger::trimPath(APP));
$this->assertEquals('CORE', Debugger::trimPath(CAKE_CORE_INCLUDE_PATH));
$this->assertEquals('ROOT', Debugger::trimPath(ROOT));
$this->assertEquals('CORE' . DS . 'Cake' . DS, Debugger::trimPath(CAKE));
$this->assertEquals('Some/Other/Path', Debugger::trimPath('Some/Other/Path'));
}
示例9: shutDownFunction
/**
* own shutdown function - also logs fatal errors (necessary until cake2.2)
* 2010-10-17 ms
*/
function shutDownFunction()
{
$error = error_get_last();
if (empty($error)) {
return;
}
$matching = array(E_ERROR => 'E_ERROR', E_WARNING => 'E_WARNING', E_PARSE => 'E_', E_NOTICE => 'E_', E_CORE_ERROR => 'E_', E_COMPILE_ERROR => 'E_', E_COMPILE_WARNING => 'E_', E_STRICT => 'E_STRICT', E_RECOVERABLE_ERROR => 'E_RECOVERABLE_ERROR', E_DEPRECATED => 'E_DEPRECATED');
App::uses('CakeLog', 'Log');
if (in_array($error['type'], array(E_ERROR, E_PARSE, E_CORE_ERROR, E_COMPILE_ERROR))) {
$error['type_name'] = 'Fatal Error';
$type = 'error';
} elseif (Configure::read('Debug.log') && isset($matching[$error['type']])) {
$error['type_name'] = 'Error';
$type = 'notice';
}
if (!isset($type)) {
return;
}
App::uses('Debugger', 'Utility');
$trace = Debugger::trace(array('start' => 1, 'format' => 'log', 'args' => true));
$path = Debugger::trimPath($error['file']);
$message = $error['type_name'] . ' ' . $matching[$error['type']] . ' in ' . $path . ' (line ' . $error['line'] . '): ' . $error['message'];
$message .= PHP_EOL . $trace;
App::uses('MyErrorHandler', 'Tools.Error');
$message .= MyErrorHandler::traceDetails();
CakeLog::write($type, $message);
}
示例10: testTrimPath
/**
* testTrimPath method
*
* @return void
*/
public function testTrimPath()
{
$this->assertEquals(Debugger::trimPath(APP), 'APP' . DS);
$this->assertEquals(Debugger::trimPath(CAKE_CORE_INCLUDE_PATH), 'CORE');
}
示例11: _escapeTrace
/**
* Fix a trace for use in output
*
* @param mixed $trace Trace to fix
* @return string
*/
protected static function _escapeTrace($trace)
{
for ($i = 0, $len = count($trace); $i < $len; $i++) {
if (isset($trace[$i]['file'])) {
$trace[$i]['file'] = Debugger::trimPath($trace[$i]['file']);
}
if (isset($trace[$i]['args'])) {
$trace[$i]['args'] = FireCake::stringEncode($trace[$i]['args']);
}
}
return $trace;
}
示例12: handleError
/**
* Set as the default error handler by CakePHP. Use Configure::write('Error.handler', $callback), to use your own
* error handling methods. This function will use Debugger to display errors when debug > 0. And
* will log errors to CakeLog, when debug == 0.
*
* You can use Configure::write('Error.level', $value); to set what type of errors will be handled here.
* Stack traces for errors can be enabled with Configure::write('Error.trace', true);
*
* @param int $code Code of error
* @param string $description Error description
* @param string $file File on which error occurred
* @param int $line Line that triggered the error
* @param array $context Context
* @return bool true if error was handled
*/
public static function handleError($code, $description, $file = null, $line = null, $context = null)
{
if (error_reporting() === 0) {
return false;
}
$errorConfig = Configure::read('Error');
list($error, $log) = self::mapErrorCode($code);
if ($log === LOG_ERR) {
return self::handleFatalError($code, $description, $file, $line);
}
$debug = Configure::read('debug');
if ($debug) {
$data = array('level' => $log, 'code' => $code, 'error' => $error, 'description' => $description, 'file' => $file, 'line' => $line, 'context' => $context, 'start' => 2, 'path' => Debugger::trimPath($file));
return Debugger::getInstance()->outputError($data);
}
$message = $error . ' (' . $code . '): ' . $description . ' in [' . $file . ', line ' . $line . ']';
#mod blamoo@live.com
$message .= "\nForwarded-For: " . (isset($_SERVER["HTTP_X_FORWARDED_FOR"]) ? $_SERVER["HTTP_X_FORWARDED_FOR"] : '(None)');
#MOD
$message .= "\nReferer: " . (isset($_SERVER['HTTP_REFERER']) ? "<a href=\"{$_SERVER['HTTP_REFERER']}\">{$_SERVER['HTTP_REFERER']}</a>" : '(None)');
#MOD
$message .= "\nUA: " . (isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : '(None)');
#MOD
$message .= "\nMethod: " . (isset($_SERVER['REQUEST_METHOD']) ? $_SERVER['REQUEST_METHOD'] : '(None)');
#MOD
if (count($_POST) !== 0) {
$message .= "\nPost: <pre>" . var_export($_POST, true) . '</pre>';
#MOD
}
#endmod
if (!empty($errorConfig['trace'])) {
$trace = Debugger::trace(array('start' => 1, 'format' => 'log'));
$message .= "\nTrace:\n" . $trace . "\n";
}
return CakeLog::write($log, $message);
}
示例13: _getClosureDefinition
/**
* Return where a closure has been defined
*
* If for some reason this doesn't work - it'll return the closure instance in the full knowledge
* that it'll probably get dumped as the string "function"
*
* @param Closure $closure
* @return mixed string or Closure
*/
protected function _getClosureDefinition(Closure $closure)
{
$exported = ReflectionFunction::export($closure, true);
preg_match('#@@ (.*) (\\d+) - (\\d+)#', $exported, $match);
if (!$match) {
return $closure;
}
list($m, $path, $start) = $match;
$path = Debugger::trimPath($path);
return "{$path}:{$start}";
}
示例14: update
/**
* update method
*
* @return void
* @access public
*/
public function update()
{
if (!file_exists(CAKE . 'config' . DS . 'sources.txt')) {
$File = new File(CAKE . 'config' . DS . 'sources.txt', true);
$File->write('file://' . dirname(__FILE__) . DS . 'packages.txt');
}
$sources = file(CAKE . 'config' . DS . 'sources.txt');
$packages = array();
App::import('Core', 'HttpSocket');
$Socket = new HttpSocket();
foreach ($sources as &$source) {
$source = trim($source);
if (!$source || $source[0] === '#') {
$source = false;
continue;
}
if (strpos($source, 'file://') !== false) {
$data = file($source);
} else {
$data = $Socket->get($source);
if (!$data) {
$source .= ' (no response)';
continue;
}
$data = explode("\n", $data);
}
$packages = array_merge($packages, MiInstall::_parsePackages($data));
}
$File = new File(CAKE . 'config' . DS . 'packages.php', true);
$File->write("<?php\n\$config = " . var_export($packages, true) . ';');
$return[] = Debugger::trimPath($File->pwd()) . ' updated';
$return['sources checked:'] = array_filter($sources);
return $return;
}
示例15: handleError
/**
* Set as the default error handler by CakePHP. Use Configure::write('Error.handler', $callback), to use your own
* error handling methods. This function will use Debugger to display errors when debug > 0. And
* will log errors to CakeLog, when debug == 0.
*
* You can use Configure::write('Error.level', $value); to set what type of errors will be handled here.
* Stack traces for errors can be enabled with Configure::write('Error.trace', true);
*
* @param int $code Code of error
* @param string $description Error description
* @param string $file File on which error occurred
* @param int $line Line that triggered the error
* @param array $context Context
* @return bool true if error was handled
*/
public static function handleError($code, $description, $file = null, $line = null, $context = null)
{
if (error_reporting() === 0) {
return false;
}
list($error, $log) = static::mapErrorCode($code);
if ($log === LOG_ERR) {
return static::handleFatalError($code, $description, $file, $line);
}
$debug = Configure::read('debug');
if ($debug) {
$data = array('level' => $log, 'code' => $code, 'error' => $error, 'description' => $description, 'file' => $file, 'line' => $line, 'context' => $context, 'start' => 2, 'path' => Debugger::trimPath($file));
return Debugger::getInstance()->outputError($data);
}
$message = static::_getErrorMessage($error, $code, $description, $file, $line);
return CakeLog::write($log, $message);
}