2015-10-12 06:34:34 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace SilverStripe\Filesystem\Storage;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Interface to define a handler for persistent generated files
|
|
|
|
*
|
|
|
|
* @package framework
|
|
|
|
* @subpackage filesystem
|
|
|
|
*/
|
|
|
|
interface GeneratedAssetHandler {
|
|
|
|
|
|
|
|
/**
|
2015-11-26 03:19:43 +01:00
|
|
|
* Returns a URL to a generated asset, if one is available.
|
|
|
|
*
|
|
|
|
* Given a filename, determine if a file is available. If the file is unavailable,
|
|
|
|
* and a callback is supplied, invoke it to regenerate the content.
|
2015-10-12 06:34:34 +02:00
|
|
|
*
|
|
|
|
* @param string $filename
|
|
|
|
* @param callable $callback To generate content. If none provided, url will only be returned
|
|
|
|
* if there is valid content.
|
|
|
|
* @return string URL to generated file
|
|
|
|
*/
|
2015-11-26 03:19:43 +01:00
|
|
|
public function getContentURL($filename, $callback = null);
|
2015-10-12 06:34:34 +02:00
|
|
|
|
|
|
|
/**
|
2015-11-26 03:19:43 +01:00
|
|
|
* Returns the content for a generated asset, if one is available.
|
|
|
|
*
|
|
|
|
* Given a filename, determine if a file is available. If the file is unavailable,
|
|
|
|
* and a callback is supplied, invoke it to regenerate the content.
|
2015-10-12 06:34:34 +02:00
|
|
|
*
|
|
|
|
* @param string $filename
|
|
|
|
* @param callable $callback To generate content. If none provided, content will only be returned
|
|
|
|
* if there is valid content.
|
|
|
|
* @return string Content for this generated file
|
|
|
|
*/
|
2015-11-26 03:19:43 +01:00
|
|
|
public function getContent($filename, $callback = null);
|
2015-10-12 06:34:34 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Update content with new value
|
|
|
|
*
|
|
|
|
* @param string $filename
|
|
|
|
* @param string $content Content to write to the backend
|
|
|
|
*/
|
2015-11-26 03:19:43 +01:00
|
|
|
public function setContent($filename, $content);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Remove any content under the given file.
|
|
|
|
*
|
|
|
|
* If $filename is a folder, it should delete all files underneath it also.
|
|
|
|
*
|
|
|
|
* @param string $filename
|
|
|
|
*/
|
|
|
|
public function removeContent($filename);
|
2015-10-12 06:34:34 +02:00
|
|
|
}
|