Ejemplo n.º 1
0
 public function flushLog($level, $category)
 {
     $logs = explode(PHP_EOL, $this->getLog());
     foreach ($logs as $message) {
         P::getLogger()->log($message, $level, $category);
     }
     P::getLogger()->flush(true);
 }
Ejemplo n.º 2
0
 public function init()
 {
     parent::init();
     $this->tmpPath = P::getAlias($this->tmpPath);
     if (!is_dir($this->tmpPath)) {
         FileHelper::createDirectory($this->tmpPath, $this->tmpDirMode, true);
     }
 }
Ejemplo n.º 3
0
 /**
  * Displays available commands or the detailed information to the current command.
  * 
  * @throws Exception the exception throwed for unknown command or bad controller
  */
 public function help()
 {
     $result = P::$app->createController('help');
     /* @var $controller \yii\console\controllers\HelpController */
     $controller = $result !== false ? $result[0] : null;
     if ($controller !== null || !$controller instanceof Controller) {
         throw new Exception(P::t('platform', 'No help for this command.', ['command' => $this->owner->ansiFormat('help', Console::FG_YELLOW)]));
     }
     $controller->actionIndex($this->owner->id);
 }
Ejemplo n.º 4
0
 public function getValue()
 {
     if (!empty($_SERVER['argv'])) {
         $option = '--' . Application::OPTION_APPHOST . '=';
         foreach ($_SERVER['argv'] as $param) {
             if (strpos($param, $option) !== false) {
                 $host = substr($param, strlen($option));
                 return $host;
             }
         }
     }
     $this->stdout(P::t('platform', 'Missing required option: --{name}', ['name' => Application::OPTION_APPHOST]), Console::FG_RED);
     die("\n\n");
 }
Ejemplo n.º 5
0
 /**
  * Format timezone
  * @param type $timezone
  * @param type $default
  * @return string
  */
 public function formatTimezone($timezone, $default = 'UTC')
 {
     if ($timezone === null || !in_array($timezone, DateTimeZone::listIdentifiers())) {
         P::warning(sprintf('Formatted timezone \'%s\' is not supported, reset to default \'%s\'', $timezone, $default), __CLASS__);
         return $default;
     }
     return $timezone;
 }
Ejemplo n.º 6
0
 protected function resolveConfigFile($project, $prefix = '', $suffix = '')
 {
     if (!isset($project['multipath'])) {
         $pattern = implode('/', ['%s', 'p%ds%d', '%s']);
         $alias = sprintf($pattern, $prefix, $project['projectId'], $project['siteId'], $suffix);
     } else {
         $pattern = implode('/', ['%s', $project['multipath'], '%s']);
         $alias = sprintf($pattern, $prefix, $suffix);
     }
     $path = P::getAlias($alias);
     if (($realPath = realpath($path)) === false) {
         throw new \yii\base\InvalidParamException('File path is invalid or not exists [' . $path . '].');
     }
     return $realPath;
 }
Ejemplo n.º 7
0
<?php

use yii\platform\P;
return ['sourcePath' => P::getAlias('@yii'), 'messagePath' => __DIR__, 'languages' => ['ru-RU'], 'translator' => 'Yii::t', 'sort' => false, 'overwrite' => true, 'removeUnused' => false, 'only' => ['.php'], 'except' => ['.svn', '.git', '.gitignore', '.gitkeep', '.hgignore', '.hgkeep', '/messages']];
Ejemplo n.º 8
0
 public function onMissingTranslation($event)
 {
     P::warning(sprintf('Missing translation message "%s:%s:%s"', $event->category, $event->message, $event->language), get_class($event->sender));
 }