本文整理汇总了PHP中Yii::info方法的典型用法代码示例。如果您正苦于以下问题:PHP Yii::info方法的具体用法?PHP Yii::info怎么用?PHP Yii::info使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Yii
的用法示例。
在下文中一共展示了Yii::info方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: init
public function init()
{
parent::init();
//Get cart items and calculate total value
//Cookie cart array type : ['product_id' => 'quantity', ...]
$cart_info = \Yii::$app->request->cookies->getValue('cart');
if ($cart_info !== null) {
$products = unserialize($cart_info);
if (is_array($products)) {
$product_ids = array_keys($products);
$product_models = ProductModel::getProducts($product_ids);
//find()->where(['id'=>$product_ids])->all();
foreach ($product_models as $product_model) {
$this->value += $product_model->price * $products[$product_model->id];
$this->items += $products[$product_model->id];
\Yii::info('Quantity of ' . $product_model->id . ' (' . $product_model->price . ') - ' . $products[$product_model->id]);
}
}
}
if ($this->value > 0) {
$this->message = "\$('.cart').addClass('active'); \$('.cart').append(\"<span class='cart-value'> ({$this->value} ₴ - {$this->items} items)</span>\");";
} else {
$this->message = "";
}
}
示例2: 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('Нечего импортировать');
}
}
}
示例3: 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;
}
示例4: save
/**
* @inheritdoc
*/
public function save($runValidation = true, $attributeNames = null)
{
if ($runValidation && !$this->validate($attributeNames)) {
\Yii::info('Model not save due to validation error.', __METHOD__);
return false;
}
$db = static::getDb();
if ($this->isTransactional(self::OP_ALL)) {
$transaction = $db->beginTransaction();
try {
$result = $this->saveInternal();
if ($result === false) {
$transaction->rollBack();
} else {
$transaction->commit();
}
} catch (\Exception $e) {
$transaction->rollBack();
throw $e;
}
} else {
$result = $this->saveInternal();
}
return $result;
}
示例5: DownloadReportWithAwql
public static function DownloadReportWithAwql($reportQuery, $path = NULL, \AdWordsUser $user, $reportFormat, array $options = NULL)
{
self::init();
$lastIteration = 0;
do {
try {
$throwException = true;
\ReportUtils::DownloadReportWithAwql($reportQuery, $path, $user, $reportFormat, $options);
} catch (\Exception $e) {
//if errror 5xx or 0 or 8, waiting and trying else
/* These exceptions are thrown with a random order. I can not keep track of them and support google says nothing.
* 5xx - error on google server.
* 0 - couldn't connect to host
* 8 - this exception: Undefined property: stdClass::$ApiError
*
* */
if ($e->getCode() >= 500 && $e->getCode() < 600 || $e->getCode() == 0 || $e->getCode() == 8) {
$lastIteration++;
if ($lastIteration < ReportUtils::ATTEMPS) {
$throwException = false;
\Yii::info($reportQuery, self::CATEGORY);
sleep(mt_rand(15, 45));
}
}
if ($throwException) {
$message = "Error with download report. Query:{$reportQuery} Error:{$e->getMessage()} CodeError:{$e->getCode()}";
throw new \yii\console\Exception($message);
}
}
} while ($throwException === false);
return true;
}
示例6: add
/**
* Добавляет записи для рассылки в таблицу рассылки
*
* @param SiteContentInterface | \app\models\SubscribeItem $item тема письма
*/
public static function add($item)
{
if ($item instanceof SiteContentInterface) {
$subscribeItem = $item->getMailContent();
} else {
$subscribeItem = $item;
}
switch ($subscribeItem->type) {
case self::TYPE_NEWS:
$where = ['subscribe_is_news' => 1];
break;
case self::TYPE_SITE_UPDATE:
$where = ['subscribe_is_site_update' => 1];
break;
case self::TYPE_MANUAL:
$where = ['subscribe_is_tesla' => 1];
// $where = ['subscribe_is_test' => 1];
break;
}
$emailList = User::query($where)->select('email')->andWhere(['not', ['email' => null]])->andWhere(['not', ['email' => '']])->andWhere(['is_active' => 1])->column();
// VarDumper::dump(count($emailList),3,false);exit;
$rows = [];
foreach ($emailList as $email) {
$urlUnSubscribe = Url::to(['subscribe/unsubscribe', 'mail' => $email, 'type' => $subscribeItem->type, 'hash' => self::hashGenerate($email, $subscribeItem->type)], true);
SubscribeMailItem::insert(['text' => str_replace('{linkUnsubscribe}', $urlUnSubscribe, $subscribeItem->text), 'html' => str_replace('{linkUnsubscribe}', $urlUnSubscribe, $subscribeItem->html), 'subject' => $subscribeItem->subject, 'mail' => $email, 'date_insert' => time()]);
$rows[] = $email;
}
\Yii::info($rows, 'tg\\subscribe');
}
示例7: handleMissingTranslation
public static function handleMissingTranslation(MissingTranslationEvent $event)
{
\Yii::info("@MISSING: {$event->category}.{$event->message} FOR LANGUAGE {$event->language} @");
if (!$event->category == 'app') {
$event->translatedMessage = \Yii::t('app', $event->message);
}
}
示例8: add
/**
* Добавляет записи для рассылки в таблицу рассылки
*
* @param SiteContentInterface | \app\models\SubscribeItem $item тема письма
*/
public static function add($item)
{
if ($item instanceof SiteContentInterface) {
$subscribeItem = $item->getMailContent();
} else {
$subscribeItem = $item;
}
switch ($subscribeItem->type) {
case self::TYPE_NEWS:
$where = ['subscribe_is_news' => 1];
break;
case self::TYPE_SITE_UPDATE:
$where = ['subscribe_is_site_update' => 1];
break;
case self::TYPE_MANUAL:
$where = ['subscribe_is_manual' => 1];
break;
}
$emailList = User::query($where)->select('email')->andWhere(['not', ['email' => null]])->andWhere(['is_active' => 1, 'is_confirm' => 1])->column();
$rows = [];
foreach ($emailList as $email) {
$urlUnSubscribe = Url::to(['subscribe/unsubscribe', 'mail' => $email, 'type' => $subscribeItem->type, 'hash' => self::hashGenerate($email, $subscribeItem->type)], true);
$rows[] = [str_replace('{linkUnsubscribe}', $urlUnSubscribe, $subscribeItem->text), str_replace('{linkUnsubscribe}', $urlUnSubscribe, $subscribeItem->html), $subscribeItem->subject, $email, time()];
}
\Yii::info(ArrayHelper::getColumn($rows, 3), 'gs\\subscribe');
if (count($rows) > 0) {
SubscribeMailItem::batchInsert(['text', 'html', 'subject', 'mail', 'date_insert'], $rows);
}
}
示例9: execute
public function execute($command, callable $next)
{
\Yii::info('middleware test 1 ok');
$result = $next($command);
\Yii::info('middleware test 2 ok');
return $result;
}
示例10: connect
public function connect(\Closure $callback, array $options = [])
{
$options = array_merge(['logging' => $this->logging, 'loggingOutput' => $this->loggingOutput, 'connectionTimeout' => null, 'connectionOptions' => []], $options);
if (!$options['logging']) {
Logger::set(new NullLogger());
}
if (!$options['loggingOutput']) {
ob_start();
}
$connection = $this->createConnection($options['connectionOptions']);
$connection->once('open', function (ClientSession $session) use($connection, $callback) {
call_user_func_array($callback, [$connection, $session]);
});
if ($options['connectionTimeout'] !== null) {
$loop = $connection->getClient()->getLoop();
$timer = $loop->addTimer($options['connectionTimeout'], function () use($loop) {
$loop->stop();
});
$connection->once('close', function () use($timer) {
$timer->cancel();
\Yii::warning('WAMP connection closed by timeout.');
});
}
$connection->open();
if ($options['logging']) {
\Yii::info(ob_get_contents());
}
if (!$options['loggingOutput']) {
ob_clean();
}
}
示例11: apply
/**
* @inheritdoc
*/
public function apply($model)
{
if ($this->isDue() && in_array($model->ClassID, [6, 12])) {
$userID = $model->contractor->id;
\Yii::info('Проверка и применение акции "' . self::$name . '"' . "({$this->getModel()->id})" . ' для пользователя ' . Html::a($userID, ['/user/admin/update', 'id' => $userID]), 'info');
$settings = $this->getModel()->parseSettings();
if (empty($settings['attributes'])) {
return false;
}
ArrayHelper::multisort($settings['attributes'], 'payment', SORT_DESC);
$account = $model->contractor->account;
foreach ($settings['attributes'] as $attributes) {
$discount = $this->getModel()->getDiscount();
$discount->setAttributes($attributes);
if ($model->CashSum >= $discount->payment) {
\Yii::info('Применение акции с атрибутами: ' . Json::encode($attributes), 'info');
$account->BonusGames = $account->BonusGames + $discount->bonusGamesCount;
if ($account->save(false, ['BonusGames'])) {
$finance = new FinanceRecord();
$finance->CashSum = 0;
$finance->ClassID = 21;
//Начисление бонусов
$finance->ContractorID = $model->ContractorID;
$finance->Comment = $this->getDescription();
$finance->save();
return true;
}
}
}
} else {
// var_export(in_array($model->ClassID, [6, 12]));
}
return false;
}
示例12: actionNotify
public function actionNotify()
{
\Yii::info("POST: " . Json::encode(\Yii::$app->request->post()), self::className());
try {
if (!\Yii::$app->request->post('OrderId')) {
throw new Exception('Некорректны запрос от банка.');
}
/**
* @var $shopOrder ShopOrder
*/
if (!($shopOrder = ShopOrder::findOne(\Yii::$app->request->post('OrderId')))) {
throw new Exception('Заказ не найден в базе.');
}
if ($shopOrder->id != \Yii::$app->request->post('OrderId')) {
throw new Exception('Не совпадает номер заказа.');
}
if ($shopOrder->money->getAmount() != \Yii::$app->request->post('Amount')) {
throw new Exception('Не совпадает сумма заказа.');
}
if (\Yii::$app->request->post('Status') == "CONFIRMED") {
\Yii::info("Успешный платеж", self::className());
$shopOrder->processNotePayment();
}
} catch (\Exception $e) {
\Yii::error($e->getMessage(), self::className());
}
$this->layout = false;
return "OK";
}
示例13: discoverMaster
/**
* Facade function for interraction with sentinel.
*
* Connects to sentinels (iterrates them if ones fail) and asks for master server address.
*
* @return array [host,port] address of redis master server or throws exception.
**/
function discoverMaster($sentinels, $masterName)
{
foreach ($sentinels as $sentinel) {
if (is_scalar($sentinel)) {
$sentinel = ['hostname' => $sentinel];
}
$connection = new SentinelConnection();
$connection->hostname = isset($sentinel['hostname']) ? $sentinel['hostname'] : null;
$connection->masterName = $masterName;
if (isset($sentinel['port'])) {
$connection->port = $sentinel['port'];
}
$connection->connectionTimeout = isset($sentinel['connectionTimeout']) ? $sentinel['connectionTimeout'] : null;
$connection->unixSocket = isset($sentinel['unixSocket']) ? $sentinel['unixSocket'] : null;
$r = $connection->getMaster();
if (isset($sentinel['hostname'])) {
$connectionName = "{$connection->hostname}:{$connection->port}";
} else {
$connectionName = $connection->unixSocket;
}
if ($r) {
\Yii::info("Sentinel @{$connectionName} gave master addr: {$r[0]}:{$r[1]}", __METHOD__);
return $r;
} else {
\Yii::info("Did not get any master from sentinel @{$connectionName}", __METHOD__);
}
}
throw new \Exception("Master could not be discovered");
}
示例14: handleMissingTranslation
public static function handleMissingTranslation(MissingTranslationEvent $event)
{
\Yii::info("@MISSING: {$event->category}.{$event->message} FOR LANGUAGE {$event->language} @", self::className());
if ($event->category != 'skeeks/cms') {
$event->translatedMessage = \Yii::t('skeeks/cms', $event->message);
}
}
示例15: setRequestMessage
public function setRequestMessage($message)
{
\Yii::info("Message: " . $message, "RPC");
$this->_requestMessage = $message;
$this->_data = json_decode($message, true);
\Yii::info("Decode message: " . print_r($this->_data, 1), "RPC");
}