UnknownComponent
class Cms\Components\UnknownComponent
extends Cms\Classes\ComponentBase
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
protected $errorMessage : string
Error message that is shown with this error component.
public $alias : string
Alias used for this component.
public $assetPath : string
Specifies a path to the asset directory.
public $componentCssClass : string
Component CSS class name for the back-end page/layout component list. This field is used by the CMS internally.
public $id : string
A unique identifier for this component.
public
$implement
:
string
|
array
|
null
= null
Extensions implemented by this class.
public
$inspectorEnabled
:
bool
= true
Determines whether Inspector can be used with the component. This field is used by the CMS internally.
public
$isHidden
:
bool
= false
Determines whether the component is hidden from the back-end UI.
public $name : string
Component class name or class alias used in the component declaration in a template.
public $pluginIcon : string
Icon of the plugin that defines the component. This field is used by the CMS internally.
protected
$assets
:
array
= {"js":[],"css":[],"rss":[]}
Collection of assets to display in the layout.
protected $controller : Cms\Classes\Controller
Controller object.
protected $dirName : string
Specifies the component directory name.
protected
static
$extendableCallbacks
:
array
= []
Used to extend the constructor of an extendable class. Eg:
Class::extend(function($obj) { })
protected
static
$extendableClassLoader
:
ClassLoader
|
null
= null
Class loader instance.
protected
static
$extendableGuardProperties
:
bool
= true
Indicates if dynamic properties can be created.
protected
static
$extendableStaticMethods
:
array
= []
Collection of static methods used by behaviors.
protected
$extensionData
:
array
= {"extensions":[],"methods":[],"dynamicMethods":[],"dynamicProperties":[]}
Class reflection information, including behaviors.
protected
$externalPropertyNames
:
array
= []
A collection of external property names used by this component.
protected $page : Cms\Classes\PageCode
Page object object.
protected
$properties
:
array
= []
Contains the object property values.
Methods
public __construct ($cmsObject, $properties, $errorMessage)
Component constructor. Takes in the page or layout code section object and properties set by the page or layout.
Property | Type | Description |
---|---|---|
$cmsObject | mixed |
mixed
|
$properties | mixed |
mixed
|
$errorMessage | mixed |
mixed
|
public componentDetails () : array
public __call (string $method, array $parameters) : mixed
Dynamically handle calls into the controller instance.
Property | Type | Description |
---|---|---|
$method | string |
string
|
$parameters | array |
array
|
public static __callStatic ($name, $params)
Property | Type | Description |
---|---|---|
$name | mixed |
mixed
|
$params | mixed |
mixed
|
public __get ($name)
Property | Type | Description |
---|---|---|
$name | mixed |
mixed
|
public __set ($name, $value)
Property | Type | Description |
---|---|---|
$name | mixed |
mixed
|
$value | mixed |
mixed
|
public __toString ()
Returns the component's alias, used by SELF
public
addCss (array | string $name, array $attributes = []
)
: void
Adds StyleSheet asset to the asset list. Call $this->makeAssets() in a view to output corresponding markup.
Property | Type | Description |
---|---|---|
$name | array | string |
array | string
Specifies a path (URL) or an array of paths to the stylesheet(s). |
$attributes | array |
array
Adds extra HTML attributes to the asset link. |
public
addDynamicMethod (string $dynamicName, callable $method, string $extension = null
)
Programmatically adds a method to the extendable class
Property | Type | Description |
---|---|---|
$dynamicName | string |
string
|
$method | callable |
callable
|
$extension | string |
string
|
public
addDynamicProperty (string $dynamicName, mixed $value = null
)
: void
Programmatically adds a property to the extendable class
Property | Type | Description |
---|---|---|
$dynamicName | string |
string
The name of the property to add |
$value | mixed |
mixed
The value of the property |
public
addJs (array | string $name, array $attributes = []
)
: void
Adds JavaScript asset to the asset list. Call $this->makeAssets() in a view to output corresponding markup.
Property | Type | Description |
---|---|---|
$name | array | string |
array | string
Specifies a path (URL) or an array of paths to the script(s). |
$attributes | array |
array
Adds extra HTML attributes to the asset link. |
public
addRss (string $name, array $attributes = []
)
: void
Adds an RSS link asset to the asset list. Call $this->makeAssets() in a view to output corresponding markup.
Property | Type | Description |
---|---|---|
$name | string |
string
Specifies a path (URL) to the RSS channel |
$attributes | array |
array
Adds extra HTML attributes to the asset link. |
public asExtension (string $shortName) : mixed
Short hand for getClassExtension()
method, except takes the short
extension name, example:
$this->asExtension('FormController')
Property | Type | Description |
---|---|---|
$shortName | string |
string
|
public static clearExtendedClasses () : void
Clear the list of extended classes so they will be re-extended.
public
combineAssets (array $assets, string $localPath = ""
)
: string
Run the provided assets through the Asset Combiner
Property | Type | Description |
---|---|---|
$assets | array |
array
Collection of assets |
$localPath | string |
string
Prefix all assets with this path (optional) |
public defineProperties () : array
Defines the properties used by this class.
This method should be overriden in your extended class and return an array of properties that your class uses, with the keys of the array being the name of the properties, and the values being an array of property parameters.
Example: return [ 'propertyName' => [ 'title' => 'Property name', 'description' => 'Property description', 'default' => 'Default value' ], ];
public extendClassWith (string $extensionName) : void
Dynamically extend a class with a specified behavior
Property | Type | Description |
---|---|---|
$extensionName | string |
string
|
public
static
extendableAddExtension (callable $callback, boolean $scoped = false
, $outerScope = null
)
: void
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.
Property | Type | Description |
---|---|---|
$callback | callable |
callable
|
$scoped | boolean |
boolean
|
$outerScope | mixed |
mixed
|
public
extendableCall (string $name, array $params = null
)
: mixed
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
Property | Type | Description |
---|---|---|
$name | string |
string
|
$params | array |
array
|
public
static
extendableCallStatic (string $name, array $params = null
)
: mixed
Magic method for __callStatic()
Property | Type | Description |
---|---|---|
$name | string |
string
|
$params | array |
array
|
public extendableConstruct ()
This method should be called as part of the constructor.
public
static
extendableExtendCallback (callable $callback, boolean $scoped = false
, $outerScope = null
)
: void
Helper method for ::extend()
static method.
Property | Type | Description |
---|---|---|
$callback | callable |
callable
|
$scoped | boolean |
boolean
|
$outerScope | mixed |
mixed
|
public extendableGet (string $name) : mixed | null
Magic method for __get()
Property | Type | Description |
---|---|---|
$name | string |
string
|
public extendableSet (string $name, mixed $value) : void
Magic method for __set()
Property | Type | Description |
---|---|---|
$name | string |
string
|
$value | mixed |
mixed
|
public
fireSystemEvent (string $event, array $params = []
, boolean $halt = true
)
: 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.
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);
Property | Type | Description |
---|---|---|
$event | string |
string
Event name |
$params | array |
array
Event parameters |
$halt | boolean |
boolean
Halt after first non-null result |
public
fireViewEvent (string $event, array $params = []
)
: string
Special event function used for extending within view files, allowing HTML to be injected multiple times.
For example:
= $this->fireViewEvent('backend.auth.extendSigninView') ?>Property | Type | Description |
---|---|---|
$event | string |
string
Event name |
$params | array |
array
Event parameters |
public 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.
public
getAssetPath (string $fileName, string $assetPath = null
)
: 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.
Property | Type | Description |
---|---|---|
$fileName | string |
string
File to load. |
$assetPath | string |
string
Explicitly define an asset path. |
Relative path to the asset file.
public getAssetPaths () : array
Returns an array of all registered asset paths.
public getClassExtension (string $name) : mixed
Returns a behavior object from an extendable class, example:
$this->getClassExtension('Backend.Behaviors.FormController')
Property | Type | Description |
---|---|---|
$name | string |
string
Fully qualified behavior name |
public getClassMethods () : array
Get a list of class methods, extension equivalent of get_class_methods()
public getDynamicProperties () : array
Returns all dynamic properties and their values
['property' => 'value']
public getPath ()
Returns the absolute component path.
public getProperties () : array
Returns all properties.
public getPropertyOptions (string $property) : array
Returns options for multi-option properties (drop-downs, etc.)
Property | Type | Description |
---|---|---|
$property | string |
string
Specifies the property name |
Return an array of option values and descriptions
public hasAssetsDefined () : bool
Returns true if assets any have been added.
public init ()
Executed when this component is first initialized, before AJAX requests.
public isClassExtendedWith (string $name) : bool
Check if extendable class is extended with a behavior object
Property | Type | Description |
---|---|---|
$name | string |
string
Fully qualified behavior name |
public
makeAssets ($type = null
)
: string | null
Outputs <link>
and <script>
tags to load assets previously added
with addJs, addCss, & addRss method calls depending on the provided $type
Property | Type | Description |
---|---|---|
$type | mixed |
mixed
|
public methodExists (string $name) : bool
Checks if a method exists, extension equivalent of method_exists()
Property | Type | Description |
---|---|---|
$name | string |
string
|
public onRender ()
Executed when this component is rendered on a page or layout.
public onRun ()
Executed when this component is bound to a page or layout, part of the page life cycle.
public
paramName (string $name, mixed $default = null
)
: string
Returns the external property name when the property value is a routing parameter reference.
Otherwise the default value specified is returned.
Property | Type | Description |
---|---|---|
$name | string |
string
The property name |
$default | mixed |
mixed
|
public
property (string $name, string $default = null
)
: mixed
Returns a defined property value or default if one is not set.
Property | Type | Description |
---|---|---|
$name | string |
string
The property name to look for. |
$default | string |
string
A default value to return if no name is found. |
The property value or the default specified.
public propertyExists (string $name) : bool
Checks if a property exists, extension equivalent of property_exists()
Property | Type | Description |
---|---|---|
$name | string |
string
|
public
propertyName (string $name, mixed $default = null
)
: string
Returns the external property name when the property value is an external property reference.
Otherwise the default value specified is returned.
Property | Type | Description |
---|---|---|
$name | string |
string
The property name |
$default | mixed |
mixed
|
public renderPartial ()
Renders a requested partial in context of this component, see Cms\Classes\Controller@renderPartial for usage.
public runAjaxHandler ($handler) : bool
Executes the event cycle when running an AJAX handler.
Property | Type | Description |
---|---|---|
$handler | mixed |
mixed
|
Returns true if the handler was found. Returns false otherwise.
public setExternalPropertyName (string $name, string $extName) : string
Sets an external property name.
Property | Type | Description |
---|---|---|
$name | string |
string
Property name |
$extName | string |
string
External property name |
public setExternalPropertyNames (array $names) : void
Sets names used by external properties.
Property | Type | Description |
---|---|---|
$names | array |
array
The key should be the property name, the value should be the external property name. |
public setProperties (array $properties) : void
Sets multiple properties.
Property | Type | Description |
---|---|---|
$properties | array |
array
|
public setProperty (string $name, mixed $value) : void
Sets a property value
Property | Type | Description |
---|---|---|
$name | string |
string
|
$value | mixed |
mixed
|
public validateProperties (array $properties) : array
Validates the properties against the defined properties of the class.
This method also sets default properties.
Property | Type | Description |
---|---|---|
$properties | array |
array
The supplied property values. |
The validated property set, with defaults applied.
protected addAsset (string $type, string $path, array $attributes)
Adds the provided asset to the internal asset collections
Property | Type | Description |
---|---|---|
$type | string |
string
The type of the asset: 'js' || 'css' || 'rss' |
$path | string |
string
The path to the asset |
$attributes | array |
array
The attributes for the asset |
protected
extendableAddLocalExtension (Closure $callback, $outerScope = null
)
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.
Property | Type | Description |
---|---|---|
$callback | Closure |
Closure
|
$outerScope | mixed |
mixed
|
protected extendableIsAccessible (mixed $class, string $propertyName) : bool
Checks if a property is accessible, property equivalent of is_callable()
Property | Type | Description |
---|---|---|
$class | mixed |
mixed
|
$propertyName | string |
string
|
protected extensionExtractMethods (string $extensionName, object $extensionObject) : void
Extracts the available methods from a behavior and adds it to the list of callable methods.
Property | Type | Description |
---|---|---|
$extensionName | string |
string
|
$extensionObject | object |
object
|
protected extensionGetClassLoader () : Winter\Storm\Support\ClassLoader | null
Gets the class loader
protected extensionNormalizeClassName (string $name) : string
Normalizes the provided extension name allowing for the ClassLoader to inject aliased classes
Property | Type | Description |
---|---|---|
$name | string |
string
|
protected getAssetEntryBuildPath (array $asset) : string
Internal helper, attaches a build code to an asset path
Property | Type | Description |
---|---|---|
$asset | array |
array
Stored asset array |
protected getAssetScheme (string $asset) : string
Internal helper, get asset scheme
Property | Type | Description |
---|---|---|
$asset | string |
string
Specifies a path (URL) to the asset. |
protected getLocalPath (string | null $relativePath)
Property | Type | Description |
---|---|---|
$relativePath | string | null |
string | null
|
protected removeDuplicates () : void
Removes duplicate assets from the entire collection.