Documentation

ViewBag extends ComponentBase
in package

The view bag stores custom template properties.

This is a hidden component ignored by the back-end UI.

Tags
author

Alexey Bobkov, Samuel Georges

Table of Contents

$alias  : string
$assetPath  : string
$componentCssClass  : string
$id  : string
$implement  : array<string|int, mixed>
$inspectorEnabled  : bool
$isHidden  : bool
$name  : string
$pluginIcon  : string
$assets  : array<string|int, mixed>
$controller  : Controller
$dirName  : string
$extendableCallbacks  : array<string|int, mixed>
$extendableGuardProperties  : bool
$extendableStaticMethods  : array<string|int, mixed>
$extensionData  : array<string|int, mixed>
$externalPropertyNames  : array<string|int, mixed>
$page  : PageCode
$properties  : array<string|int, mixed>
__call()  : mixed
__callStatic()  : mixed
__construct()  : mixed
Constructor
__get()  : void
Implements the getter functionality.
__isset()  : bool
Determine if an attribute exists on the object.
__set()  : mixed
__toString()  : mixed
Returns the component's alias, used by __SELF__
addCss()  : void
Adds StyleSheet asset to the asset list. Call $this->makeAssets() in a view to output corresponding markup.
addDynamicMethod()  : mixed
Programmatically adds a method to the extendable class
addDynamicProperty()  : mixed
Programmatically adds a property to the extendable class
addJs()  : void
Adds JavaScript asset to the asset list. Call $this->makeAssets() in a view to output corresponding markup.
addRss()  : void
Adds an RSS link asset to the asset list. Call $this->makeAssets() in a view to output corresponding markup.
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.
combineAssets()  : string
Run the provided assets through the Asset Combiner
componentDetails()  : array<string|int, mixed>
Returns information about this component, including name and description.
defineProperties()  : array<string|int, mixed>
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
fireSystemEvent()  : mixed
Fires a combination of local and global events. The first segment is removed from the event name locally and the local object is passed as the first argument to the event globally. Halting is also enabled by default.
fireViewEvent()  : string
Special event function used for extending within view files, allowing HTML to be injected multiple times.
flushAssets()  : void
Disables the use, and subequent broadcast, of assets. This is useful to call during an AJAX request to speed things up. This method works by specifically targeting the hasAssetsDefined method.
getAssetPath()  : string
Locates a file based on it's definition. If the file starts with a forward slash, it will be returned in context of the application public path, otherwise it will be returned in context of the asset path.
getAssetPaths()  : array<string|int, mixed>
Returns an array of all registered asset paths.
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
getPath()  : mixed
Returns the absolute component path.
getProperties()  : array<string|int, mixed>
Returns all properties.
getPropertyOptions()  : array<string|int, mixed>
Returns options for multi-option properties (drop-downs, etc.)
hasAssetsDefined()  : bool
Returns true if assets any have been added.
init()  : mixed
Executed when this component is first initialized, before AJAX requests.
isClassExtendedWith()  : bool
Check if extendable class is extended with a behavior object
makeAssets()  : string
Outputs `<link>` and `<script>` tags to load assets previously added with addJs and addCss method calls
methodExists()  : bool
Checks if a method exists, extension equivalent of method_exists()
onRender()  : mixed
Executed when this component is rendered on a page or layout.
onRun()  : mixed
Executed when this component is bound to a page or layout, part of the page life cycle.
paramName()  : string
Returns the external property name when the property value is a routing parameter reference.
property()  : string
Returns a defined property value or default if one is not set.
propertyExists()  : bool
Checks if a property exists, extension equivalent of `property_exists()`
propertyName()  : string
Returns the external property name when the property value is an external property reference.
renderPartial()  : mixed
Renders a requested partial in context of this component, see Cms\Classes\Controller@renderPartial for usage.
runAjaxHandler()  : bool
Executes the event cycle when running an AJAX handler.
setExternalPropertyName()  : string
Sets an external property name.
setExternalPropertyNames()  : void
Sets names used by external properties.
setProperties()  : void
Sets multiple properties.
setProperty()  : void
Sets a property value
validateProperties()  : array<string|int, mixed>
addAsset()  : mixed
Adds the provided asset to the internal asset collections
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.
getAssetEntryBuildPath()  : string
Internal helper, attaches a build code to an asset path
getAssetScheme()  : string
Internal helper, get asset scheme
getLocalPath()  : mixed
removeDuplicates()  : void
Removes duplicate assets from the entire collection.

Properties

$assetPath

public string $assetPath

Specifies a path to the asset directory.

$componentCssClass

public string $componentCssClass

Component CSS class name for the back-end page/layout component list. This field is used by the CMS internally.

$id

public string $id

A unique identifier for this component.

$implement

public array<string|int, mixed> $implement

Extensions implemented by this class.

$inspectorEnabled

public bool $inspectorEnabled = true

Determines whether Inspector can be used with the component. This field is used by the CMS internally.

$isHidden

public bool $isHidden = true

This component is hidden from the back-end UI.

$name

public string $name

Component class name or class alias used in the component declaration in a template.

$pluginIcon

public string $pluginIcon

Icon of the plugin that defines the component. This field is used by the CMS internally.

$assets

protected array<string|int, mixed> $assets = ['js' => [], 'css' => [], 'rss' => []]

Collection of assets to display in the layout.

$dirName

protected string $dirName

Specifies the component directory 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.

$externalPropertyNames

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

A collection of external property names used by this component.

$properties

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

Contains the object property values.

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()

Constructor

public __construct() : mixed
Return values
mixed

__get()

Implements the getter functionality.

public __get(string $name) : void
Parameters
$name : string
Return values
void

__isset()

Determine if an attribute exists on the object.

public __isset(string $key) : bool
Parameters
$key : string
Return values
bool

__set()

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

__toString()

Returns the component's alias, used by __SELF__

public __toString() : mixed
Return values
mixed

addCss()

Adds StyleSheet asset to the asset list. Call $this->makeAssets() in a view to output corresponding markup.

public addCss(string $name[, array<string|int, mixed> $attributes = [] ]) : void
Parameters
$name : string

Specifies a path (URL) to the script.

$attributes : array<string|int, mixed> = []

Adds extra HTML attributes to the asset link.

Return values
void

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

addJs()

Adds JavaScript asset to the asset list. Call $this->makeAssets() in a view to output corresponding markup.

public addJs(string $name[, array<string|int, mixed> $attributes = [] ]) : void
Parameters
$name : string

Specifies a path (URL) to the script.

$attributes : array<string|int, mixed> = []

Adds extra HTML attributes to the asset link.

Return values
void

addRss()

Adds an RSS link asset to the asset list. Call $this->makeAssets() in a view to output corresponding markup.

public addRss(string $name[, array<string|int, mixed> $attributes = [] ]) : void
Parameters
$name : string

Specifies a path (URL) to the RSS channel

$attributes : array<string|int, mixed> = []

Adds extra HTML attributes to the asset link.

Return values
void

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

combineAssets()

Run the provided assets through the Asset Combiner

public combineAssets(array<string|int, mixed> $assets[, string $localPath = '' ]) : string
Parameters
$assets : array<string|int, mixed>

Collection of assets

$localPath : string = ''

Prefix all assets with this path (optional)

Return values
string

componentDetails()

Returns information about this component, including name and description.

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

defineProperties()

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

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

fireSystemEvent()

Fires a combination of local and global events. The first segment is removed from the event name locally and the local object is passed as the first argument to the event globally. Halting is also enabled by default.

public fireSystemEvent(string $event[, array<string|int, mixed> $params = [] ][, bool $halt = true ]) : mixed

For example:

$this->fireSystemEvent('backend.list.myEvent', ['my value']);

Is equivalent to:

$this->fireEvent('list.myEvent', ['myvalue'], true);

Event::fire('backend.list.myEvent', [$this, 'myvalue'], true);
Parameters
$event : string

Event name

$params : array<string|int, mixed> = []

Event parameters

$halt : bool = true

Halt after first non-null result

Return values
mixed

fireViewEvent()

Special event function used for extending within view files, allowing HTML to be injected multiple times.

public fireViewEvent(string $event[, array<string|int, mixed> $params = [] ]) : string

For example:

fireViewEvent('backend.auth.extendSigninView') ?>
Parameters
$event : string

Event name

$params : array<string|int, mixed> = []

Event parameters

Return values
string

flushAssets()

Disables the use, and subequent broadcast, of assets. This is useful to call during an AJAX request to speed things up. This method works by specifically targeting the hasAssetsDefined method.

public flushAssets() : void
Return values
void

getAssetPath()

Locates a file based on it's definition. If the file starts with a forward slash, it will be returned in context of the application public path, otherwise it will be returned in context of the asset path.

public getAssetPath(string $fileName[, string $assetPath = null ]) : string
Parameters
$fileName : string

File to load.

$assetPath : string = null

Explicitly define an asset path.

Return values
string

Relative path to the asset file.

getAssetPaths()

Returns an array of all registered asset paths.

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

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']

getPath()

Returns the absolute component path.

public getPath() : mixed
Return values
mixed

getProperties()

Returns all properties.

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

getPropertyOptions()

Returns options for multi-option properties (drop-downs, etc.)

public getPropertyOptions(string $property) : array<string|int, mixed>
Parameters
$property : string

Specifies the property name

Return values
array<string|int, mixed>

Return an array of option values and descriptions

hasAssetsDefined()

Returns true if assets any have been added.

public hasAssetsDefined() : bool
Return values
bool

init()

Executed when this component is first initialized, before AJAX requests.

public init() : mixed
Return values
mixed

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

makeAssets()

Outputs `<link>` and `<script>` tags to load assets previously added with addJs and addCss method calls

public makeAssets([string $type = null ]) : string
Parameters
$type : string = null

Return an asset collection of a given type (css, rss, js) or null for all.

Return values
string

methodExists()

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

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

onRender()

Executed when this component is rendered on a page or layout.

public onRender() : mixed
Return values
mixed

onRun()

Executed when this component is bound to a page or layout, part of the page life cycle.

public onRun() : mixed
Return values
mixed

paramName()

Returns the external property name when the property value is a routing parameter reference.

public paramName(string $name[, mixed $default = null ]) : string

Otherwise the default value specified is returned.

Parameters
$name : string

The property name

$default : mixed = null
Return values
string

property()

Returns a defined property value or default if one is not set.

public property(string $name[, string $default = null ]) : string
Parameters
$name : string

The property name to look for.

$default : string = null

A default value to return if no name is found.

Return values
string

The property value or the default specified.

propertyExists()

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

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

propertyName()

Returns the external property name when the property value is an external property reference.

public propertyName(string $name[, mixed $default = null ]) : string

Otherwise the default value specified is returned.

Parameters
$name : string

The property name

$default : mixed = null
Return values
string

renderPartial()

Renders a requested partial in context of this component, see Cms\Classes\Controller@renderPartial for usage.

public renderPartial() : mixed
Return values
mixed

runAjaxHandler()

Executes the event cycle when running an AJAX handler.

public runAjaxHandler(mixed $handler) : bool
Parameters
$handler : mixed
Return values
bool

Returns true if the handler was found. Returns false otherwise.

setExternalPropertyName()

Sets an external property name.

public setExternalPropertyName(string $name, string $extName) : string
Parameters
$name : string

Property name

$extName : string

External property name

Return values
string

setExternalPropertyNames()

Sets names used by external properties.

public setExternalPropertyNames(array<string|int, mixed> $names) : void
Parameters
$names : array<string|int, mixed>

The key should be the property name, the value should be the external property name.

Return values
void

setProperties()

Sets multiple properties.

public setProperties(array<string|int, mixed> $properties) : void
Parameters
$properties : array<string|int, mixed>
Return values
void

setProperty()

Sets a property value

public setProperty(string $name, mixed $value) : void
Parameters
$name : string
$value : mixed
Return values
void

validateProperties()

public validateProperties(array<string|int, mixed> $properties) : array<string|int, mixed>
Parameters
$properties : array<string|int, mixed>
Return values
array<string|int, mixed>

addAsset()

Adds the provided asset to the internal asset collections

protected addAsset(string $type, string $path, array<string|int, mixed> $attributes) : mixed
Parameters
$type : string

The type of the asset: 'js' || 'css' || 'rss'

$path : string

The path to the asset

$attributes : array<string|int, mixed>

The attributes for the asset

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

getAssetEntryBuildPath()

Internal helper, attaches a build code to an asset path

protected getAssetEntryBuildPath(array<string|int, mixed> $asset) : string
Parameters
$asset : array<string|int, mixed>

Stored asset array

Return values
string

getAssetScheme()

Internal helper, get asset scheme

protected getAssetScheme(string $asset) : string
Parameters
$asset : string

Specifies a path (URL) to the asset.

Return values
string

getLocalPath()

protected getLocalPath(string $relativePath) : mixed
Parameters
$relativePath : string
Return values
mixed

removeDuplicates()

Removes duplicate assets from the entire collection.

protected removeDuplicates() : void
Return values
void

Search results