class RevisionCompiler implements CompilerInterface

Traits

Constants

EMPTY_REVISION

Properties

protected callable[] $sourcesCallbacks from HasSources
protected array<string,string> $pendingSidecars Sidecar files (e.g. JsCompiler's `.map`) queued by renderOutput() during the current commit, written only if the primary file is — so an unchanged bundle rewrites nothing at all.

Methods

void
addSources(callable $callback)

No description

array
getSources()

No description

array
allowedSourceTypes()

No description

__construct(Cloud $assetsDir, string $filename, SettingsRepositoryInterface $settings, VersionerInterface $versioner)

No description

string|null
getFilename()

No description

void
setFilename(string $filename)

No description

void
commit(bool $force = false)

Recompile this asset and record its revision. Files are only written when the compiled output actually differs from what the revision manifest says is on disk (or the file has gone missing) — so routine rebuilds of unchanged assets are complete no-ops with zero writes.

void
writePendingSidecars()

No description

string
hashOutput(string $content)

No description

string|null
renderOutput(array $sources)

Produce the exact bytes to write to the primary asset file, or null when there is nothing to write (empty sources). This is what the revision is hashed from, so it must be identical to what gets committed — subclasses that transform or add to the output (e.g. JsCompiler's sourcemap handling) override this and queue any sidecar files (like the `.map`) on {$pendingSidecars} rather than writing them, so sidecars are only written when the bundle itself is.

string|null
getUrl()

No description

string
compile(array $sources)

No description

string
format(string $string)

No description

void
flush()

No description

void
delete(string $file)

No description

Details

void addSources(callable $callback)

Parameters

callable $callback

Return Value

void

protected array getSources()

Return Value

array

protected array allowedSourceTypes()

Return Value

array

__construct(Cloud $assetsDir, string $filename, SettingsRepositoryInterface $settings, VersionerInterface $versioner)

Parameters

Cloud $assetsDir
string $filename
SettingsRepositoryInterface $settings
VersionerInterface $versioner

string|null getFilename()

Return Value

string|null

void setFilename(string $filename)

Parameters

string $filename

Return Value

void

void commit(bool $force = false)

Recompile this asset and record its revision. Files are only written when the compiled output actually differs from what the revision manifest says is on disk (or the file has gone missing) — so routine rebuilds of unchanged assets are complete no-ops with zero writes.

Parameters

bool $force

Return Value

void

protected void writePendingSidecars()

Return Value

void

protected string hashOutput(string $content)

Parameters

string $content

Return Value

string

protected string|null renderOutput(array $sources)

Produce the exact bytes to write to the primary asset file, or null when there is nothing to write (empty sources). This is what the revision is hashed from, so it must be identical to what gets committed — subclasses that transform or add to the output (e.g. JsCompiler's sourcemap handling) override this and queue any sidecar files (like the `.map`) on {$pendingSidecars} rather than writing them, so sidecars are only written when the bundle itself is.

Parameters

array $sources

Return Value

string|null

string|null getUrl()

Return Value

string|null

protected string compile(array $sources)

Parameters

array $sources

Return Value

string

protected string format(string $string)

Parameters

string $string

Return Value

string

void flush()

Return Value

void

protected void delete(string $file)

Parameters

string $file

Return Value

void