本文整理汇总了PHP中yii\helpers\VarDumper::export方法的典型用法代码示例。如果您正苦于以下问题:PHP VarDumper::export方法的具体用法?PHP VarDumper::export怎么用?PHP VarDumper::export使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类yii\helpers\VarDumper
的用法示例。
在下文中一共展示了VarDumper::export方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: format
public function format($response)
{
$response->getHeaders()->set('Content-Type', 'text/php; charset=UTF-8');
if ($response->data !== null) {
$response->content = "<?php\nreturn " . VarDumper::export($response->data) . ";\n";
}
}
示例2: export
/**
* Stores log messages to DB.
*/
public function export()
{
$tableName = $this->db->quoteTableName($this->logTable);
$sql = "INSERT INTO {$tableName} ([[level]], [[category]], [[log_time]], [[prefix]], [[message]], [[model]], [[blame]])\n VALUES (:level, :category, :log_time, :prefix, :message, :model, :blame)";
$command = $this->db->createCommand($sql);
foreach ($this->messages as $message) {
list($text, $level, $category, $timestamp) = $message;
$extracted = ['msg' => '', 'model' => null, 'blame' => null];
if (is_array($text) && (isset($text['msg']) || isset($text['model']) || isset($text['blame']))) {
if (isset($text['msg'])) {
if (!is_string($text['msg'])) {
$extracted['msg'] = VarDumper::export($text['msg']);
} else {
$extracted['msg'] = $text['msg'];
}
}
if (isset($text['model'])) {
$extracted['model'] = $text['model'];
}
if (isset($text['blame'])) {
$extracted['blame'] = $text['blame'];
}
} elseif (is_string($text)) {
$extracted['msg'] = $text;
} else {
$extracted['msg'] = VarDumper::export($text);
}
$command->bindValues([':level' => $level, ':category' => $category, ':log_time' => $timestamp, ':prefix' => $this->getMessagePrefix($message), ':message' => $extracted['msg'], ':model' => $extracted['model'], ':blame' => $extracted['blame']])->execute();
}
}
示例3: getDirectories
/**
* @return array all directories
*/
protected function getDirectories()
{
if ($this->_paths === null) {
$paths = ArrayHelper::getValue(Yii::$app->params, $this->paramVar, []);
$paths = array_merge($paths, $this->migrationLookup);
$extra = !empty($this->extraFile) && is_file($this->extraFile = Yii::getAlias($this->extraFile)) ? require $this->extraFile : [];
$paths = array_merge($extra, $paths);
$p = [];
foreach ($paths as $path) {
$p[Yii::getAlias($path, false)] = true;
}
unset($p[false]);
$currentPath = Yii::getAlias($this->migrationPath);
if (!isset($p[$currentPath])) {
$p[$currentPath] = true;
if (!empty($this->extraFile)) {
$extra[] = $this->migrationPath;
FileHelper::createDirectory(dirname($this->extraFile));
file_put_contents($this->extraFile, "<?php\nreturn " . VarDumper::export($extra) . ";\n", LOCK_EX);
}
}
$this->_paths = array_keys($p);
foreach ($this->migrationNamespaces as $namespace) {
$path = str_replace('/', DIRECTORY_SEPARATOR, Yii::getAlias('@' . str_replace('\\', '/', $namespace)));
$this->_paths[$namespace] = $path;
}
}
return $this->_paths;
}
示例4: commit
/**
* Writes all configuration to application configuration file
* @return bool result, true if success
*/
public function commit()
{
$data = <<<PHP
<?php
/*
* ! WARNING !
*
* This file is auto-generated.
* Please don't modify it by-hand or all your changes can be lost.
*/
{$this->append}
return
PHP;
$data .= VarDumper::export($this->configuration);
$data .= ";\n\n";
$result = file_put_contents($this->filename, $data, LOCK_EX) !== false;
if ($result) {
if (function_exists('opcache_invalidate')) {
opcache_invalidate($this->filename, true);
}
if (function_exists('apc_delete_file')) {
@apc_delete_file($this->filename);
}
}
return $result;
}
示例5: saveConfigFile
/**
* Creates message command config file named as [[configFileName]].
* @param array $config message command config.
*/
protected function saveConfigFile(array $config)
{
if (file_exists($this->configFileName)) {
unlink($this->configFileName);
}
$fileContent = '<?php return ' . VarDumper::export($config) . ';';
file_put_contents($this->configFileName, $fileContent);
}
示例6: createDatabaseConfigFile
/**
* Write database configuration content in a file
*
* @param $config
* @return bool
*/
public static function createDatabaseConfigFile($config)
{
$content = VarDumper::export($config);
$content = preg_replace('~\\\\+~', '\\', $content);
// Fix class backslash
$content = "<?php\nreturn " . $content . ";\n";
return file_put_contents(Yii::getAlias('@app/config/db.php'), $content) > 0;
}
示例7: writeCommonConfig
public static function writeCommonConfig(FinalStep $model)
{
$common_config = ['language' => Yii::$app->session->get('language'), 'components' => ['cache' => ['class' => $model->cacheClass, 'keyPrefix' => $model->keyPrefix]], 'modules' => ['core' => ['serverName' => $model->serverName, 'serverPort' => $model->serverPort]]];
if ($model->cacheClass === 'yii\\caching\\MemCache') {
$common_config['components']['cache']['useMemcached'] = $model->useMemcached;
}
return file_put_contents(Yii::getAlias('@app/config/common-local.php'), "<?php\nreturn " . VarDumper::export($common_config) . ';') > 0;
}
示例8: writeData
/**
* @inheritdoc
*/
public function writeData($fileName, array $data)
{
$fileName = $this->composeActualFileName($fileName);
$content = "<?php\n\nreturn " . VarDumper::export($data) . ";";
$bytesWritten = file_put_contents($fileName, $content);
if ($bytesWritten <= 0) {
throw new Exception("Unable to write file '{$fileName}'.");
}
}
示例9: setRuntimeConfig
public function setRuntimeConfig($config)
{
$path = $this->runtimeConfigDir();
if (!is_dir($path)) {
FileHelper::createDirectory($path);
}
$data = '<?php ' . "\nreturn " . VarDumper::export($config) . ';';
file_put_contents($path . DIRECTORY_SEPARATOR . 'config.php', $data);
}
示例10: formatMessage
/**
* @inheritdoc
*/
public function formatMessage($message)
{
list($text, $level, $category, $timestamp) = $message;
$level = Logger::getLevelName($level);
if (!is_string($text)) {
$text = VarDumper::export($text);
}
$prefix = $this->getMessagePrefix($message);
return "{$prefix}[{$level}][{$category}] {$text}";
}
示例11: export
/**
* @inheritdoc
*/
public function export()
{
foreach ($this->messages as $message) {
list($text, $level, $category, $timestamp) = $message;
if (!is_string($text)) {
$text = VarDumper::export($text);
}
$this->sendLog($text);
}
}
示例12: export
/**
* Stores log messages to MongoDB collection.
*/
public function export()
{
$collection = $this->db->getCollection($this->logCollection);
foreach ($this->messages as $message) {
list($text, $level, $category, $timestamp) = $message;
if (!is_string($text)) {
$text = VarDumper::export($text);
}
$collection->insert(['level' => $level, 'category' => $category, 'log_time' => $timestamp, 'prefix' => $this->getMessagePrefix($message), 'message' => $text]);
}
}
示例13: match
/**
* @inheritdoc
*/
public function match($value)
{
if (!is_scalar($value)) {
$value = VarDumper::export($value);
}
if ($this->partial) {
return mb_stripos($value, $this->baseValue, 0, \Yii::$app->charset) !== false;
} else {
return strcmp(mb_strtoupper($this->baseValue, \Yii::$app->charset), mb_strtoupper($value, \Yii::$app->charset)) === 0;
}
}
示例14: saveConfig
public function saveConfig()
{
$this->beforeSave();
$conf = $this->getAttributes();
unset($conf['blockId'], $conf['widgetId'], $conf['comment']);
$conf['__block'] = ['widgetId' => $this->widgetId, 'comment' => $this->comment, 'widgetClass' => DynBlockHelper::widgetClassById($this->widgetId, true), 'modelClass' => DynBlockHelper::widgetModelClassNameById($this->widgetId)];
$s = VarDumper::export($conf);
$s = "<?php\nreturn " . $s . ";";
$fn = DynBlockHelper::configFile($this->blockId);
file_put_contents($fn, $s);
}
示例15: __construct
/**
* Constructor.
*
* @param Item $item
* @param array $config
*/
public function __construct($item, $config = [])
{
$this->_item = $item;
if ($item !== null) {
$this->name = $item->name;
$this->type = (int) $item->type;
$this->description = $item->description;
$this->ruleName = $item->ruleName;
$this->data = $item->data === null ? null : VarDumper::export($item->data);
}
parent::__construct($config);
}