src/Awjudd/AssetProcessor/AssetProcessor.php
private function write($type, $contents, $directory = null)
    {
        // Will contain all of the files put together
        $file = '';

        // Derive the destination path
        $directory = $directory === null ? static::storageFolder() : ($directory . '/');
        $directory .= $type . '/';

        // Do we have one file or multiple?
        if(is_array($contents))
        {
            // Cycle through each of the files
            foreach($contents as $filename)
            {
                // Check if the file exists on it's own
                if(!file_exists($filename))
                {
                    $filename = $directory . $filename;    
                }
                
                // Keep appending the file's contents
                $file .= file_get_contents($filename);
            }
        }
        else
        {
            // Check if the file exists on it's own
            if(!file_exists($contents))
            {
                $contents = $directory . $contents;    
            }
            
            // Otherwise just read in the file
            $file .= file_get_contents($contents);
        }

        $filename = md5($file);

        // Make sure that the folder exists
        if(!file_exists($directory))
        {
            // It doesn't, so make it (allow us to write)
            mkdir($directory, 0777, true);
        }

        // Write the file to disk
        file_put_contents($directory . $filename, $file);

        // Return the file name
        return $filename;
    }
private function write($type, $contents, $directory = null)
    {
        // Will contain all of the files put together
        $file = '';

        // Derive the destination path
        $directory = $directory === null ? static::storageFolder() : ($directory . '/');
        $directory .= $type . '/';

        // Do we have one file or multiple?
        if(is_array($contents))
        {
            // Cycle through each of the files
            foreach($contents as $filename)
            {
                // Check if the file exists on it's own
                if(!file_exists($filename))
                {
                    $filename = $directory . $filename;    
                }
                
                // Keep appending the file's contents
                $file .= file_get_contents($filename);
            }
        }
        else
        {
            // Check if the file exists on it's own
            if(!file_exists($contents))
            {
                $contents = $directory . $contents;    
            }
            
            // Otherwise just read in the file
            $file .= file_get_contents($contents);
        }

        $filename = md5($file);

        // Make sure that the folder exists
        if(!file_exists($directory))
        {
            // It doesn't, so make it (allow us to write)
            mkdir($directory, 0777, true);
        }

        // Write the file to disk
        file_put_contents($directory . $filename, $file);

        // Return the file name
        return $filename;
    }
private function write ( $ type , $ contents , $ directory = null ) { // Will contain all of the files put together $ file = '' ; // Derive the destination path $ directory = $ directory === null ? static :: storageFolder ( ) : ( $ directory . '/' ) ; $ directory .= $ type . '/' ; // Do we have one file or multiple? if ( is_array ( $ contents ) ) { // Cycle through each of the files foreach ( $ contents as $ filename ) { // Check if the file exists on it's own if ( ! file_exists ( $ filename ) ) { $ filename = $ directory . $ filename ; } // Keep appending the file's contents $ file .= file_get_contents ( $ filename ) ; } } else { // Check if the file exists on it's own if ( ! file_exists ( $ contents ) ) { $ contents = $ directory . $ contents ; } // Otherwise just read in the file $ file .= file_get_contents ( $ contents ) ; } $ filename = md5 ( $ file ) ; // Make sure that the folder exists if ( ! file_exists ( $ directory ) ) { // It doesn't, so make it (allow us to write) mkdir ( $ directory , 0777 , true ) ; } // Write the file to disk file_put_contents ( $ directory . $ filename , $ file ) ; // Return the file name return $ filename ; }
Used internally in order to write all of the contents for the provided files
into a single file.

@param string $type The type of asset that we are making
@param mixed $contents An array of all of the files to combine OR a single file to write
@param string $directory The name of the directory to store the files in
@return string The new file name
Used internally in order to write all of the contents for the provided files into a single file .