applyTo() публичный Метод

If there is no corresponding themed file, the original file will be returned.
public applyTo ( string $path ) : string
$path string the file to be themed
Результат string the themed file, or the original file if the themed version is not available.
Пример #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;
 }
Пример #2
0
 /**
  * @inheritDoc
  */
 public function applyTo($path)
 {
     $ext = substr(strrchr($path, '.'), 1);
     if ($ext !== Yii::$app->getView()->defaultExtension) {
         $path = str_replace('.' . $ext, '.' . Yii::$app->getView()->defaultExtension, $path);
     }
     return parent::applyTo($path);
 }
 /**
  * @inheritdoc
  */
 public function applyTo($path)
 {
     $autoPath = $this->autoFindModuleView($path);
     if ($autoPath !== null && file_exists($autoPath)) {
         return $autoPath;
     }
     // Web Resource e.g. image
     if (substr($path, 0, 5) === '@web/') {
         $themedFile = str_replace('@web', $this->getBasePath(), $path);
         if (file_exists($themedFile)) {
             return str_replace('@web', $this->getBaseUrl(), $path);
         } else {
             return $path;
         }
     }
     return parent::applyTo($path);
 }