yii\web\AssetManager::publishFile PHP Метод

publishFile() защищенный Метод

Publishes a file.
protected publishFile ( string $src ) : string[]
$src string the asset file to be published
Результат string[] the path and the URL that the asset is published as.
    protected function publishFile($src)
    {
        $dir = $this->hash($src);
        $fileName = basename($src);
        $dstDir = $this->basePath . DIRECTORY_SEPARATOR . $dir;
        $dstFile = $dstDir . DIRECTORY_SEPARATOR . $fileName;
        if (!is_dir($dstDir)) {
            FileHelper::createDirectory($dstDir, $this->dirMode, true);
        }
        if ($this->linkAssets) {
            if (!is_file($dstFile)) {
                symlink($src, $dstFile);
            }
        } elseif (@filemtime($dstFile) < @filemtime($src)) {
            copy($src, $dstFile);
            if ($this->fileMode !== null) {
                @chmod($dstFile, $this->fileMode);
            }
        }
        return [$dstFile, $this->baseUrl . "/{$dir}/{$fileName}"];
    }

Usage Example

Пример #1
0
 protected function publishFile($src)
 {
     throw new \yii\base\Exception('Not implemented!');
     //TODO: check custom behavior
     return parent::publishFile($src);
 }