本文整理汇总了PHP中CVarDumper类的典型用法代码示例。如果您正苦于以下问题:PHP CVarDumper类的具体用法?PHP CVarDumper怎么用?PHP CVarDumper使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CVarDumper类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
public function run($isTab = false)
{
/** @var TourBuilderForm $tourForm */
$tourForm = Yii::app()->user->getState('tourForm');
$eventId = $tourForm->eventId;
$startCities = Yii::app()->user->getState('startCities');
$currentStartCityIndex = Yii::app()->user->getState('startCitiesIndex') - 1;
$currentStartCity = City::model()->findByPk($startCities[$currentStartCityIndex]->id);
$startCityId = $currentStartCity->id;
$event = Event::model()->findByPk($eventId);
$tripStorage = new TripStorage();
$order = $tripStorage->saveOrder($event, $startCityId, 'Тур для события "' . $event->title . '" из ' . $currentStartCity->caseGen);
$eventOrder = new EventOrder();
$eventOrder->startCityId = $startCityId;
$eventOrder->orderId = $order->id;
$eventOrder->eventId = $event->id;
$eventOrder->save();
$eventPrice = EventPrice::model()->findByAttributes(array('eventId' => $eventId, 'cityId' => $startCityId));
if (!$eventPrice) {
$eventPrice = new EventPrice();
}
$eventPrice->eventId = $event->id;
$eventPrice->cityId = $startCityId;
$eventPrice->bestPrice = $tripStorage->getPrice();
if (!$eventPrice->save()) {
throw new CHttpException('Could not save price for event - city.' . CVarDumper::dumpAsString($eventPrice));
}
$this->controller->redirect($this->controller->createUrl('showEventTrip'));
}
示例2: dump
public static function dump()
{
echo '<pre>';
CVarDumper::dump(func_get_args());
echo '<pre>';
exit;
}
示例3: registerScript
public function registerScript($id, $script, $position = null, array $htmlOptions = array())
{
// assumed config includes the required path aliases to use
// EScriptBoost
$debug = YII_DEBUG;
// Check if this script is in the exceptions - if so, skip caching.
foreach ($this->skipList as $s) {
$skip |= strpos($id, $s) === 0;
if ($skip) {
break;
}
}
$compressed = !$debug ? false : Yii::app()->cache->get($id);
if ($skip) {
// Skipping scripts that should not be cached.
$compressed = EScriptBoost::minifyJs($script);
} elseif ($debug && $compressed !== false) {
// During debug check that the newly minified script is not different from the cached one.
// If so, log the difference so that it can be fixed.
$c = EScriptBoost::minifyJs($script);
if ($c !== $compressed) {
Yii::log("Issue with caching of compressed script '{$id}'\n" . CVarDumper::dumpAsString($c) . "\nXXX\n" . CVarDumper::dumpAsString($compressed), CLogger::LEVEL_ERROR);
}
} elseif ($compressed === false) {
$compressed = EScriptBoost::minifyJs($script);
Yii::app()->cache->set($id, $compressed, $this->cacheDuration);
}
parent::registerScript($id, $compressed, $position, $htmlOptions);
}
示例4: d
/**
* Функция для отладки, печатает переменную с подсветкой синтаксиса
* @param mixed
*/
function d()
{
foreach (func_get_args() as $arg) {
CVarDumper::dump($arg, 10, true);
echo '<hr>';
}
}
示例5: actionAdd
public function actionAdd()
{
$model = new Umbrella();
if (isset($_POST['Umbrella'])) {
$model->attributes = $_POST;
$model->umbrellaid = uniqid('', true);
$model->attributes = $_POST['Umbrella'];
$model->create_userid = $this->user_id;
$model->now_userid = $this->user_id;
$model->create_at = $this->getTime();
if (SERVER_TEST) {
$model->img = "http://umbrella.b0.upaiyun.com/991c/991c1b1f34d6d076bcf7e01925af1e43/7GTMyFS_QW00m6fdAzzdphLPJtGAvlF9Gd4ivkWNQ9-olR2mFgn6NBn8JW8e78H2.jpg";
}
// $model->status=UMBRELLASTATUS::IDLE;
if ($model->validate()) {
$model->img = $this->updateWxImage($model->img);
if (!$model->save()) {
Yii::log(CVarDumper::dumpAsString($user->errors), 'error', "Add umbrella save error");
}
$this->actionInfo($model->umbrellaid);
return;
}
}
$this->render('add', array('model' => $model, 'status' => 'new'));
}
示例6: dump
/**
* Displays a variable.
* This method achieves the similar functionality as var_dump and print_r
* but is more robust when handling complex objects such as Yii controllers.
* @param mixed $var variable to be dumped
*/
public static function dump()
{
$args = func_get_args();
if (php_sapi_name() == "cli") {
foreach ($args as $k => $var) {
var_dump($var);
echo "\n";
}
return;
} else {
if (empty($_SERVER['SERVER_ADDR']) || empty($_SERVER['REMOTE_ADDR']) || $_SERVER['SERVER_ADDR'] !== $_SERVER['REMOTE_ADDR']) {
return;
}
}
$backTrace = debug_backtrace();
$backTrace = array_shift($backTrace);
echo '<div style="margin: 10px;border: 1px solid red;padding: 10px; background: #fff;">';
if (is_array($backTrace) && isset($backTrace['file']) && isset($backTrace['function']) && $backTrace['function'] === __FUNCTION__) {
echo "<b>{$backTrace['file']}</b> in line <b>{$backTrace['line']}</b> <br />";
echo '<div style="border-bottom:1px solid #006699;margin: 5px 0;"></div>';
}
foreach ($args as $k => $var) {
echo CVarDumper::dump($var, 10, true), '<br />';
}
echo "</div>";
}
示例7: actionChangeState
public function actionChangeState($hotelBookerId = 0, $newState = '')
{
if ($hotelBookerId) {
/** @var HotelBookerComponent $hotelBookerComponent */
$hotelBookerComponent = new HotelBookerComponent();
$hotelBookerComponent->setHotelBookerFromId($hotelBookerId);
echo "HotelBookerId " . $hotelBookerComponent->getHotelBookerId() . PHP_EOL;
echo "Current status is " . $hotelBookerComponent->getCurrent()->swGetStatus() . PHP_EOL;
echo "Next possible status are " . $hotelBookerComponent->getCurrent()->swGetNextStatus() . PHP_EOL;
echo "Trying to change status to {$newState}" . PHP_EOL;
if ($newState) {
$res = $hotelBookerComponent->status($newState);
if (!$res) {
CVarDumper::dump($hotelBookerComponent->getCurrent()->getErrors());
CVarDumper::dump($hotelBookerComponent->getCurrent()->getAttributes());
echo PHP_EOL;
} else {
$hotelBookerComponent->getCurrent()->onlySave();
}
echo "Status is " . $hotelBookerComponent->getCurrent()->swGetStatus() . "\n";
}
} else {
$helpText = $this->getHelp();
$helpText = str_replace('command', 'ChangeState', $helpText);
echo $helpText;
}
}
示例8: injectForBe
public static function injectForBe($flightVoyages, $injectSearchParams = false)
{
$newFlights = array();
try {
if (!is_iterable($flightVoyages)) {
throw new CException('Flight Voyages are not iterable.');
}
foreach ($flightVoyages as $key => $flight) {
$newFlight = $flight;
if ($injectSearchParams) {
$newFlight['serviceClass'] = $injectSearchParams['serviceClass'];
$newFlight['freeWeight'] = $newFlight['serviceClass'] == 'E' ? $flight['economFreeWeight'] : $flight['businessFreeWeight'];
$newFlight['freeWeightDescription'] = $newFlight['serviceClass'] == 'E' ? $flight['economDescription'] : $flight['businessDescription'];
unset($newFlight['economFreeWeight']);
unset($newFlight['businessFreeWeight']);
unset($newFlight['economDescription']);
unset($newFlight['businessDescription']);
}
$newFlights[] = $newFlight;
}
return $newFlights;
} catch (Exception $e) {
$newException = new Exception("Error: " . $e->getMessage() . " Data: " . CVarDumper::dumpAsString($flightVoyages));
Yii::app()->RSentryException->logException($newException);
return $newFlights;
}
}
示例9: createOrUpdate
public static function createOrUpdate($id, $title, $address, $latitude, $longitude, $type = 'create')
{
$querystring_arrays = array();
$uri = '';
if ($type == 'create') {
//这里是创建
$uri = '/geodata/v3/poi/create';
$querystring_arrays = array('id' => $id, 'title' => $title, 'latitude' => $latitude, 'longitude' => $longitude, 'coord_type' => 1, 'geotable_id' => GEOTABLE_ID, 'ak' => MAP_AK);
} else {
//这里是更新
$uri = '/geodata/v3/poi/update';
$querystring_arrays = array('id' => $id, 'title' => $title, 'latitude' => $latitude, 'longitude' => $longitude, 'coord_type' => 1, 'geotable_id' => GEOTABLE_ID, 'ak' => MAP_AK);
}
$sn = BDLbs::caculateAKSN($uri, $querystring_arrays, "POST");
$querystring_arrays['sn'] = $sn;
Yii::trace(CVarDumper::dumpAsString($querystring_arrays), 'create or update baidu poi post');
$ret = Yii::app()->curl->post(Yii::app()->params['baiduapi'] . $uri, $querystring_arrays);
$ret = json_decode($ret, true);
Yii::trace(CVarDumper::dumpAsString($ret), 'create or update baidu poi');
if ($ret['status'] == 0) {
return $ret['id'];
} else {
Yii::log(CVarDumper::dumpAsString($ret), 'error', 'create or update baidu poi ERROR');
return -1;
}
}
示例10: findTree
/**
* @param array $options options for tree searching. Valid options are:
* exclude: array list of children exclusions
* level: integer, recursion depth, default=-1
* Level -1 means searching for all children under root;
* Level 0 means searching for only the child DIRECTLY under the root;
* level N means searching for those children that are within N levels.
*/
public function findTree($options = array())
{
$exclude = array();
$level = -1;
extract($options);
$cache = $this->getCache();
$cacheKey = get_class($this->getOwner()) . '-' . $this->getOwner()->{$this->primaryKey} . '-' . $this->className . '-' . $this->primaryKey . '-' . $this->attributeName . '-' . CVarDumper::dumpAsString($this->attributes) . '-' . CVarDumper::dumpAsString($this->criteria) . '-' . CVarDumper::dumpAsString($exclude) . '-' . CVarDumper::dumpAsString($level);
$cacheKey = md5($cacheKey);
if (isset($cache) && ($data = $cache->get($cacheKey)) !== false) {
Yii::trace('Find tree from cache:' . $cacheKey, 'Xpress.extensions.web.behaviors');
return $data;
}
$event = new NestedEvent($this);
$event->params = array('exclude' => $exclude, 'level' => $level);
if ($this->hasEventHandler('onBeforeFindTree')) {
$this->onBeforeFindTree($event);
}
$tree = $this->findTreeRecursive($exclude, 0, NULL, $level);
$event->data =& $tree;
if ($this->hasEventHandler('onAfterFindTree')) {
$this->onAfterFindTree($event);
}
if (isset($cache)) {
$cache->set($cacheKey, $tree);
}
Yii::trace('Find tree from database', 'Xpress.extensions.web.behaviors');
return $tree;
}
示例11: bookAndReturnTripElementWorkflowItem
public function bookAndReturnTripElementWorkflowItem($index)
{
try {
$bookedTripElementWorkflow = array();
$item = $this->itemsOnePerGroup[$index];
if ($this->isDoubleRequest($item)) {
throw new CHttpException(400, 'Double request');
}
$tripElementWorkflow = $item->createTripElementWorkflow();
$tripElementWorkflow->bookItem();
$this->markItemGroupAsBooked($tripElementWorkflow->getItem());
$tripElementWorkflow->runWorkflowAndSetFinalStatus();
$this->saveWorkflowState($tripElementWorkflow->finalStatus);
$tripElementWorkflow->updateBookingId();
Yii::app()->shoppingCart->update($item, 1);
$bookedTripElementWorkflow[] = $tripElementWorkflow;
if ($this->areAllStatusesCorrect()) {
Yii::app()->user->setState('blockedToBook', null);
return $bookedTripElementWorkflow;
} else {
throw new CHttpException(500, 'At least one of workflow status at step 1 is incorrect:' . CVarDumper::dumpAsString($this->finalWorkflowStatuses));
}
} catch (Exception $e) {
throw new CHttpException(500, 'We can not book ' . $index . '-th item: ' . $e->getMessage());
}
}
示例12: e
function e($msg, $exit = true, $depth = 10)
{
CVarDumper::dump($msg, $depth, true);
if ($exit) {
exit;
}
}
示例13: actionReadTopic
public function actionReadTopic($id)
{
$thread = Thread::model()->getThreadInfoById($id);
$this->areaLarge = $thread['program_name'];
$this->areaSmall = $thread['semester_name'];
$reply = new Reply();
$complaint = new Complaint('postComplaint');
if (isset($_POST['Reply'])) {
$reply->attributes = $_POST['Reply'];
$reply->post_item_id = $id;
if ($reply->save()) {
Yii::app()->user->setFlash('success', Yii::t('forum', 'forum.view.reply.success'));
$reply->unsetAttributes();
} else {
Yii::app()->user->setFlash('error', Yii::t('forum', 'forum.view.reply.error'));
}
}
if (isset($_POST['Complaint'])) {
$complaint->attributes = $_POST['Complaint'];
if ($complaint->save()) {
if ($complaint->post_item_id == $id) {
Yii::app()->user->setFlash('success', Yii::t('forum', 'forum.view.complaint.success'));
} else {
Yii::app()->user->setFlash('success', Yii::t('forum', 'forum.view.complaint.success'));
}
$complaint->unsetAttributes();
} else {
Yii::app()->clientScript->registerScript('show_modal', "\$('#reportModal').modal('show');", CClientScript::POS_READY);
}
}
$dataProvider = Thread::model()->getPostsDataInThread($id);
Yii::log(CVarDumper::dumpAsString($dataProvider->getData()));
$this->render('application.modules.community.views.front.post.view', array('thread' => $thread, 'threadId' => $id, 'dataProvider' => $dataProvider, 'reply' => $reply, 'complaint' => $complaint));
}
示例14: actionUpdate
/**
* Updates a particular model.
* If update is successful, the browser will be redirected to the 'view' page.
* @param integer $id the ID of the model to be updated
*/
public function actionUpdate($id)
{
$model = new WorkshopForm('view', $id);
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
if (isset($_POST['WorkshopForm'])) {
$model->attributes = $_POST['WorkshopForm'];
$model->postItem->attributes = $_POST['PostItem'];
$model->workshop->attributes = $_POST['Workshop'];
$model->workshopFile = CUploadedFile::getInstance($model, 'workshopFile');
Yii::log(CVarDumper::dumpAsString($model->workshopFile));
if ($model->validate()) {
$fileUpload = $model->workshopFile;
if ($fileUpload !== null) {
$model->workshop->removeFile();
$model->workshop->workshop_file = $fileUpload;
$fileName = $fileUpload->name;
}
if ($model->save()) {
if ($model->workshop->workshop_file !== null) {
$userFilePath = FileHelper::getFilePath(Yii::getPathOfAlias('site.files') . '/workshops/' . $model->postItem->primaryKey . '/');
$model->workshopFile->saveAs($userFilePath . $fileName);
}
$this->redirect(array('view', 'id' => $model->workshop->post_item_id));
}
}
}
$this->render('update', array('model' => $model));
}
示例15: run
public function run()
{
$nav = $content = '';
$first = true;
$type = rtrim($this->type, 's');
foreach ($this->items as $id => $item) {
if (is_array($item['content'])) {
$id = "{$this->id}-{$id}";
$opts = $first ? array('class' => 'active') : array();
$opts['class'] = isset($opts['class']) ? $opts['class'] . ' dropdown' : 'dropdown';
$dropdown = array();
foreach ($item['content'] as $subId => $subTab) {
Yii::trace(CVarDumper::dumpAsString($subTab));
$subOpts = array();
$subOpts['id'] = "{$id}-{$subId}";
$subOpts['class'] = 'tab-pane';
$content .= CHtml::tag('div', $subOpts, $subTab['content']);
$dropdown[$subTab['title']] = '#' . $subOpts['id'];
}
Yii::trace(CVarDumper::dumpAsString($dropdown));
$nav .= CHtml::tag('li', $opts, BHtml::dropdownToggle($item['title']) . BHtml::dropdownMenu($dropdown, array('linkOptions' => array('data-toggle' => 'tab'))));
} else {
$id = "{$this->id}-{$id}";
$opts = $first ? array('class' => 'active') : array();
$nav .= CHtml::tag('li', $opts, CHtml::link($item['title'], "#{$id}", array('data-toggle' => $type)));
$opts['id'] = $id;
$opts['class'] = isset($opts['class']) ? $opts['class'] . ' tab-pane' : 'tab-pane';
$content .= CHtml::tag('div', $opts, $item['content']);
}
$first = false;
}
echo CHtml::tag('div', $this->htmlOptions, CHtml::tag('ul', $this->navOptions, $nav) . CHtml::tag('div', array('class' => 'tab-content'), $content));
BHtml::registerBootstrapJs();
}