public function import (Asset $asset) : Asset
    {
        $fileContent = $this->fileLoader->loadFile($asset, FileLoader::MODE_PROD);
        $fileType = $this->fileTypeRegistry->getFileType($asset);

        $asset->setHash(
            \base64_encode(\hash("sha256", $fileContent, true)),
            $fileType->shouldIncludeHashInFileName()
        );

        $outputPath = "{$this->storagePath}/{$asset->getNamespace()}/{$asset->getDumpFilePath()}";

        // ensure that the target directory exists
        $this->filesystem->mkdir(dirname($outputPath));

        // copy file
        $this->filesystem->dumpFile($outputPath, $fileContent);

        if ($fileType->shouldBeGzipCompressed())
        {
            $this->compression->compressFile($outputPath);
        }

        return $asset;
    }
public function import (Asset $asset) : Asset
    {
        $fileContent = $this->fileLoader->loadFile($asset, FileLoader::MODE_PROD);
        $fileType = $this->fileTypeRegistry->getFileType($asset);

        $asset->setHash(
            \base64_encode(\hash("sha256", $fileContent, true)),
            $fileType->shouldIncludeHashInFileName()
        );

        $outputPath = "{$this->storagePath}/{$asset->getNamespace()}/{$asset->getDumpFilePath()}";

        // ensure that the target directory exists
        $this->filesystem->mkdir(dirname($outputPath));

        // copy file
        $this->filesystem->dumpFile($outputPath, $fileContent);

        if ($fileType->shouldBeGzipCompressed())
        {
            $this->compression->compressFile($outputPath);
        }

        return $asset;
    }
public function import ( Asset $ asset ) : Asset { $ fileContent = $ this -> fileLoader -> loadFile ( $ asset , FileLoader :: MODE_PROD ) ; $ fileType = $ this -> fileTypeRegistry -> getFileType ( $ asset ) ; $ asset -> setHash ( \ base64_encode ( \ hash ( "sha256" , $ fileContent , true ) ) , $ fileType -> shouldIncludeHashInFileName ( ) ) ; $ outputPath = "{$this->storagePath}/{$asset->getNamespace()}/{$asset->getDumpFilePath()}" ; // ensure that the target directory exists $ this -> filesystem -> mkdir ( dirname ( $ outputPath ) ) ; // copy file $ this -> filesystem -> dumpFile ( $ outputPath , $ fileContent ) ; if ( $ fileType -> shouldBeGzipCompressed ( ) ) { $ this -> compression -> compressFile ( $ outputPath ) ; } return $ asset ; }
Imports the given asset

@param string $assetPath
@return Asset
@throws AssetsException
Imports the given asset