public function loadFile (Asset $asset, ?bool $mode) : string
    {
        $filePath = $this->getFilePath($asset);

        if (!\is_file($filePath))
        {
            throw new FileNotFoundException(sprintf(
                "Asset '%s' not found at '%s'.",
                $asset->getAssetPath(),
                $filePath
            ));
        }

        $fileContent = \file_get_contents($filePath);

        if (false === $fileContent)
        {
            throw new FileNotFoundException(sprintf(
                "Can't read asset file '%s' at '%s'.",
                $asset->getAssetPath(),
                $filePath
            ));
        }

        $fileType = $this->fileTypeRegistry->getFileType($asset);

        if (self::MODE_UNTOUCHED !== $mode)
        {
            // prepend file header in dev and process in prod
            $fileContent = (self::MODE_PROD === $mode)
                ? $fileType->processForProd($asset, $fileContent)
                : $fileType->processForDev($asset, $filePath, $fileContent);
        }

        return $fileContent;
    }
public function loadFile (Asset $asset, ?bool $mode) : string
    {
        $filePath = $this->getFilePath($asset);

        if (!\is_file($filePath))
        {
            throw new FileNotFoundException(sprintf(
                "Asset '%s' not found at '%s'.",
                $asset->getAssetPath(),
                $filePath
            ));
        }

        $fileContent = \file_get_contents($filePath);

        if (false === $fileContent)
        {
            throw new FileNotFoundException(sprintf(
                "Can't read asset file '%s' at '%s'.",
                $asset->getAssetPath(),
                $filePath
            ));
        }

        $fileType = $this->fileTypeRegistry->getFileType($asset);

        if (self::MODE_UNTOUCHED !== $mode)
        {
            // prepend file header in dev and process in prod
            $fileContent = (self::MODE_PROD === $mode)
                ? $fileType->processForProd($asset, $fileContent)
                : $fileType->processForDev($asset, $filePath, $fileContent);
        }

        return $fileContent;
    }
public function loadFile ( Asset $ asset , ? bool $ mode ) : string { $ filePath = $ this -> getFilePath ( $ asset ) ; if ( ! \ is_file ( $ filePath ) ) { throw new FileNotFoundException ( sprintf ( "Asset '%s' not found at '%s'." , $ asset -> getAssetPath ( ) , $ filePath ) ) ; } $ fileContent = \ file_get_contents ( $ filePath ) ; if ( false === $ fileContent ) { throw new FileNotFoundException ( sprintf ( "Can't read asset file '%s' at '%s'." , $ asset -> getAssetPath ( ) , $ filePath ) ) ; } $ fileType = $ this -> fileTypeRegistry -> getFileType ( $ asset ) ; if ( self :: MODE_UNTOUCHED !== $ mode ) { // prepend file header in dev and process in prod $ fileContent = ( self :: MODE_PROD === $ mode ) ? $ fileType -> processForProd ( $ asset , $ fileContent ) : $ fileType -> processForDev ( $ asset , $ filePath , $ fileContent ) ; } return $ fileContent ; }
Loads an asset's file content

@param Asset $asset
@param bool  $mode   one of the MODE_* constants

@return string
@throws AssetsException
@throws FileNotFoundException
Loads an asset s file content