{ if (!is_int($attribute)) { throw new InvalidArgumentException( "The $source array keys must be integers recognizable by NumberFormatter::setAttribute(). \"" . gettype($attribute) . '" provided instead.' ); } if (!is_int($value)) { if (is_string($value)) { throw new InvalidArgumentException( "The $source array values must be integers. Did you mean to use $alternative?" ); } throw new InvalidArgumentException( "The $source array values must be integers. \"" . gettype($value) . '" provided instead.' ); } $formatter->setAttribute($attribute, $value); }
foreach ($textOptions as $attribute => $value) { $this->setFormatterTextAttribute($formatter, $attribute, $value, '$textOptions', '$options'); } // set attributes foreach ($this->numberFormatterOptions as $attribute => $value) { $this->setFormatterIntAttribute($formatter, $attribute, $value, 'numberFormatterOptions', 'numberFormatterTextOptions'); } foreach ($options as $attribute => $value) { $this->setFormatterIntAttribute($formatter, $attribute, $value, '$options', '$textOptions'); } if ($decimals !== null) { $formatter->setAttribute(NumberFormatter::MAX_FRACTION_DIGITS, $decimals);
$currency = $currency ?: $this->currencyCode; // currency code must be set before fraction digits // https://www.php.net/manual/en/numberformatter.formatcurrency.php#114376 if ($currency && !isset($textOptions[NumberFormatter::CURRENCY_CODE])) { $textOptions[NumberFormatter::CURRENCY_CODE] = $currency; } $formatter = $this->createNumberFormatter(NumberFormatter::CURRENCY, null, $options, $textOptions); if ($currency === null) { $result = $formatter->format($normalizedValue); } else { $result = $formatter->formatCurrency($normalizedValue, $currency); } if ($result === false) {
$lowestPrice = $price; } } } if ($lowestPrice != 123456789) { $lowestPrice = Yii::$app->formatter->asCurrency($lowestPrice, 'UAH'); } else { $lowestPrice = '-'; } $cachedData = $lowestPrice; Yii::$app->cache->set('cars_lowestprice_'.$url_name, $cachedData);
if (!empty($rawText)) { while (stristr($rawText, '{%%PRICE_CALCULATED|')) { //replace with proper price preg_match('/\{%%PRICE_CALCULATED\|([a-zA-Z0-9-_]+)%%}/i', $rawText, $matches); if (!empty($matches[1])) { $lowestPrice = (static::$REL_MODEL)::getLowestPriceByCar($matches[1]); $rawText = str_replace($matches[0], $lowestPrice, $rawText); } else { $rawText = str_replace('{%%PRICE_CALCULATED|', '', $rawText); } } }
if (!empty($infoBlock->meta_description)) {$metaData['description'] = $infoBlock->meta_description;} if (!empty($infoBlock->meta_keywords)) {$metaData['image'] = $infoBlock->sourcesLink.$infoBlock->meta_keywords;} $metaData['canonical'] = $infoBlock->getUrl(true); } $metaData['title'] = $this->processVars($metaData['title']); $metaData['description'] = $this->processVars($metaData['description']); Yii::$app->params['meta'] = $metaData; return true; }
} } else { throw new NotFoundHttpException('The requested page does not exist.'); } } $this->setMetaData($carModel, $infoBlock, $externalResponse); return $this->render('view', [ 'car' => $car, 'carModel' => $carModel, 'infoBlockCategory' => $infoBlockCategorySelected, 'infoBlock' => $infoBlockSelected,
$args = $this->controller->bindActionParams($this, $params); Yii::debug('Running action: ' . get_class($this->controller) . '::' . $this->actionMethod . '()', __METHOD__); if (Yii::$app->requestedParams === null) { Yii::$app->requestedParams = $args; } return call_user_func_array([$this->controller, $this->actionMethod], $args); } }
} $result = null; if ($runAction && $this->beforeAction($action)) { // run the action $result = $action->runWithParams($params); $result = $this->afterAction($action, $result); // call afterAction on modules foreach ($modules as $module) { /* @var $module Module */
$parts = $this->createController($route); if (is_array($parts)) { /* @var $controller Controller */ list($controller, $actionID) = $parts; $oldController = Yii::$app->controller; Yii::$app->controller = $controller; $result = $controller->runAction($actionID, $params); if ($oldController !== null) { Yii::$app->controller = $oldController; } return $result; }
$params = $this->catchAll; unset($params[0]); } try { Yii::debug("Route requested: '$route'", __METHOD__); $this->requestedRoute = $route; $result = $this->runAction($route, $params); if ($result instanceof Response) { return $result; } $response = $this->getResponse(); if ($result !== null) {
{ try { $this->state = self::STATE_BEFORE_REQUEST; $this->trigger(self::EVENT_BEFORE_REQUEST); $this->state = self::STATE_HANDLING_REQUEST; $response = $this->handleRequest($this->getRequest()); $this->state = self::STATE_AFTER_REQUEST; $this->trigger(self::EVENT_AFTER_REQUEST); $this->state = self::STATE_SENDING_RESPONSE; $response->send();
require(__DIR__ . '/../../common/config/main.php'), require(__DIR__ . '/../../common/config/main-local.php'), require(__DIR__ . '/../config/main.php'), require(__DIR__ . '/../config/main-local.php') ); (new yii\web\Application($config))->run();
$_GET = [ 'url_name' => 'range-rover-velar', 'category_name' => 'models', 'block_name' => 'overview', ];