PHP Class MiniAsset\Output\AssetWriter

Inheritance: use trait FreshTrait
Datei anzeigen Open project: markstory/mini-asset Class Usage Examples

Protected Properties

Property Type Description
$_invalidated array An array of invalidated output files.
$path
$theme
$timestamp

Public Methods

Method Description
__construct ( array $timestamp, string $timestampPath, string $theme = null ) Constructor.
buildCacheName ( string $build ) : string Get the cache name a build.
buildFileName ( AssetTarget $target, $timestamp = true ) : string Get the final filename for a build. Resolves theme prefixes and timestamps.
clearTimestamps ( ) : void Clear timestamps for assets.
config ( ) : array Get the config options this object is using.
finalize ( AssetTarget $build ) : void Finalize a build after written to filesystem.
getTimestamp ( AssetTarget $build ) : mixed Get the last build timestamp for a given build.
invalidate ( AssetTarget $build ) : void Invalidate a build before re-generating the file.
outputDir ( AssetTarget $target ) : string Get the output dir
setTimestamp ( AssetTarget $build, integer $time ) : void Set the timestamp for a build file.
write ( AssetTarget $build, string $content ) Writes content into a file

Protected Methods

Method Description
_readTimestamp ( ) : array Read timestamps from either the fast cache, or the serialized file.
_timestampFile ( string $file, integer $time ) : string Modify a file name and append in the timestamp
_writeTimestamp ( array $data ) : void Write timestamps to either the fast cache, or the serialized file.

Method Details

__construct() public method

Constructor.
public __construct ( array $timestamp, string $timestampPath, string $theme = null )
$timestamp array The map of extensions and timestamps
$timestampPath string The path to the timestamp file for assets.
$theme string The the theme being assets are being built for.

_readTimestamp() protected method

Read timestamps from either the fast cache, or the serialized file.
protected _readTimestamp ( ) : array
return array An array of timestamps for build files.

_timestampFile() protected method

Modify a file name and append in the timestamp
protected _timestampFile ( string $file, integer $time ) : string
$file string The filename.
$time integer The timestamp.
return string The build filename to cache on disk.

_writeTimestamp() protected method

Write timestamps to either the fast cache, or the serialized file.
protected _writeTimestamp ( array $data ) : void
$data array An array of timestamps for build files.
return void

buildCacheName() public method

Get the cache name a build.
public buildCacheName ( string $build ) : string
$build string The build target name.
return string The build cache name.

buildFileName() public method

Get the final filename for a build. Resolves theme prefixes and timestamps.
public buildFileName ( AssetTarget $target, $timestamp = true ) : string
$target MiniAsset\AssetTarget The build target name.
return string The build filename to cache on disk.

clearTimestamps() public method

Clear timestamps for assets.
public clearTimestamps ( ) : void
return void

config() public method

Get the config options this object is using.
public config ( ) : array
return array

finalize() public method

Finalize a build after written to filesystem.
public finalize ( AssetTarget $build ) : void
$build MiniAsset\AssetTarget The build to finalize.
return void

getTimestamp() public method

Will either read the cached version, or the on disk version. If no timestamp is found for a file, a new time will be generated and saved. If timestamps are disabled, false will be returned.
public getTimestamp ( AssetTarget $build ) : mixed
$build MiniAsset\AssetTarget The build to get a timestamp for.
return mixed The last build time, or false.

invalidate() public method

Invalidate a build before re-generating the file.
public invalidate ( AssetTarget $build ) : void
$build MiniAsset\AssetTarget The build to invalidate.
return void

outputDir() public method

Used to locate outputs when determining freshness.
public outputDir ( AssetTarget $target ) : string
$target MiniAsset\AssetTarget
return string The path

setTimestamp() public method

Set the timestamp for a build file.
public setTimestamp ( AssetTarget $build, integer $time ) : void
$build MiniAsset\AssetTarget The name of the build to set a timestamp for.
$time integer The timestamp.
return void

write() public method

Writes content into a file
public write ( AssetTarget $build, string $content )
$build MiniAsset\AssetTarget The filename to write.
$content string The contents to write.

Property Details

$_invalidated protected_oe property

An array of invalidated output files.
protected array $_invalidated
return array

$path protected_oe property

protected $path

$theme protected_oe property

protected $theme

$timestamp protected_oe property

protected $timestamp