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)) {
                try { // fix #6226 symlinking multi threaded
                    symlink($src, $dstFile);
                } catch (\Exception $e) {
                    if (!is_file($dstFile)) {
                        throw $e;
                    }
                }
            }
        } elseif (@filemtime($dstFile) < @filemtime($src)) {
            copy($src, $dstFile);
            if ($this->fileMode !== null) {
                @chmod($dstFile, $this->fileMode);
            }
        }

        if ($this->appendTimestamp && ($timestamp = @filemtime($dstFile)) > 0) {
            $fileName = $fileName . "?v=$timestamp";
        }

        return [$dstFile, $this->baseUrl . "/$dir/$fileName"];
    }
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)) {
                try { // fix #6226 symlinking multi threaded
                    symlink($src, $dstFile);
                } catch (\Exception $e) {
                    if (!is_file($dstFile)) {
                        throw $e;
                    }
                }
            }
        } elseif (@filemtime($dstFile) < @filemtime($src)) {
            copy($src, $dstFile);
            if ($this->fileMode !== null) {
                @chmod($dstFile, $this->fileMode);
            }
        }

        if ($this->appendTimestamp && ($timestamp = @filemtime($dstFile)) > 0) {
            $fileName = $fileName . "?v=$timestamp";
        }

        return [$dstFile, $this->baseUrl . "/$dir/$fileName"];
    }
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 ) ) { try { // fix #6226 symlinking multi threaded symlink ( $ src , $ dstFile ) ; } catch ( \ Exception $ e ) { if ( ! is_file ( $ dstFile ) ) { throw $ e ; } } } } elseif ( @ filemtime ( $ dstFile ) < @ filemtime ( $ src ) ) { copy ( $ src , $ dstFile ) ; if ( $ this -> fileMode !== null ) { @ chmod ( $ dstFile , $ this -> fileMode ) ; } } if ( $ this -> appendTimestamp && ( $ timestamp = @ filemtime ( $ dstFile ) ) > 0 ) { $ fileName = $ fileName . "?v=$timestamp" ; } return [ $ dstFile , $ this -> baseUrl . "/$dir/$fileName" ] ; }
Publishes a file.
@param string $src the asset file to be published
@return string[] the path and the URL that the asset is published as.
@throws InvalidArgumentException if the asset to be published does not exist.
Publishes a file .