Since: 1.3.0

class RokkaHash extends AbstractLocalImage (View source)

Creates a LocalImage object with an existing rokka hash as input.

Example:

$image = new RokkaHash($hash, $identifier, $context);

If you want to get the source image content by getContent(), you need to inject a TemplateHelper object into the constructor

Properties

protected mixed|null $context

Can be anything and accessed in callbacks and such.

from  AbstractLocalImage
protected string|null $rokkaHash

The rokka hash from the rokka API.

from  AbstractLocalImage
protected string|null $identifier

A unique identifier for this image, can be any string.

from  AbstractLocalImage

Methods

__construct(string $hash, string|null $identifier = null, mixed|null $context = null, TemplateHelper|null $templateHelper = null)

No description

string|bool
getRealpath()

Returns the realPath of an image, if there is one.

string|null
getFilename()

Returns the filename of an image.

string|null
getContent()

Returns the actual content of an image.

null|string
getIdentifier()

Returns the unique custom identifier.

setIdentifier(string|null $identifier)

Sets the unique custom identifier.

mixed|null
getContext()

Returns the custom context.

setContext(mixed|null $context)

Sets the custom context.

null|string
getRokkaHash()

Returns the rokkaHash, in case the object knows it already.

Details

__construct(string $hash, string|null $identifier = null, mixed|null $context = null, TemplateHelper|null $templateHelper = null)

No description

Parameters

string $hash
string|null $identifier

A unique custom identifier for this image

mixed|null $context

Can be anything and accessed in callbacks and such

TemplateHelper|null $templateHelper

string|bool getRealpath()

Since: 1.3.0

Returns the realPath of an image, if there is one.

If the file isn't on the local file system (or a stream, php understands), return false.

Return Value

string|bool

string|null getFilename()

Since: 1.3.0 This is used for nicer looking generated URLs, but optional

Returns the filename of an image.

Return Value

string|null

string|null getContent()

Since: 1.3.0

Returns the actual content of an image.

Return Value

string|null

Exceptions

GuzzleException

null|string getIdentifier()

Returns the unique custom identifier.

Return Value

null|string

setIdentifier(string|null $identifier)

Since: 1.3.0

Sets the unique custom identifier.

Parameters

string|null $identifier

mixed|null getContext()

Since: 1.3.0

Returns the custom context.

Return Value

mixed|null

setContext(mixed|null $context)

Since: 1.3.0

Sets the custom context.

Parameters

mixed|null $context

null|string getRokkaHash()

Since: 1.3.0

Returns the rokkaHash, in case the object knows it already.

Happens especially with the RokkaHash LocalImage class, but others may use it too

Return Value

null|string