FileAccess Orion

Asset extends BaseContent
in package

Implement asset master object

This class provides general interfaces to trigger asset object specific reactions. Asset are contents witch several extra features, this class provides alternate storage interfaces and some helper methods to register uploaded files and rendering cronjobs.

Tags
category

Core content type

author

Tobias Teichner webmaster@teichner.biz

since

File available since v0.30

Table of Contents

$  : string
$  : string
$  : string
$  : int|string
$parent  : FolderTree|null
Store reference to parent folder
__construct()  : mixed
Asset constructor.
AssignMaster()  : Result
Add uploaded master file to asset moves the uploaded file to the asset folder and triggers the resize job
CorrectRotation()  : Result
Correct an images rotation by given degree.
DataType()  : string
Delete()  : Result
Delete a whole asset
Folder()  : FolderTree|null
Resolve the main project of this asset
ForceAssetRendering()  : Result
Render the asset entirely again
GeneralSearchFields()  : array<string|int, mixed>
Get the general search fields
GetMainPath()  : string
Get the main file Download the main file to local storage
ImprovedPublicUrl()  : string
IsProcessed()  : bool
check is locked state provide the is locked and in process status
Locked()  : void
set is locked state provide the is locked and in process status
PublicUrl()  : string|null
Get the instance as public url
ReplacedDerivatives()  : array<string|int, mixed>|mixed
Get replaced derivatives
RootPath()  : string
expose root path provide an interface to the date storage path of this asset
Save()  : Result
Save asset instance
SearchFields()  : array<string|int, mixed>
Get search fields Create a array of search fields
SetDerivativeReplaced()  : Result
Set a derivative as replaced
extraSearchFields()  : void
Add some extra search fields

Properties

$

public string $

hash The file hash of master entity

$

public string $

ext The extension like p4 or png

$

public string $

language The content language

$

public int|string $

main_relation The main relation

$parent

Store reference to parent folder

private FolderTree|null $parent = null

Methods

__construct()

Asset constructor.

public __construct([string|null $id = null ][, string|null $language = null ][, string $sub = 'asset' ]) : mixed
Parameters
$id : string|null = null

The asset id

$language : string|null = null

The language to load in

$sub : string = 'asset'

The type of the subclass

Return values
mixed

AssignMaster()

Add uploaded master file to asset moves the uploaded file to the asset folder and triggers the resize job

public AssignMaster(string $file[, bool $no_clear = false ]) : Result
Parameters
$file : string

Upload folder relative storage path of new asset

$no_clear : bool = false

When set, do not delete the source folder afterwards

Return values
Result

A system result object

CorrectRotation()

Correct an images rotation by given degree.

public CorrectRotation(int $degree) : Result

Uses the asset service to render a new base image, update the local image and then forces a new rendering operation.

Parameters
$degree : int

The rotation direction

Return values
Result

A system result object

DataType()

public DataType() : string
Return values
string

Delete()

Delete a whole asset

public Delete([bool $skip = false ]) : Result

As an asset is an extended form of the generic content the whole folder has to be deleted This method will also delete the folder and the asset in asset storage.

Parameters
$skip : bool = false

Skip hooks on demand

Return values
Result

A system result object

ForceAssetRendering()

Render the asset entirely again

public ForceAssetRendering([bool $full = false ][, bool $force_existing = true ]) : Result

Removes the locally stored content hashes of the derivatives and creates a job to render the files again. This file does an asset save. When it is not explicitly requested the replaced assets wont be affected.

Parameters
$full : bool = false

When true also the replaced will be rendered new

$force_existing : bool = true

Recreate all

Return values
Result

A system result object

GeneralSearchFields()

Get the general search fields

public GeneralSearchFields() : array<string|int, mixed>
Return values
array<string|int, mixed>

GetMainPath()

Get the main file Download the main file to local storage

public GetMainPath([string $size = 'main' ]) : string
Parameters
$size : string = 'main'
Return values
string

Absolute path to file or empty

ImprovedPublicUrl()

public ImprovedPublicUrl(Request $request, string $size[, string|null $prefix = null ][, bool $absolute = false ]) : string
Parameters
$request : Request

A system http request object

$size : string

The derivative type

$prefix : string|null = null

A prefix, can be name of the parent content

$absolute : bool = false

When true, the current master domain will be attached

Tags
deprecated

This method is deprecated

Return values
string

A public url with improved naming convention

IsProcessed()

check is locked state provide the is locked and in process status

public IsProcessed() : bool
Return values
bool

is locked or not

Locked()

set is locked state provide the is locked and in process status

public Locked([bool $value = true ]) : void
Parameters
$value : bool = true

The desired state

Return values
void

PublicUrl()

Get the instance as public url

public PublicUrl([bool $skip_cdn = true ][, string $size = 'main' ]) : string|null
Parameters
$skip_cdn : bool = true

Without cdn prefix, defaults to true

$size : string = 'main'

The variant / derivative to load

Return values
string|null

ReplacedDerivatives()

Get replaced derivatives

public ReplacedDerivatives() : array<string|int, mixed>|mixed
Return values
array<string|int, mixed>|mixed

RootPath()

expose root path provide an interface to the date storage path of this asset

public RootPath() : string
Return values
string

the absolute path to the storage folder

Save()

Save asset instance

public Save([bool $force_new_id = false ][, bool $skip = false ]) : Result

Save object entry in file system and git repository. Store the current payload inside the system storage and commit the changes to the local repository. Will trigger the renderer when not defined otherwise.

Parameters
$force_new_id : bool = false

Indicate force new id on demand (local id empty)

$skip : bool = false

When true do not check size changed

Return values
Result

A default system result object

SearchFields()

Get search fields Create a array of search fields

public SearchFields() : array<string|int, mixed>
Return values
array<string|int, mixed>

A list of search fields

SetDerivativeReplaced()

Set a derivative as replaced

public SetDerivativeReplaced(string $derivative, string $file) : Result

This method updates the corresponding attributes, the marker list and saves the asset

Parameters
$derivative : string

The attribute to set as replaced

$file : string

File path with extension that represents the new derivative

Return values
Result

A system result object

extraSearchFields()

Add some extra search fields

private extraSearchFields( &$fields) : void
Parameters
$fields :
Return values
void

Search results