当前位置: 首页>>代码示例>>PHP>>正文


PHP VarDumper::dumpAsString方法代码示例

本文整理汇总了PHP中yii\helpers\VarDumper::dumpAsString方法的典型用法代码示例。如果您正苦于以下问题:PHP VarDumper::dumpAsString方法的具体用法?PHP VarDumper::dumpAsString怎么用?PHP VarDumper::dumpAsString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在yii\helpers\VarDumper的用法示例。


在下文中一共展示了VarDumper::dumpAsString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: actionCompetition

 /**
  * Displays and/or update Score models for a competition.
  * @return mixed
  */
 public function actionCompetition($id)
 {
     $competition = $this->findCompetition($id);
     if (isset($_POST['ScorecardForCompetition'])) {
         $models = ScorecardForCompetition::find()->andWhere(['id' => array_keys($_POST['ScorecardForCompetition'])])->indexBy('id')->all();
         if (!ScorecardForCompetition::loadMultiple($models, Yii::$app->request->post()) || !ScorecardForCompetition::validateMultiple($models)) {
             $errors = [];
             foreach ($models as $model) {
                 $errors += $model->errors;
             }
             if (count($errors) > 0) {
                 Yii::$app->session->setFlash('danger', Yii::t('igolf', 'Error(s): {0}', [VarDumper::dumpAsString($errors, 4, true)]));
             }
         } else {
             foreach ($models as $model) {
                 $model->save();
             }
             Yii::$app->session->setFlash('success', Yii::t('igolf', 'Scores updated.'));
         }
     } else {
         //@todo do not loop on getScorecards twice...
         $scorecards = [];
         foreach ($competition->getRegistrations()->andWhere(['registration.status' => array_merge([Registration::STATUS_CONFIRMED], Registration::getPostCompetitionStatuses())])->each() as $registration) {
             $scorecards[] = $registration->getScorecard();
             // this will create a scorecard if none exists
         }
     }
     return $this->render('competition', ['competition' => $competition, 'dataProvider' => new ActiveDataProvider(['query' => $competition->getScorecards()])]);
 }
开发者ID:kleitz,项目名称:golfleague,代码行数:33,代码来源:ScorecardController.php

示例2: get

 public static function get($id)
 {
     $query = is_numeric($id) ? ['clientid' => $id] : ['email' => $id];
     $response = self::getWhmcs()->call('getclientsdetails', $query, false);
     \Yii::trace(VarDumper::dumpAsString($response), __METHOD__);
     return \Yii::createObject(self::className(), [$response]);
 }
开发者ID:muvo,项目名称:yii2-whmcs,代码行数:7,代码来源:Client.php

示例3: info

 public static function info($message, $category = 'application')
 {
     if (!is_string($message)) {
         $message = VarDumper::dumpAsString($message);
     }
     Yii::info($message, $category);
 }
开发者ID:ivan-chkv,项目名称:yii2-kladovka,代码行数:7,代码来源:Log.php

示例4: sendErrorMessageToDevelopers

 /**
  * @param $exception \Exception
  */
 private function sendErrorMessageToDevelopers($exception)
 {
     $errors = $this->convertExceptionToArray($exception);
     $userIdentity = Yii::$app->getUser()->getIdentity();
     if (!is_null($userIdentity)) {
         $sender = [$userIdentity->getEmail() => $userIdentity->getFullname()];
     } else {
         $sender = ['noreply@' . Yii::$app->getRequest()->getServerName() => 'Web User'];
     }
     $status = S::get($errors, 'status');
     $status = is_null($status) ? S::get($errors, 'code') : $status;
     $subject = '#' . $status . ' ' . S::get($errors, 'name');
     $content = '<h3>' . Yii::$app->name . ' alkalmazásban hiba történt!</h3>';
     $absoluteUrl = Yii::$app->getRequest()->absoluteUrl;
     $content .= '<p><b>URL:</b> ' . $absoluteUrl . '</p>';
     $referrer = Yii::$app->getRequest()->getReferrer();
     $content .= '<p><b>Előző/Hivatkozó oldal:</b> ' . ($referrer !== null ? $referrer : 'direkt link') . '</p>';
     $content .= '<p><b>Fájl:</b> <code>' . $exception->getFile() . '</code></p>';
     $content .= '<p><b>Sor:</b> <code>' . $exception->getLine() . '</code></p>';
     $content .= '<p><b>Hibaüzenet</b> <code>' . $exception->getMessage() . '</code></p>';
     $content .= '<p><b>Részetesen:</b> ' . \yii\helpers\VarDumper::dumpAsString($errors, 10, true) . '</p>';
     $content .= '<p><b>GET paraméterek</b> ' . VarDumper::dumpAsString(Yii::$app->request->get(), 10, true) . '</p>';
     $content .= '<p><b>POST paraméterek</b> ' . VarDumper::dumpAsString(Yii::$app->request->post(), 10, true) . '</p>';
     foreach ($this->emails as $recipient) {
         Mailer::sendMail($recipient, $subject, $content, $sender);
     }
 }
开发者ID:albertborsos,项目名称:yii2-lib,代码行数:30,代码来源:ErrorHandler.php

示例5: log

 /**
  * @inheritdoc
  */
 public function log($level, $message, array $context = [])
 {
     if (count($context)) {
         $message .= PHP_EOL . VarDumper::dumpAsString($context);
     }
     Yii::getLogger()->log($message, $this->levelMap[$level], $this->category);
 }
开发者ID:ivan-chkv,项目名称:yii2-boost,代码行数:10,代码来源:PsrLogger.php

示例6: tryInsert

 /**
  * @param bool $runValidation
  * @param array|null $attributeNames
  * @return true
  */
 public function tryInsert($runValidation = true, $attributeNames = null)
 {
     if (false === $this->insert($runValidation, $attributeNames)) {
         throw new \LogicException("Saving error: " . VarDumper::dumpAsString($this->getErrors()));
     }
     return true;
 }
开发者ID:yarcode,项目名称:yii2-base,代码行数:12,代码来源:ActiveRecord.php

示例7: _addAdmin

 /**
  * Adds Administrator account.
  * @return string result message.
  */
 protected function _addAdmin()
 {
     try {
         $podium = PodiumModule::getInstance();
         if ($podium->userComponent == PodiumModule::USER_INHERIT) {
             if (!empty($podium->adminId)) {
                 $this->authManager->assign($this->authManager->getRole('podiumAdmin'), $podium->adminId);
                 return $this->outputSuccess(Yii::t('podium/flash', Messages::ADMINISTRATOR_PRIVILEGES_SET, ['id' => $podium->adminId]));
             } else {
                 return $this->outputWarning(Yii::t('podium/flash', Messages::NO_ADMINISTRATOR_PRIVILEGES_SET));
             }
         } else {
             $admin = new User();
             $admin->setScenario('installation');
             $admin->username = self::DEFAULT_USERNAME;
             $admin->email = self::DEFAULT_USER_EMAIL;
             $admin->status = User::STATUS_ACTIVE;
             $admin->role = User::ROLE_ADMIN;
             $admin->generateAuthKey();
             $admin->setPassword(self::DEFAULT_USERNAME);
             if ($admin->save()) {
                 $this->authManager->assign($this->authManager->getRole('podiumAdmin'), $admin->getId());
                 return $this->outputSuccess(Yii::t('podium/flash', Messages::ADMINISTRATOR_ACCOUNT_CREATED) . ' ' . Html::tag('strong', Yii::t('podium/flash', 'Login') . ':') . ' ' . Html::tag('kbd', self::DEFAULT_USERNAME) . ' ' . Html::tag('strong', Yii::t('podium/flash', 'Password') . ':') . ' ' . Html::tag('kbd', self::DEFAULT_USERNAME));
             } else {
                 $this->setError(true);
                 return $this->outputDanger(Yii::t('podium/flash', Messages::ACCOUNT_CREATING_ERROR) . ': ' . Html::tag('pre', VarDumper::dumpAsString($admin->getErrors())));
             }
         }
     } catch (Exception $e) {
         Yii::error([$e->getName(), $e->getMessage()], __METHOD__);
         $this->setError(true);
         return $this->outputDanger(Yii::t('podium/flash', Messages::ACCOUNT_CREATING_ERROR) . ': ' . Html::tag('pre', $e->getMessage()));
     }
 }
开发者ID:keltstr,项目名称:yii2-podium,代码行数:38,代码来源:Installation.php

示例8: actionSend

 /**
  * Делает рассылку писем из списка рассылки
  */
 public function actionSend()
 {
     $time = microtime(true);
     $list = SubscribeMailItem::query()->limit(10)->orderBy(['date_insert' => SORT_DESC])->all();
     if (count($list) > 0) {
         //            \Yii::info('Всего писем для рассылки: ' . count($list), 'gs\\app\\commands\\SubscribeController::actionSend');
         //            \Yii::info('Список писем: ' . VarDumper::dumpAsString(ArrayHelper::getColumn($list, 'mail')), 'gs\\app\\commands\\SubscribeController::actionSend');
         foreach ($list as $mailItem) {
             $mail = \Yii::$app->mailer->compose()->setFrom(\Yii::$app->params['mailer']['from'])->setTo($mailItem['mail'])->setSubject($mailItem['subject'])->setHtmlBody($mailItem['html']);
             if (isset($mailItem['text'])) {
                 if ($mailItem['text'] != '') {
                     $mail->setTextBody($mailItem['text']);
                 }
             }
             $result = $mail->send();
             if ($result == false) {
                 \Yii::info('Не удалось доствить: ' . VarDumper::dumpAsString($mailItem), 'gs\\app\\commands\\SubscribeController::actionSend');
             }
         }
         //            \Yii::info('Список писем для удаления: ' . VarDumper::dumpAsString(ArrayHelper::getColumn($list, 'id')), 'gs\\app\\commands\\SubscribeController::actionSend');
         SubscribeMailItem::deleteByCondition(['in', 'id', ArrayHelper::getColumn($list, 'id')]);
         //            \Yii::info('Осталось после рассылки: ' . SubscribeMailItem::query()->count(), 'gs\\app\\commands\\SubscribeController::actionSend');
         $time = microtime(true) - $time;
         //            \Yii::info('Затраченное время на расылку: ' . $time, 'gs\\app\\commands\\SubscribeController::actionSend');
     }
     \Yii::$app->end();
 }
开发者ID:Makeyko,项目名称:galaxysss,代码行数:30,代码来源:SubscribeController.php

示例9: run

 /**
  * @param ActionData $actionData
  *
  * @return void
  */
 public function run(&$actionData)
 {
     $monsterContentConfigs = [];
     foreach ($this->entities as $definition) {
         if (!isset($definition['entity'], $definition['attributes'])) {
             continue;
         }
         $entity = $definition['entity'];
         $definition['attributes'] = (array) $definition['attributes'];
         /** @var yii\base\Model $model */
         $models = ArrayHelper::getValue($actionData->entities, $entity, []);
         $model = is_object($models) ? $models : reset($models);
         if ($model === null) {
             Yii::info("Entities list: " . yii\helpers\VarDumper::dumpAsString($actionData->entities));
             Yii::info((array) ArrayHelper::getValue($actionData->entities, $entity, []));
             Yii::info("Searching for " . $entity);
             throw new \RuntimeException("Model is empty");
         }
         foreach ($definition['attributes'] as $index => $attribute) {
             $materials = $model->{$attribute};
             if (is_array($materials) || is_object($materials)) {
                 $monsterContentConfigs[] = ['materials' => $materials, 'uniqueContentId' => $model::className() . ":{$index}:" . $model->id];
             } else {
                 Yii::warning("Model attribute {$attribute} of entity {$entity} is not array or object");
             }
         }
     }
     $content = '';
     foreach ($monsterContentConfigs as $index => $config) {
         $content .= "<!-- MonsterContent::{$index} -->\n" . MonsterContent::widget($config) . "\n\n";
     }
     $actionData->content = $content;
 }
开发者ID:DevGroup-ru,项目名称:dotplant-monster,代码行数:38,代码来源:MaterializedAttributes.php

示例10: call

 public function call($method, $params = array(), $tag = null)
 {
     $url = sprintf('%s/%s', $this->baseUrl, $this->callUri);
     $postFields = array('username' => $this->username, 'password' => md5($this->password), 'action' => $method, 'responsetype' => 'json');
     if (!empty($this->accesskey)) {
         $postFields['accesskey'] = $this->accesskey;
     }
     if (!empty($params)) {
         $postFields = array_merge($params, $postFields);
     }
     \Yii::trace($url, __METHOD__);
     \Yii::trace(VarDumper::dumpAsString($postFields), __METHOD__);
     $key = null;
     if (\Yii::$app->has('cache') && $tag !== false) {
         \Yii::$app->cache->keyPrefix = 'whmcs_';
         $key = md5(implode(':', [$url, serialize($postFields), $tag]));
         if ($response = \Yii::$app->cache->get($key)) {
             return $response;
         }
     }
     $response = null;
     if (!($response = $this->curl->setOption(CURLOPT_POSTFIELDS, $postFields)->post($url))) {
         throw new InvalidCallException();
     }
     $response = Json::decode($response, false);
     if ($response->result === 'success' && $key) {
         \Yii::$app->cache->set($key, $response, 3600, new TagDependency(['tags' => [$method, $tag]]));
     }
     if ($response->result !== 'success') {
         throw new InvalidCallException($response->message);
     }
     unset($response->result);
     return $response;
 }
开发者ID:muvo,项目名称:yii2-whmcs,代码行数:34,代码来源:Connector.php

示例11: actionCandels

 /**
  * Импортирует курсы сразу для всех индексов
  */
 public function actionCandels()
 {
     $rows = Stock::query()->all();
     foreach ($rows as $row) {
         $stock_id = $row['id'];
         $this->log('Попытка получить данные для: ' . $row['name']);
         $importer = ['params' => ['market' => $row['finam_market'], 'em' => $row['finam_em'], 'code' => $row['finam_code']]];
         $class = new \app\service\DadaImporter\Finam($importer);
         $date = new \DateTime();
         $date->sub(new \DateInterval('P7D'));
         $data = $class->importCandels($date->format('Y-m-d'));
         // стратегия: Если данные есть то, они не трогаются
         $dateArray = ArrayHelper::getColumn($data, 'date');
         sort($dateArray);
         $rows2 = StockKurs::query(['between', 'date', $dateArray[0], $dateArray[count($dateArray) - 1]])->andWhere(['stock_id' => $stock_id])->all();
         $dateArrayRows = ArrayHelper::getColumn($rows2, 'date');
         $new = [];
         foreach ($data as $row) {
             if (!in_array($row['date'], $dateArrayRows)) {
                 $new[] = [$stock_id, $row['date'], $row['open'], $row['high'], $row['low'], $row['close'], $row['volume'], $row['close']];
             }
         }
         if (count($new) > 0) {
             \Yii::info('Импортированы данные: ' . VarDumper::dumpAsString($new), 'cap\\importer\\index');
             $this->log('Импортированы данные: ' . VarDumper::dumpAsString($new));
             StockKurs::batchInsert(['stock_id', 'date', 'open', 'high', 'low', 'close', 'volume', 'kurs'], $new);
         } else {
             $this->log('Нечего импортировать');
         }
     }
 }
开发者ID:CAPITALOV,项目名称:capitalov,代码行数:34,代码来源:ImporterController.php

示例12: release

 public function release($dbConfig = false)
 {
     //		ob_flush();
     //		ob_clean();
     \Yii::trace('application release called.dbConfig=' . VarDumper::dumpAsString($dbConfig), __METHOD__);
     if ($dbConfig) {
         /**
          * 关闭非持久化的数据库连接
          */
         $keys = array_keys($dbConfig);
         if ($keys) {
             foreach ($keys as $item) {
                 $dbObject = \Yii::$app->get($item);
                 if ($dbObject instanceof \yii\db\Connection) {
                     if (!isset($dbObject->attributes[\PDO::ATTR_PERSISTENT])) {
                         if ($dbObject->getIsActive()) {
                             \Yii::trace('db ' . VarDumper::dumpAsString($dbObject) . 'close.', __METHOD__);
                             $dbObject->close();
                         }
                     }
                 }
             }
         }
     }
 }
开发者ID:highestgoodlikewater,项目名称:yii2-liuxy-extension,代码行数:25,代码来源:Application.php

示例13: saveFileToStorage

 /**
  * Saves file to a random folder
  * @param \stdClass $fileData, example:
  * object(stdClass)[82]
  *   public 'name' => string 'SampleVideo_1080x720_20mb (1).mp4' (length=33)
  *   public 'size' => int 21069678
  *   public 'type' => string 'video/mp4' (length=9)
  *   public 'extension' => string 'mp4' (length=3)
  *
  * @return int File record id
  * @author Alex Makhorin
  */
 public function saveFileToStorage($fileData)
 {
     $tmpFilePath = $this->tmpDirectory . $fileData->name;
     $randomDir = $this->generateRandomDirectory($fileData->name);
     $randomName = $this->generateRandomName();
     $newPath = $this->storageDirectory . $randomDir . '/' . $randomName . '.' . $fileData->extension;
     $this->createFolders($newPath);
     rename($tmpFilePath, $newPath);
     $url = $this->storageUrl . $randomDir . '/' . $randomName . '.' . $fileData->extension;
     if (strpos($fileData->type, 'video/') === 0) {
         $type = FileType::TYPE_VIDEO;
     } elseif (strpos($fileData->type, 'image/') === 0) {
         $type = FileType::TYPE_IMAGE;
     } else {
         is_file($newPath) && unlink($newPath);
         throw new HttpException(400, 'No data to handle');
     }
     $file = new File();
     $file->file_type = $type;
     $file->mime_type = $fileData->type;
     $file->url = $url;
     $isSaved = $file->save();
     if (!$isSaved) {
         throw new HttpException(500, 'DB error occured: ' . \yii\helpers\VarDumper::dumpAsString($file->getErrors()));
     }
     return $file->primaryKey;
 }
开发者ID:vfokov,项目名称:tims2,代码行数:39,代码来源:Media.php

示例14: bind

 /**
  * 绑定角色与权限的对应关系
  * @param $roleId   角色ID
  * @param $pids 权限ID列表
  * @param $loginUser \liuxy\admin\models\AdminUser
  */
 public static function bind($roleId, $pids, $loginUser)
 {
     self::deteteAll(['role_id' => $roleId]);
     if (!empty($pids)) {
         $pids = explode(',', $pids);
         $pids = array_unique($pids);
         foreach ($pids as $pid) {
             if (!empty($pid)) {
                 $item = new RolePermission();
                 $item->isNewRecord = true;
                 $item->role_id = $roleId;
                 $item->permission_id = $pid;
                 $item->insert_by = $loginUser->username;
                 $item->insert();
                 if ($item->hasErrors()) {
                     Yii::error(VarDumper::dumpAsString($item->getErrors()), __METHOD__);
                 }
                 unset($item);
             }
         }
         /**
          * 清理角色下所对应用户的权限
          */
         foreach (AdminUserRole::find()->where(['role_id' => $roleId])->all() as $userRole) {
             AdminUser::clearPermission($userRole['user_id']);
         }
     }
 }
开发者ID:highestgoodlikewater,项目名称:yii2-liuxy-admin,代码行数:34,代码来源:RolePermission.php

示例15: testApiKey

 public function testApiKey()
 {
     Yii::$app->params['google.api.key'] = 'TEST_API_KEY';
     GooglePlaceSearch::widget(['id' => 'test', 'name' => 'test-widget-name', 'country' => 'au', 'map' => ['selector' => '#map']]);
     $view = Yii::$app->getView();
     $expected = '//maps.googleapis.com/maps/api/js?libraries=places&key=TEST_API_KEY';
     $this->assertContains($expected, VarDumper::dumpAsString($view->assetBundles['webtoolsnz\\widgets\\GooglePlaceSearchAsset']->js));
 }
开发者ID:webtoolsnz,项目名称:yii2-widgets,代码行数:8,代码来源:GooglePlaceSearchTest.php


注:本文中的yii\helpers\VarDumper::dumpAsString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。