class GeneratedAssets implements GeneratedAssetHandler (View source)

Simple Flysystem implementation of GeneratedAssetHandler for storing generated content

Properties

protected Filesystem $assetStore

Flysystem store for files

Methods

public
$this
setFilesystem(Filesystem $store)

Assign the asset backend. This must be a filesystem with an adapter of type {PublicAdapter}.

public
Filesystem
getFilesystem()

Get the asset backend

public
string
getContentURL(string $filename, callable $callback = null)

Returns a URL to a generated asset, if one is available.

public
string
getContent(string $filename, callable $callback = null)

Returns the content for a generated asset, if one is available.

protected
bool
checkOrCreate(string $filename, callable $callback = null)

Check if the file exists or that the $callback provided was able to regenerate it.

public
setContent(string $filename, string $content)

Update content with new value

public
removeContent(string $filename)

Remove any content under the given file.

Details

$this setFilesystem(Filesystem $store)

Assign the asset backend. This must be a filesystem with an adapter of type {PublicAdapter}.

Parameters

Filesystem $store

Return Value

$this

Filesystem getFilesystem()

Get the asset backend

Return Value

Filesystem

Exceptions

Exception

string getContentURL(string $filename, callable $callback = null)

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.

Parameters

string $filename
callable $callback

To generate content. If none provided, url will only be returned if there is valid content.

Return Value

string

URL to generated file

string getContent(string $filename, callable $callback = null)

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.

Parameters

string $filename
callable $callback

To generate content. If none provided, content will only be returned if there is valid content.

Return Value

string

Content for this generated file

protected bool checkOrCreate(string $filename, callable $callback = null)

Check if the file exists or that the $callback provided was able to regenerate it.

Parameters

string $filename
callable $callback

Return Value

bool

Whether or not the file exists

Exceptions

Exception

setContent(string $filename, string $content)

Update content with new value

Parameters

string $filename
string $content

Content to write to the backend

removeContent(string $filename)

Remove any content under the given file.

If $filename is a folder, it should delete all files underneath it also.

Parameters

string $filename