Resources

Resources component

 class Cms\Components\Resources
extends Cms\Classes\ComponentBase

Extends

Class Description
ComponentBase

Component base class

Traits

Trait Description
AssetMaker

Asset Maker Trait Adds asset based methods to a class

EventEmitter

Adds system event related features to any class.

ExtendableTrait

This extension trait is used when access to the underlying base class is not available, such as classes that belong to the foundation framework (Laravel). It is currently used by the Controller and Model classes.

PropertyContainer

Property container trait

Properties

public $cssDir : string

The default CSS directory

public $jsDir : string

The default JavaScript directory

public $lessDir : string

The default LESS directory

public $sassDir : string

The default SASS directory

inherited public $alias : string

Inherited from ComponentBase

Alias used for this component.

inherited public $assetPath : string

Inherited from ComponentBase

Specifies a path to the asset directory.

inherited public $componentCssClass : string

Inherited from ComponentBase

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

inherited public $id : string

Inherited from ComponentBase

A unique identifier for this component.

inherited public $implement : string | array | null

Inherited from ComponentBase

Extensions implemented by this class.

inherited public $inspectorEnabled : bool

Inherited from ComponentBase

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

inherited public $isHidden : bool

Inherited from ComponentBase

Determines whether the component is hidden from the back-end UI.

inherited public $name : string

Inherited from ComponentBase

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

inherited public $pluginIcon : string

Inherited from ComponentBase

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

inherited protected $assets : array

Inherited from ComponentBase

Collection of assets to display in the layout.

inherited protected $controller : Cms\Classes\Controller

Inherited from ComponentBase

Controller object.

inherited protected $dirName : string

Inherited from ComponentBase

Specifies the component directory name.

inherited protected static $extendableCallbacks : array

Inherited from ComponentBase

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

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

inherited protected static $extendableClassLoader : ClassLoader | null

Inherited from ComponentBase

Class loader instance.

inherited protected $extendableConstructed : bool

Inherited from ComponentBase

Indicates if the extendable constructor has completed.

inherited protected static $extendableStaticMethods : array

Inherited from ComponentBase

Collection of static methods used by behaviors.

inherited protected $extensionData : array

Inherited from ComponentBase

Class reflection information, including behaviors.

inherited protected $externalPropertyNames : array

Inherited from ComponentBase

A collection of external property names used by this component.

inherited protected $localCallbacks : array

Inherited from ComponentBase

This stores any locally-scoped callbacks fired before the extendable constructor had completed.

inherited protected $orderFactor : integer

Inherited from ComponentBase

Ensures "first-come, first-served" applies to assets of the same ordering.

inherited protected $page : Cms\Classes\PageCode

Inherited from ComponentBase

Page object object.

inherited protected $properties : array

Inherited from ComponentBase

Contains the object property values.

Methods

public componentDetails () : array

Returns
array

public defineProperties () : array

Returns
array

public init ()

Returns
mixed

public onRun ()

Returns
mixed

protected guessAssetDirectory (array $possible, $default = null)

Parameters
Property Description
$possible
array
$default
mixed
Returns
mixed

protected guessAssetPath ()

Returns
mixed

protected prefixCss ($value)

Parameters
Property Description
$value
mixed
Returns
mixed

protected prefixJs ($value)

Parameters
Property Description
$value
mixed
Returns
mixed

protected prefixLess ($value)

Parameters
Property Description
$value
mixed
Returns
mixed

protected prefixSass ($value)

Parameters
Property Description
$value
mixed
Returns
mixed

inherited public __call (string $method, array $parameters) : mixed

Inherited from ComponentBase

Dynamically handle calls into the controller instance.

Parameters
Property Description
$method
string
$parameters
array
Returns
mixed

inherited public static __callStatic ($name, $params)

Inherited from ComponentBase
Parameters
Property Description
$name
mixed
$params
mixed
Returns
mixed

inherited public __construct (null | CodeBase $cmsObject = null, array $properties = [])

Inherited from ComponentBase

Component constructor. Takes in the page or layout code section object and properties set by the page or layout.

Parameters
Property Description
$cmsObject
null | CodeBase
$properties
array
Returns
mixed

inherited public __get ($name)

Inherited from ComponentBase
Parameters
Property Description
$name
mixed
Returns
mixed

inherited public __set ($name, $value)

Inherited from ComponentBase
Parameters
Property Description
$name
mixed
$value
mixed
Returns
mixed

inherited public __toString ()

Inherited from ComponentBase

Returns the component's alias, used by SELF

Returns
mixed

inherited public addCss (string | array $name, array $attributes = []) : void

Inherited from ComponentBase

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

Parameters
Property Description
$name
string | array

When an array of paths are provided they will be passed to the Asset Combiner

$attributes
array

When a string is provided it will be used as the 'build' attribute value

Returns
void

inherited public addDynamicMethod (string $dynamicName, callable $method, string $extension = null)

Inherited from ComponentBase

Programmatically adds a method to the extendable class

Parameters
Property Description
$dynamicName
string
$method
callable
$extension
string
Returns
mixed

inherited public addDynamicProperty (string $dynamicName, mixed $value = null) : void

Inherited from ComponentBase

Programmatically adds a property to the extendable class

Parameters
Property Description
$dynamicName
string

The name of the property to add

$value
mixed

The value of the property

Returns
void

inherited public addJs (string | array $name, array $attributes = []) : void

Inherited from ComponentBase

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

Parameters
Property Description
$name
string | array

When an array of paths are provided they will be passed to the Asset Combiner

$attributes
array

When a string is provided it will be used as the 'build' attribute value

Returns
void

inherited public addRss (string $name, array $attributes = []) : void

Inherited from ComponentBase

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

Parameters
Property Description
$name
string
$attributes
array
Returns
void

inherited public addVite (array | string $entrypoints, ?string $package = null) : void

Inherited from ComponentBase

Adds Vite tags

Parameters
Property Description
$entrypoints
array | string

The list of entry points for Vite

$package
?string

The package name of the plugin or theme

Returns
void

inherited public asExtension (string $shortName) : mixed

Inherited from ComponentBase

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

$this->asExtension('FormController')

Parameters
Property Description
$shortName
string
Returns
mixed

inherited public static clearExtendedClasses () : void

Inherited from ComponentBase

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

Returns
void

inherited public combineAssets (array $assets, string $localPath = "") : string

Inherited from ComponentBase

Run the provided assets through the Asset Combiner

Parameters
Property Description
$assets
array
$localPath
string
Returns
string

inherited public extendClassWith (string $extensionName) : void

Inherited from ComponentBase

Dynamically extend a class with a specified behavior

Parameters
Property Description
$extensionName
string
Returns
void

inherited public static extendableAddExtension (callable $callback, boolean $scoped = false, $outerScope = null) : void

Inherited from ComponentBase

Extends the class using a closure.

The closure will be provided a single parameter which is the instance of the extended class, by default.

You may optionally specify the callback as a scoped callback, which inherits the scope of the extended class and provides access to protected and private methods and properties. This makes any call using $this act on the extended class, not the class providing the extension.

If you use a scoped callback, you can provide the "outer" scope - or the scope of the class providing the extension, with the third parameter. The outer scope object will then be passed as the single parameter to the closure.

Parameters
Property Description
$callback
callable
$scoped
boolean
$outerScope
mixed
Returns
void

inherited public extendableCall (string $name, array $params = null) : mixed

Inherited from ComponentBase

Magic method for __call().

Callback priority is as follows:

  • "Dynamic Methods" added locally to the object via addDynamicMethod($name, $callable)
  • Methods available on Behaviors that have been implemented by the object
  • Pass it to the parent's __call() method if it defines one
Parameters
Property Description
$name
string
$params
array
Returns
mixed

inherited public static extendableCallStatic (string $name, array $params = null) : mixed

Inherited from ComponentBase

Magic method for __callStatic()

Parameters
Property Description
$name
string
$params
array
Returns
mixed

inherited public extendableConstruct ()

Inherited from ComponentBase

This method should be called as part of the constructor.

Returns
mixed

inherited public static extendableExtendCallback (callable $callback, boolean $scoped = false, $outerScope = null) : void

Inherited from ComponentBase

Helper method for ::extend() static method.

Parameters
Property Description
$callback
callable
$scoped
boolean
$outerScope
mixed
Returns
void

inherited public extendableGet (string $name) : mixed | null

Inherited from ComponentBase

Magic method for __get()

Parameters
Property Description
$name
string
Returns
mixed | null

inherited public extendableSet (string $name, mixed $value) : void

Inherited from ComponentBase

Magic method for __set()

Parameters
Property Description
$name
string
$value
mixed
Returns
void

inherited public fireSystemEvent (string $event, array $params = [], boolean $halt = true) : mixed

Inherited from ComponentBase

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.

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
Property Description
$event
string

Event name

$params
array

Event parameters

$halt
boolean

Halt after first non-null result

Returns
mixed

inherited public fireViewEvent (string $event, array $params = []) : string

Inherited from ComponentBase

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

For example:

= $this->fireViewEvent('backend.auth.extendSigninView') ?>
Parameters
Property Description
$event
string

Event name

$params
array

Event parameters

Returns
string

inherited public flushAssets () : void

Inherited from ComponentBase

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.

Returns
void

inherited public getAssetPath (string $fileName, $assetPath = null) : string

Inherited from ComponentBase

Returns the URL to the provided asset. If the provided fileName is a relative path without a leading slash it will be assumbed to be relative to the asset path.

Parameters
Property Description
$fileName
string
$assetPath
mixed
Returns
string

inherited public getAssetPaths () : array

Inherited from ComponentBase

Returns an array of all registered asset paths.

Assets will be prioritized based on their defined ordering.

Returns
array

inherited public getClassExtension (string $name) : mixed

Inherited from ComponentBase

Returns a behavior object from an extendable class, example:

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

Parameters
Property Description
$name
string

Fully qualified behavior name

Returns
mixed

inherited public getClassMethods () : array

Inherited from ComponentBase

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

Returns
array

inherited public getDynamicProperties () : array

Inherited from ComponentBase

Returns all dynamic properties and their values

Returns
array

['property' => 'value']

inherited public getPath ()

Inherited from ComponentBase

Returns the absolute component path.

Returns
mixed

inherited public getProperties () : array

Inherited from ComponentBase

Returns all properties.

Returns
array

inherited public getPropertyOptions (string $property) : array

Inherited from ComponentBase

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

Parameters
Property Description
$property
string

Specifies the property name

Returns
array

Return an array of option values and descriptions

inherited public hasAssetsDefined () : bool

Inherited from ComponentBase

Returns true if assets any have been added.

Returns
bool

inherited public isClassExtendedWith (string $name) : bool

Inherited from ComponentBase

Check if extendable class is extended with a behavior object

Parameters
Property Description
$name
string

Fully qualified behavior name

Returns
bool

inherited public makeAssets ($type = null) : string | null

Inherited from ComponentBase

Outputs <link> and <script> tags to load assets previously added with addJs, addCss, & addRss method calls depending on the provided $type

Parameters
Property Description
$type
mixed
Returns
string | null

inherited public methodExists (string $name) : bool

Inherited from ComponentBase

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

Parameters
Property Description
$name
string
Returns
bool

inherited public onRender ()

Inherited from ComponentBase

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

Returns
mixed

inherited public orderAssets (array $assets) : array

Inherited from ComponentBase

Prioritize assets based on the given order.

Parameters
Property Description
$assets
array
Returns
array

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

Inherited from ComponentBase

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

Otherwise the default value specified is returned.

Parameters
Property Description
$name
string

The property name

$default
mixed
Returns
string

inherited public property (string $name, string $default = null) : mixed

Inherited from ComponentBase

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

Parameters
Property Description
$name
string

The property name to look for.

$default
string

A default value to return if no name is found.

Returns
mixed

The property value or the default specified.

inherited public propertyExists (string $name) : bool

Inherited from ComponentBase

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

Parameters
Property Description
$name
string
Returns
bool

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

Inherited from ComponentBase

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

Otherwise the default value specified is returned.

Parameters
Property Description
$name
string

The property name

$default
mixed
Returns
string

inherited public renderPartial ()

Inherited from ComponentBase

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

Returns
mixed

inherited public runAjaxHandler ($handler) : bool

Inherited from ComponentBase

Executes the event cycle when running an AJAX handler.

Parameters
Property Description
$handler
mixed
Returns
bool

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

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

Inherited from ComponentBase

Sets an external property name.

Parameters
Property Description
$name
string

Property name

$extName
string

External property name

Returns
string

inherited public setExternalPropertyNames (array $names) : void

Inherited from ComponentBase

Sets names used by external properties.

Parameters
Property Description
$names
array

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

Returns
void

inherited public setProperties (array $properties) : void

Inherited from ComponentBase

Sets multiple properties.

Parameters
Property Description
$properties
array
Returns
void

inherited public setProperty (string $name, mixed $value) : void

Inherited from ComponentBase

Sets a property value

Parameters
Property Description
$name
string
$value
mixed
Returns
void

inherited public validateProperties (array $properties) : array

Inherited from ComponentBase

Validates the properties against the defined properties of the class.

This method also sets default properties.

Parameters
Property Description
$properties
array

The supplied property values.

Returns
array

The validated property set, with defaults applied.

inherited protected addAsset (string $type, string $path, array $attributes) : void

Inherited from ComponentBase

Adds the provided asset to the internal asset collections

Parameters
Property Description
$type
string
$path
string
$attributes
array
Returns
void

inherited protected extendableAddLocalExtension (Closure $callback, $outerScope = null)

Inherited from ComponentBase

Adds local extensibility to the current instance.

This rebinds a given closure to the current instance, making it able to access protected and private methods. This makes any call using $this within the closure act on the extended class, not the class providing the extension.

An outer scope may be provided by providing a second parameter, which will then be passed through to the closure as its first parameter. If this is not given, the current instance will be provided as the first parameter.

Parameters
Property Description
$callback
Closure
$outerScope
mixed
Returns
mixed

inherited protected extendableIsAccessible (mixed $class, string $propertyName) : bool

Inherited from ComponentBase

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

Parameters
Property Description
$class
mixed
$propertyName
string
Returns
bool

inherited protected extensionCallMethod (ReflectionClass $class, string $method, array $params)

Inherited from ComponentBase

Calls a method through reflection.

Parameters
Property Description
$class
ReflectionClass
$method
string
$params
array
Returns
mixed

inherited protected extensionExtractMethods (string $extensionName, object $extensionObject) : void

Inherited from ComponentBase

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

Parameters
Property Description
$extensionName
string
$extensionObject
object
Returns
void

inherited protected extensionGetClassLoader () : Winter\Storm\Support\ClassLoader | null

Inherited from ComponentBase

Gets the class loader

Returns
Winter\Storm\Support\ClassLoader | null

inherited protected extensionGetParentClass ($instance = null) : ReflectionClass | false

Inherited from ComponentBase

Gets the parent class using reflection.

The parent class must either not be the Extendable class, or must not be using the ExtendableTrait trait, in order to prevent infinite loops.

Parameters
Property Description
$instance
mixed
Returns
ReflectionClass | false

inherited protected extensionMethodExists (ReflectionClass $class, string $methodName) : bool

Inherited from ComponentBase

Determines if the given class reflection contains the given method.

Parameters
Property Description
$class
ReflectionClass
$methodName
string
Returns
bool

inherited protected extensionNormalizeClassName (string $name) : string

Inherited from ComponentBase

Normalizes the provided extension name allowing for the ClassLoader to inject aliased classes

Parameters
Property Description
$name
string
Returns
string

inherited protected getAssetEntryBuildPath (array $asset) : string

Inherited from ComponentBase

Internal helper, attaches a build code to an asset path

Parameters
Property Description
$asset
array
Returns
string

inherited protected getAssetScheme (string $asset) : string

Inherited from ComponentBase

Internal helper, get asset scheme

Parameters
Property Description
$asset
string
Returns
string

inherited protected getLocalPath (string | null $relativePath) : string

Inherited from ComponentBase
Parameters
Property Description
$relativePath
string | null
Returns
string

inherited protected removeDuplicates () : void

Inherited from ComponentBase

Removes duplicate assets from the entire collection.

Returns
void
Copyright © 2024 Winter CMS