class ThemeImages

The logos and icons a theme sets with the Theme extender.

Each is drawn into the assets directory the way an upload would be, and drawn again only when its file's contents or its options change. A file is only read again when its size or modification time changes. What was drawn is kept in a setting, so clearing the cache doesn't draw it again. While a theme sets an image, the setting an upload of it is kept in holds the drawn file instead, when that is the kind of file an upload would be. The upload is put back when the theme stops setting the image. Files an image no longer uses are kept for 30 days, for pages and emails that still show them, and taken back if the image returns to them.

Constants

STATE_KEY

VERSION

Raise to draw every theme image again, after changing how they are drawn.

KEEP_RETIRED_FOR

How long, in seconds, the files an image no longer uses are kept.

SETTINGS

image => [setting => the drawn file it holds].

Properties

protected Cloud $assets
protected array<string, array{signature: string, paths: array<string, string>, email_size?: string, replaced?: array<string, mixed>}>|null $state What was drawn, checked once per request.
protected array<string, array{file: string, svg?: string| null, background?: string| null, landscape?: string| null, owner?: string| null}>|null $config

Methods

__construct( Container $container, SettingsRepositoryInterface $settings, Factory $filesystemFactory)

No description

bool
has(string $image)

No description

array
owners()

No description

array
urls(string $image)

No description

array
paths(string $image)

No description

array|null
email(string $image)

The email copy of a theme image, as EmailLogo resolves it.

string|null
backgroundOf(string $image)

No description

void
assertNotSet(string $image, string $field)

No description

array
sync()

No description

array
drawOrLeaveOut(string $image, array $options, string $signature)

An image that can't be drawn is left out until its file changes, rather than tried again, and failing, on every request.

array
retire(string $image, array $entry, int $now)

No description

array|null
reuse(array $retired, string $image, string $signature)

Takes back the files drawn for an image before, if they are still kept.

array
draw(string $image, array $options, string $signature)

No description

void
assertDrawable(string $image, array $options)

No description

array
logo(string $data)

No description

array
encodeEmail(string $data)

No description

string
background(array $options)

No description

string
signature(string $image, array $options)

No description

array
replaced(string $image)

No description

void
mirror(string $image, array $entry)

Puts the drawn file in the image's settings, or the values they had before when it isn't the kind of file an upload would be.

string|null
contents(string $file)

A hash of the file's contents, read again only when its size or modification time changes.

void
deletePaths(array $paths)

No description

bool
isSvg(string $file)

No description

array
config()

The images set on this request, with their callables called.

Details

__construct( Container $container, SettingsRepositoryInterface $settings, Factory $filesystemFactory)

Parameters

Container $container
SettingsRepositoryInterface $settings
Factory $filesystemFactory

bool has(string $image)

Parameters

string $image

Return Value

bool

array owners()

Return Value

array image => title of the extension that set it

array urls(string $image)

Parameters

string $image

Return Value

array name => URL

array paths(string $image)

Parameters

string $image

Return Value

array name => path on the assets disk

array|null email(string $image)

The email copy of a theme image, as EmailLogo resolves it.

Parameters

string $image

Return Value

array|null

string|null backgroundOf(string $image)

Parameters

string $image

Return Value

string|null

void assertNotSet(string $image, string $field)

Parameters

string $image
string $field

Return Value

void

protected array sync()

Return Value

array

protected array drawOrLeaveOut(string $image, array $options, string $signature)

An image that can't be drawn is left out until its file changes, rather than tried again, and failing, on every request.

Parameters

string $image
array $options
string $signature

Return Value

array

protected array retire(string $image, array $entry, int $now)

Parameters

string $image
array $entry
int $now

Return Value

array

protected array|null reuse(array $retired, string $image, string $signature)

Takes back the files drawn for an image before, if they are still kept.

Parameters

array $retired
string $image
string $signature

Return Value

array|null

protected array draw(string $image, array $options, string $signature)

Parameters

string $image
array $options
string $signature

Return Value

array

protected void assertDrawable(string $image, array $options)

Parameters

string $image
array $options

Return Value

void

Parameters

string $data

Return Value

array contents and extension

protected array encodeEmail(string $data)

Parameters

string $data

Return Value

array the file, and its size as "WIDTHxHEIGHT"

protected string background(array $options)

Parameters

array $options

Return Value

string

protected string signature(string $image, array $options)

Parameters

string $image
array $options

Return Value

string

protected array replaced(string $image)

Parameters

string $image

Return Value

array setting => its value before the theme set the image

protected void mirror(string $image, array $entry)

Puts the drawn file in the image's settings, or the values they had before when it isn't the kind of file an upload would be.

Parameters

string $image
array $entry

Return Value

void

protected string|null contents(string $file)

A hash of the file's contents, read again only when its size or modification time changes.

Parameters

string $file

Return Value

string|null

protected void deletePaths(array $paths)

Parameters

array $paths

Return Value

void

protected bool isSvg(string $file)

Parameters

string $file

Return Value

bool

protected array config()

The images set on this request, with their callables called.

Return Value

array