Ejemplo n.º 1
0
 public function applyTo($path)
 {
     return parent::applyTo($path);
     $pathMap = $this->pathMap;
     if (empty($pathMap)) {
         if (($basePath = $this->getBasePath()) === null) {
             throw new InvalidConfigException('The "basePath" property must be set.');
         }
         $pathMap = [Yii::$app->getBasePath() => [$basePath]];
     }
     $path = FileHelper::normalizePath($path);
     foreach ($pathMap as $from => $tos) {
         $from = FileHelper::normalizePath(Yii::getAlias($from)) . DIRECTORY_SEPARATOR;
         if (strpos($path, $from) === 0) {
             $n = strlen($from);
             foreach ((array) $tos as $to) {
                 $to = FileHelper::normalizePath(Yii::getAlias($to)) . DIRECTORY_SEPARATOR;
                 $file = $to . substr($path, $n);
                 if (is_file($file)) {
                     return $file;
                 }
             }
         }
     }
     return $path;
 }
Ejemplo n.º 2
0
 /**
  * Returns message file path for the specified language and category.
  * @param string $category The message category.
  * @param string $language The target language.
  * @return string The path to message file.
  */
 protected function getMessageFilePath($category, $language) : string
 {
     $path = preg_replace('/\\.php$/i', '.json', parent::getMessageFilePath($category, $language));
     return FileHelper::normalizePath($path);
 }