public function prepareAssets($sourceAssetsDirectory, $webAssetsDirectoryBase, $webAssetsTemplate, $webAssetsKey)
    {
        // Compute the absolute path of the output directory
        $to_directory = $this->getDestinationDirectory($webAssetsDirectoryBase, $webAssetsTemplate, $webAssetsKey);

        // Get a path to the stamp file
        $stamp_file_path = $to_directory . DS . '.source-stamp';

        // Get the last stamp of source assets directory
        $prev_stamp = @file_get_contents($stamp_file_path);

        // Get the current stamp of the source directory
        $curr_stamp = $this->getStamp($sourceAssetsDirectory);

        if ($prev_stamp !== $curr_stamp) {
            $fs = new Filesystem();

            $tmp_dir = "$to_directory.tmp";

            $fs->remove($tmp_dir);

            // Copy the whole source dir in a temp directory
            $this->copyAssets($fs, $sourceAssetsDirectory, $tmp_dir);

            // Remove existing directory
            if ($fs->exists($to_directory)) {
                $fs->remove($to_directory);
            }

            // Put in place the new directory
            $fs->rename($tmp_dir, $to_directory);

            if (false === @file_put_contents($stamp_file_path, $curr_stamp)) {
                throw new \RuntimeException(
                    "Failed to create asset stamp file $stamp_file_path. Please check that your web server has the proper access rights to do that."
                );
            }
        }
    }
public function prepareAssets($sourceAssetsDirectory, $webAssetsDirectoryBase, $webAssetsTemplate, $webAssetsKey)
    {
        // Compute the absolute path of the output directory
        $to_directory = $this->getDestinationDirectory($webAssetsDirectoryBase, $webAssetsTemplate, $webAssetsKey);

        // Get a path to the stamp file
        $stamp_file_path = $to_directory . DS . '.source-stamp';

        // Get the last stamp of source assets directory
        $prev_stamp = @file_get_contents($stamp_file_path);

        // Get the current stamp of the source directory
        $curr_stamp = $this->getStamp($sourceAssetsDirectory);

        if ($prev_stamp !== $curr_stamp) {
            $fs = new Filesystem();

            $tmp_dir = "$to_directory.tmp";

            $fs->remove($tmp_dir);

            // Copy the whole source dir in a temp directory
            $this->copyAssets($fs, $sourceAssetsDirectory, $tmp_dir);

            // Remove existing directory
            if ($fs->exists($to_directory)) {
                $fs->remove($to_directory);
            }

            // Put in place the new directory
            $fs->rename($tmp_dir, $to_directory);

            if (false === @file_put_contents($stamp_file_path, $curr_stamp)) {
                throw new \RuntimeException(
                    "Failed to create asset stamp file $stamp_file_path. Please check that your web server has the proper access rights to do that."
                );
            }
        }
    }
public function prepareAssets ( $ sourceAssetsDirectory , $ webAssetsDirectoryBase , $ webAssetsTemplate , $ webAssetsKey ) { // Compute the absolute path of the output directory $ to_directory = $ this -> getDestinationDirectory ( $ webAssetsDirectoryBase , $ webAssetsTemplate , $ webAssetsKey ) ; // Get a path to the stamp file $ stamp_file_path = $ to_directory . DS . '.source-stamp' ; // Get the last stamp of source assets directory $ prev_stamp = @ file_get_contents ( $ stamp_file_path ) ; // Get the current stamp of the source directory $ curr_stamp = $ this -> getStamp ( $ sourceAssetsDirectory ) ; if ( $ prev_stamp !== $ curr_stamp ) { $ fs = new Filesystem ( ) ; $ tmp_dir = "$to_directory.tmp" ; $ fs -> remove ( $ tmp_dir ) ; // Copy the whole source dir in a temp directory $ this -> copyAssets ( $ fs , $ sourceAssetsDirectory , $ tmp_dir ) ; // Remove existing directory if ( $ fs -> exists ( $ to_directory ) ) { $ fs -> remove ( $ to_directory ) ; } // Put in place the new directory $ fs -> rename ( $ tmp_dir , $ to_directory ) ; if ( false === @ file_put_contents ( $ stamp_file_path , $ curr_stamp ) ) { throw new \ RuntimeException ( "Failed to create asset stamp file $stamp_file_path. Please check that your web server has the proper access rights to do that." ) ; } } }
Prepare an asset directory by checking that no changes occured in
the source directory. If any change is detected, the whole asset directory
is copied in the web space.

@param string $sourceAssetsDirectory  the full path to the source assets directory
@param string $webAssetsDirectoryBase the base directory of the web based asset directory
@param        $webAssetsTemplate
@param string $webAssetsKey           the assets key : module name or 0 for base template

@throws \RuntimeException if something goes wrong.
Prepare an asset directory by checking that no changes occured in the source directory . If any change is detected the whole asset directory is copied in the web space .