本文整理汇总了PHP中Debugger::exportVar方法的典型用法代码示例。如果您正苦于以下问题:PHP Debugger::exportVar方法的具体用法?PHP Debugger::exportVar怎么用?PHP Debugger::exportVar使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Debugger
的用法示例。
在下文中一共展示了Debugger::exportVar方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getLogContents
/**
*
* @return string
*/
protected function getLogContents()
{
$log = $this;
$request = $log->request;
$remoteIp = $log->remoteIp;
$referer = $request->referer();
$params = Debugger::exportVar($request->params, 25);
$data = Debugger::exportVar($request->data, 25);
$result = array('LogType : User Login Error', 'IP : ' . $remoteIp, 'Referer : ' . $referer, '---Params---', $params, '---Data---', $data, '---End---');
return join("\n", $result);
}
示例2: getLogContents
/**
* ユーザID、コントローラ名、アクション名、メソッド名(post or get)、リクエストパラメータ
* @return string
*/
protected function getLogContents()
{
$log = $this;
$auth = $log->auth;
$model = $log->model;
$userId = self::createUserId($auth);
$mdoelName = $model->name;
$data = Debugger::exportVar($model->data, 25);
$result = array('LogType : Create Data', 'UserId : ' . $userId, 'ModelName : ' . $mdoelName, '---Data---', $data, '---End---');
return join("\n", $result);
}
示例3: save
public function save($data = null, $validate = true, $fieldList = array())
{
$res = parent::save($data, $validate, $fieldList);
if (!$res) {
$this->log('[' . $this->alias . "] save error \n===== Validation errors =====\n" . Debugger::exportVar($this->validationErrors) . "\n===== Data =====" . Debugger::exportVar($this->data), 'debug');
if (Configure::read('debug') != 0) {
debug('[' . $this->alias . '] Save didn\'t work');
debug($this->data);
debug($this->validationErrors);
}
}
return $res;
}
示例4: getLogContents
/**
* ユーザID、コントローラ名、アクション名、メソッド名(post or get)、リクエストパラメータ
* @return string
*/
protected function getLogContents()
{
$log = $this;
$request = $log->request;
$auth = $log->auth;
$userId = self::createUserId($auth);
$medhod = $request->method();
$referer = $request->referer();
$params = Debugger::exportVar($request->params, 25);
$data = Debugger::exportVar($request->data, 25);
$ctlName = Inflector::camelize($request->params['controller']);
$actionName = $request->params['action'];
$result = array('LogType : User Access', 'UserId : ' . $userId, 'Access : ' . $ctlName . 'Controller::' . $actionName . '();', 'Referer : ' . $referer, 'Medhod : ' . $medhod, '---Params---', $params, '---Data---', $data, '---End---');
return join("\n", $result);
}
示例5: main
//.........这里部分代码省略.........
$this->out("Removed {$association} association between {$modelA} and {$modelB}");
} else {
$this->out("Please verify you are using valid models, valid current association, and valid association types");
}
break;
case strpos($command, "->find") > 0:
// Remove any bad info
$command = strip_tags($command);
$command = str_replace($this->badCommandChars, "", $command);
// Do we have a valid model?
list($modelToCheck, $tmp) = explode('->', $command);
if ($this->__isValidModel($modelToCheck)) {
$findCommand = "\$data = \$this->{$command};";
@eval($findCommand);
if (is_array($data)) {
foreach ($data as $idx => $results) {
if (is_numeric($idx)) {
// findAll() output
foreach ($results as $modelName => $result) {
$this->out("{$modelName}");
foreach ($result as $field => $value) {
if (is_array($value)) {
foreach ($value as $field2 => $value2) {
$this->out("\t{$field2}: {$value2}");
}
$this->out("");
} else {
$this->out("\t{$field}: {$value}");
}
}
}
} else {
// find() output
$this->out($idx);
foreach ($results as $field => $value) {
if (is_array($value)) {
foreach ($value as $field2 => $value2) {
$this->out("\t{$field2}: {$value2}");
}
$this->out("");
} else {
$this->out("\t{$field}: {$value}");
}
}
}
}
} else {
$this->out("\nNo result set found");
}
} else {
$this->out("{$modelToCheck} is not a valid model");
}
break;
case strpos($command, '->save') > 0:
// Validate the model we're trying to save here
$command = strip_tags($command);
$command = str_replace($this->badCommandChars, "", $command);
list($modelToSave, $tmp) = explode("->", $command);
if ($this->__isValidModel($modelToSave)) {
// Extract the array of data we are trying to build
list($foo, $data) = explode("->save", $command);
$badChars = array("(", ")");
$data = str_replace($badChars, "", $data);
$saveCommand = "\$this->{$modelToSave}->save(array('{$modelToSave}' => array({$data})));";
@eval($saveCommand);
$this->out('Saved record for ' . $modelToSave);
}
break;
case preg_match("/^(\\w+) columns/", $command, $tmp) == true:
$modelToCheck = strip_tags(str_replace($this->badCommandChars, "", $tmp[1]));
if ($this->__isValidModel($modelToCheck)) {
// Get the column info for this model
$fieldsCommand = "\$data = \$this->{$modelToCheck}->getColumnTypes();";
@eval($fieldsCommand);
if (is_array($data)) {
foreach ($data as $field => $type) {
$this->out("\t{$field}: {$type}");
}
}
} else {
$this->out("Please verify that you selected a valid model");
}
break;
case preg_match("/^routes\\s+reload/i", $command, $tmp) == true:
$router =& Router::getInstance();
$router->reload();
if (config('routes') && $router->parse('/')) {
$this->out("Routes configuration reloaded, " . count($router->routes) . " routes connected");
}
break;
case preg_match("/^route\\s+(.*)/i", $command, $tmp) == true:
$this->out(Debugger::exportVar(Router::parse($tmp[1])));
break;
default:
$this->out("Invalid command\n");
break;
}
$command = '';
}
}
示例6: testExportVar
/**
* testExportVar method
*
* @access public
* @return void
*/
function testExportVar()
{
App::import('Controller');
$Controller = new Controller();
$Controller->helpers = array('Html', 'Form');
$View = new View($Controller);
$result = Debugger::exportVar($View);
$expected = 'ViewView::$base = NULL
View::$here = NULL
View::$plugin = NULL
View::$name = ""
View::$action = NULL
View::$params = array
View::$passedArgs = array
View::$data = array
View::$helpers = array
View::$viewPath = ""
View::$viewVars = array
View::$layout = "default"
View::$layoutPath = NULL
View::$pageTitle = false
View::$autoRender = true
View::$autoLayout = true
View::$ext = ".ctp"
View::$subDir = NULL
View::$themeWeb = NULL
View::$cacheAction = false
View::$validationErrors = array
View::$hasRendered = false
View::$loaded = array
View::$modelScope = false
View::$model = NULL
View::$association = NULL
View::$field = NULL
View::$fieldSuffix = NULL
View::$modelId = NULL
View::$uuids = array
View::$output = false
View::$__passedVars = array
View::$__scripts = array
View::$__paths = array
View::$_log = NULL
View::$webroot = NULL';
$result = str_replace(array("\t", "\r\n", "\n"), "", $result);
$expected = str_replace(array("\t", "\r\n", "\n"), "", $expected);
$this->assertEqual($result, $expected);
}
示例7: testExportVarRecursion
/**
* Test that exportVar() doesn't loop through recursive structures.
*
* @return void
*/
public function testExportVarRecursion()
{
$output = Debugger::exportVar($GLOBALS);
$this->assertContains("'GLOBALS' => [recursion]", $output);
}
示例8: _debug
/**
* Logs some debug output.
*
* @return void
*/
private function _debug($o)
{
if ($this->enableDebug) {
$ds = str_repeat('-', 4);
error_log(implode("\n", array('Begin debug output... ', "{$ds}Var Export{$ds}", Debugger::exportVar($o), "{$ds}Stack Trace{$ds}", Debugger::trace())));
}
}
示例9: testExportVar
/**
* testExportVar method
*
* @access public
* @return void
*/
function testExportVar()
{
App::import('Controller');
$Controller = new Controller();
$Controller->helpers = array('Html', 'Form');
$View = new View($Controller);
$result = Debugger::exportVar($View);
$expected = 'View
View::$Helpers = HelperCollection object
View::$plugin = NULL
View::$name = ""
View::$passedArgs = array
View::$helpers = array
View::$viewPath = ""
View::$viewVars = array
View::$layout = "default"
View::$layoutPath = NULL
View::$autoLayout = true
View::$ext = ".ctp"
View::$subDir = NULL
View::$theme = NULL
View::$cacheAction = false
View::$validationErrors = array
View::$hasRendered = false
View::$modelScope = false
View::$model = NULL
View::$association = NULL
View::$field = NULL
View::$fieldSuffix = NULL
View::$modelId = NULL
View::$uuids = array
View::$output = false
View::$request = NULL
View::$elementCache = "default"';
$result = str_replace(array("\t", "\r\n", "\n"), "", $result);
$expected = str_replace(array("\t", "\r\n", "\n"), "", $expected);
$this->assertEqual($result, $expected);
}
示例10: write
/**
* Writes value to given session variable name.
*
* @param mixed $name Name of variable
* @param string $value Value to write
* @return boolean True if the write was successful, false if the write failed
* @access public
*/
public function write($name, $value)
{
if (empty($name)) {
return false;
}
if (in_array($name, $this->watchKeys)) {
trigger_error(sprintf(__('Writing session key {%s}: %s', true), $name, Debugger::exportVar($value)), E_USER_NOTICE);
}
$this->__overwrite($_SESSION, Set::insert($_SESSION, $name, $value));
return Set::classicExtract($_SESSION, $name) === $value;
}
示例11: __object
/**
* Handles object to string conversion.
*
* @param string $var Object to convert
* @return string
* @access private
* @see Debugger:exportVar()
*/
function __object($var)
{
$out = array();
if (is_object($var)) {
$className = get_class($var);
$objectVars = get_object_vars($var);
foreach ($objectVars as $key => $value) {
if (is_object($value)) {
$value = get_class($value) . ' object';
} elseif (is_array($value)) {
$value = 'array';
} elseif ($value === null) {
$value = 'NULL';
} elseif (in_array(gettype($value), array('boolean', 'integer', 'double', 'string', 'array', 'resource'))) {
$value = Debugger::exportVar($value);
}
$out[] = "{$className}::\${$key} = " . $value;
}
}
return join("\n", $out);
}
示例12: generate
public function generate()
{
$rights = Configure::read('User.UserRight');
$update = false;
foreach (App::objects('plugins') as $plugin) {
if (in_array($plugin, array('Blocks', 'DebugKit', 'MultiLanguage'))) {
continue;
}
$path = CakePlugin::path($plugin) . 'Controller/';
$files = scandir($path);
if (!isset($rights['plugin'][$plugin]['name'])) {
$rights['plugin'][$plugin]['name'] = $plugin;
$rights['plugin'][$plugin]['status'] = USER_FUNC_ACTIVE;
$update = true;
}
foreach ($files as $file) {
if (is_file($path . $file)) {
$str = file_get_contents($path . $file);
preg_match_all('/public\\s+function\\s+(.+)\\s*\\(/', $str, $funcs);
if (count($funcs[1]) == 0) {
continue;
}
$controller = str_replace('.php', '', $file);
if ($controller != 'UserAdminController') {
if (!isset($rights['plugin'][$plugin]['controller'][$controller]['name'])) {
$rights['plugin'][$plugin]['controller'][$controller]['name'] = str_replace('Controller', '', $controller);
$rights['plugin'][$plugin]['controller'][$controller]['status'] = USER_FUNC_ACTIVE;
}
foreach ($funcs[1] as $func) {
if (in_array($func, array('beforeFilter', 'beforeRender', 'afterFilter'))) {
continue;
}
if (!isset($rights['plugin'][$plugin]['controller'][$controller]['action'][$func])) {
$rights['plugin'][$plugin]['controller'][$controller]['action'][$func]['name'] = $func;
$rights['plugin'][$plugin]['controller'][$controller]['action'][$func]['status'] = USER_FUNC_ACTIVE;
$update = true;
}
}
}
}
}
}
foreach (App::objects('controller') as $controller) {
if ($controller == 'AppController') {
continue;
}
$path = APP . 'Controller/';
$str = file_get_contents($path . $controller . '.php');
preg_match_all('/public\\s+function\\s+(.+)\\s*\\(/', $str, $funcs);
if (count($funcs[1]) == 0) {
continue;
}
if (!isset($rights['controller'][$controller]['name'])) {
$rights['controller'][$controller]['name'] = str_replace('Controller', '', $controller);
$rights['controller'][$controller]['status'] = USER_FUNC_ACTIVE;
$update = true;
}
foreach ($funcs[1] as $func) {
if (in_array($func, array('beforeFilter', 'beforeRender', 'afterFilter'))) {
continue;
}
if (!isset($rights['controller'][$controller]['action'][$func])) {
$rights['controller'][$controller]['action'][$func]['name'] = $func;
$rights['controller'][$controller]['action'][$func]['status'] = USER_FUNC_ACTIVE;
$update = true;
}
}
}
if ($update) {
file_put_contents(CakePlugin::path('User') . 'Config/rights.php', "<?php\n\$rights = " . str_replace('(int) ', '', Debugger::exportVar($rights, 10)) . ';');
}
die;
}
示例13: testExportVar
function testExportVar()
{
App::import('Controller');
$Controller = new Controller();
$Controller->helpers = array('Html', 'Form');
$View = new View($Controller);
$result = Debugger::exportVar($View);
$expected = 'ViewView::$base = NULL
View::$here = NULL
View::$plugin = NULL
View::$name = "[empty string]"
View::$action = NULL
View::$params = array()
View::$passedArgs = array()
View::$data = array()
View::$helpers = array("Html","Form")
View::$viewPath = "[empty string]"
View::$viewVars = array()
View::$layout = "default"
View::$layoutPath = NULL
View::$pageTitle = false
View::$autoRender = true
View::$autoLayout = true
View::$ext = ".ctp"
View::$subDir = NULL
View::$themeWeb = NULL
View::$cacheAction = false
View::$validationErrors = array()
View::$hasRendered = false
View::$loaded = array()
View::$modelScope = false
View::$model = NULL
View::$association = NULL
View::$field = NULL
View::$fieldSuffix = NULL
View::$modelId = NULL
View::$uuids = array()
View::$__passedVars = array("viewVars","action","autoLayout","autoRender","ext","base","webroot","helpers","here","layout","name","pageTitle","layoutPath","viewPath","params","data","webservices","plugin","passedArgs","cacheAction")
View::$__scripts = array()
View::$__paths = array()
View::$_log = NULL
View::$webroot = NULL
View::$webservices = NULL
View::element()
View::render()
View::renderElement()
View::renderLayout()
View::renderCache()
View::getVars()
View::getVar()
View::addScript()
View::uuid()
View::entity()
View::set()
View::error()
View::Object()
View::toString()
View::requestAction()
View::log()
View::cakeError()';
$result = str_replace(array("\t", "\r\n", "\n"), "", $result);
$expected = str_replace(array("\t", "\r\n", "\n"), "", $expected);
$this->assertEqual($result, $expected);
}
示例14: __object
/**
* Handles object conversion to debug string
*
* @param string $var Object to convert
* @access private
*/
function __object($var)
{
static $history = array();
$serialized = serialize($var);
array_push($history, $serialized);
$out = array();
if (is_object($var)) {
$className = get_class($var);
$objectVars = get_object_vars($var);
foreach ($objectVars as $key => $value) {
$inline = null;
if (strpos($key, '_', 0) !== 0) {
$inline = "{$className}::{$key} = ";
}
if (is_object($value) || is_array($value)) {
$serialized = serialize($value);
if (in_array($serialized, $history, true)) {
$value = ife(is_object($value), "*RECURSION* -> " . get_class($value), "*RECURSION*");
}
}
if (in_array(gettype($value), array('boolean', 'integer', 'double', 'string', 'array', 'resource', 'object', 'null'))) {
$out[] = "{$className}::\${$key} = " . Debugger::exportVar($value);
} else {
$out[] = "{$className}::\${$key} = " . var_export($value, true);
}
}
$objectMethods = get_class_methods($className);
foreach ($objectMethods as $key => $value) {
if (strpos($value, '_', 0) !== 0) {
$out[] = "{$className}::{$value}()";
}
}
}
array_pop($history);
return join("\n", $out);
}
示例15: exec
/**
* Utility Exec method
*
* @param mixed $cmd
* @param mixed $output
* @return void
* @access public
*/
public function exec($cmd, &$out = array())
{
if (DS === '/') {
$_out = exec($cmd . ' 2>&1', $out, $return);
} else {
$_out = exec($cmd, $out, $return);
}
if (Configure::read()) {
$source = Debugger::trace(array('depth' => 1, 'start' => 2)) . "\n";
CakeLog::write('system_calls_' . date('Y-m-d'), "\n" . $source . Debugger::exportVar(compact('cmd', 'out', 'return')));
CakeLog::write('system_calls', "\n" . $source . Debugger::exportVar(compact('cmd', 'out', 'return')));
}
if ($return) {
return false;
}
return $_out ? $_out : true;
}