Documentation

Asset extends Extendable
in package

The CMS asset file class.

Tags
author

Alexey Bobkov, Samuel Georges

Table of Contents

$content  : string
$exists  : bool
$fileName  : string
$implement  : array<string|int, mixed>
$mtime  : string
$allowedExtensions  : array<string|int, mixed>
$dirName  : string
$extendableCallbacks  : array<string|int, mixed>
$extendableGuardProperties  : bool
$extendableStaticMethods  : array<string|int, mixed>
$extensionData  : array<string|int, mixed>
$fillable  : array<string|int, mixed>
$originalFileName  : string
$theme  : Theme
__call()  : mixed
__callStatic()  : mixed
__construct()  : mixed
Creates an instance of the object and associates it with a CMS theme.
__get()  : mixed
__set()  : mixed
addDynamicMethod()  : mixed
Programmatically adds a method to the extendable class
addDynamicProperty()  : mixed
Programmatically adds a property to the extendable class
asExtension()  : mixed
Short hand for `getClassExtension()` method, except takes the short extension name, example:
clearExtendedClasses()  : void
Clear the list of extended classes so they will be re-extended.
extend()  : mixed
extendableCall()  : mixed
Magic method for `__call()`
extendableCallStatic()  : mixed
Magic method for `__callStatic()`
extendableConstruct()  : mixed
This method should be called as part of the constructor.
extendableExtendCallback()  : void
Helper method for `::extend()` static method
extendableGet()  : string
Magic method for `__get()`
extendableSet()  : string
Magic method for `__set()`
extendClassWith()  : void
Dynamically extend a class with a specified behavior
fill()  : mixed
Sets the object attributes.
find()  : mixed|static
Find a single template by its file name.
getClassExtension()  : mixed
Returns a behavior object from an extendable class, example:
getClassMethods()  : array<string|int, mixed>
Get a list of class methods, extension equivalent of get_class_methods()
getDynamicProperties()  : array<string|int, mixed>
Returns all dynamic properties and their values
getEditableExtensions()  : array<string|int, mixed>
Returns a list of editable asset extensions.
getFileName()  : string
Returns the file name.
getFilePath()  : string
Returns the absolute file path.
inTheme()  : $this
Prepares the theme datasource for the model.
isClassExtendedWith()  : bool
Check if extendable class is extended with a behavior object
load()  : mixed
Loads the object from a file.
methodExists()  : bool
Checks if a method exists, extension equivalent of method_exists()
propertyExists()  : bool
Checks if a property exists, extension equivalent of `property_exists()`
save()  : mixed
Saves the object to the disk.
extendableIsAccessible()  : bool
Checks if a property is accessible, property equivalent of `is_callable()`
extensionExtractMethods()  : void
Extracts the available methods from a behavior and adds it to the list of callable methods.
validateFileName()  : mixed
Validate the supplied filename, extension and path.

Properties

$content

public string $content

The entire file content.

$exists

public bool $exists = false

Indicates if the model exists.

$fileName

public string $fileName

Specifies the file name corresponding the CMS object.

$implement

public array<string|int, mixed> $implement

Extensions implemented by this class.

$mtime

public string $mtime

Last modified time.

$allowedExtensions

protected array<string|int, mixed> $allowedExtensions = []

Allowable file extensions.

$dirName

protected string $dirName = 'plugins'

The plugin folder name.

$extendableCallbacks

protected static array<string|int, mixed> $extendableCallbacks = []

Used to extend the constructor of an extendable class. Eg:

Class::extend(function($obj) { })

$extendableGuardProperties

protected static bool $extendableGuardProperties = true

Indicates if dynamic properties can be created.

$extendableStaticMethods

protected static array<string|int, mixed> $extendableStaticMethods = []

Collection of static methods used by behaviors.

$extensionData

protected array<string|int, mixed> $extensionData = ['extensions' => [], 'methods' => [], 'dynamicMethods' => [], 'dynamicProperties' => []]

Class reflection information, including behaviors.

$fillable

protected array<string|int, mixed> $fillable = ['fileName', 'content']

The attributes that are mass assignable.

$originalFileName

protected string $originalFileName = null

Specifies the file name, the CMS object was loaded from.

$theme

protected Theme $theme

A reference to the CMS theme containing the object.

Methods

__call()

public __call(mixed $name, mixed $params) : mixed
Parameters
$name : mixed
$params : mixed
Return values
mixed

__callStatic()

public static __callStatic(mixed $name, mixed $params) : mixed
Parameters
$name : mixed
$params : mixed
Return values
mixed

__construct()

Creates an instance of the object and associates it with a CMS theme.

public __construct() : mixed
Return values
mixed

__get()

public __get(mixed $name) : mixed
Parameters
$name : mixed
Return values
mixed

__set()

public __set(mixed $name, mixed $value) : mixed
Parameters
$name : mixed
$value : mixed
Return values
mixed

addDynamicMethod()

Programmatically adds a method to the extendable class

public addDynamicMethod(string $dynamicName, callable $method[, string $extension = null ]) : mixed
Parameters
$dynamicName : string
$method : callable
$extension : string = null
Return values
mixed

addDynamicProperty()

Programmatically adds a property to the extendable class

public addDynamicProperty(string $dynamicName[, string $value = null ]) : mixed
Parameters
$dynamicName : string
$value : string = null
Return values
mixed

asExtension()

Short hand for `getClassExtension()` method, except takes the short extension name, example:

public asExtension(string $shortName) : mixed

$this->asExtension('FormController')

Parameters
$shortName : string
Return values
mixed

clearExtendedClasses()

Clear the list of extended classes so they will be re-extended.

public static clearExtendedClasses() : void
Return values
void

extend()

public static extend(callable $callback) : mixed
Parameters
$callback : callable
Return values
mixed

extendableCall()

Magic method for `__call()`

public extendableCall(string $name[, array<string|int, mixed> $params = null ]) : mixed
Parameters
$name : string
$params : array<string|int, mixed> = null
Return values
mixed

extendableCallStatic()

Magic method for `__callStatic()`

public static extendableCallStatic(string $name[, array<string|int, mixed> $params = null ]) : mixed
Parameters
$name : string
$params : array<string|int, mixed> = null
Return values
mixed

extendableConstruct()

This method should be called as part of the constructor.

public extendableConstruct() : mixed
Return values
mixed

extendableExtendCallback()

Helper method for `::extend()` static method

public static extendableExtendCallback(callable $callback) : void
Parameters
$callback : callable
Return values
void

extendableGet()

Magic method for `__get()`

public extendableGet(string $name) : string
Parameters
$name : string
Return values
string

extendableSet()

Magic method for `__set()`

public extendableSet(string $name, string $value) : string
Parameters
$name : string
$value : string
Return values
string

extendClassWith()

Dynamically extend a class with a specified behavior

public extendClassWith(string $extensionName) : void
Parameters
$extensionName : string
Return values
void

fill()

Sets the object attributes.

public fill(array<string|int, mixed> $attributes) : mixed
Parameters
$attributes : array<string|int, mixed>

A list of attributes to set.

Return values
mixed

find()

Find a single template by its file name.

public find(string $fileName) : mixed|static
Parameters
$fileName : string
Return values
mixed|static

getClassExtension()

Returns a behavior object from an extendable class, example:

public getClassExtension(string $name) : mixed

$this->getClassExtension('Backend.Behaviors.FormController')

Parameters
$name : string

Fully qualified behavior name

Return values
mixed

getClassMethods()

Get a list of class methods, extension equivalent of get_class_methods()

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

getDynamicProperties()

Returns all dynamic properties and their values

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

['property' => 'value']

getEditableExtensions()

Returns a list of editable asset extensions.

public static getEditableExtensions() : array<string|int, mixed>

The list can be overridden with the cms.editableAssetTypes configuration option.

Return values
array<string|int, mixed>

getFileName()

Returns the file name.

public getFileName() : string
Return values
string

getFilePath()

Returns the absolute file path.

public getFilePath([string $fileName = null ]) : string
Parameters
$fileName : string = null

Specifies the file name to return the path to.

Return values
string

inTheme()

Prepares the theme datasource for the model.

public static inTheme(Theme $theme) : $this
Parameters
$theme : Theme

Specifies a parent theme.

Return values
$this

isClassExtendedWith()

Check if extendable class is extended with a behavior object

public isClassExtendedWith(string $name) : bool
Parameters
$name : string

Fully qualified behavior name

Return values
bool

load()

Loads the object from a file.

public static load(Theme $theme, string $fileName) : mixed

This method is used in the CMS back-end. It doesn't use any caching.

Parameters
$theme : Theme

Specifies the theme the object belongs to.

$fileName : string

Specifies the file name, with the extension. The file name can contain only alphanumeric symbols, dashes and dots.

Return values
mixed

Returns a CMS object instance or null if the object wasn't found.

methodExists()

Checks if a method exists, extension equivalent of method_exists()

public methodExists(string $name) : bool
Parameters
$name : string
Return values
bool

propertyExists()

Checks if a property exists, extension equivalent of `property_exists()`

public propertyExists(string $name) : bool
Parameters
$name : string
Return values
bool

save()

Saves the object to the disk.

public save() : mixed
Return values
mixed

extendableIsAccessible()

Checks if a property is accessible, property equivalent of `is_callable()`

protected extendableIsAccessible(mixed $class, string $propertyName) : bool
Parameters
$class : mixed
$propertyName : string
Return values
bool

extensionExtractMethods()

Extracts the available methods from a behavior and adds it to the list of callable methods.

protected extensionExtractMethods(string $extensionName, object $extensionObject) : void
Parameters
$extensionName : string
$extensionObject : object
Return values
void

validateFileName()

Validate the supplied filename, extension and path.

protected validateFileName([string $fileName = null ]) : mixed
Parameters
$fileName : string = null
Return values
mixed

Search results