SoftComponent
class Cms\Components\SoftComponent
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
protected $message : string
Message that is shown with this component.
inherited public $alias : string
Alias used for this component.
inherited public $assetPath : string
Specifies a path to the asset directory.
inherited public $componentCssClass : string
Component CSS class name for the back-end page/layout component list. This field is used by the CMS internally.
inherited public $id : string
A unique identifier for this component.
inherited
public
$implement
:
string
|
array
|
null
= null
Extensions implemented by this class.
inherited
public
$inspectorEnabled
:
bool
= true
Determines whether Inspector can be used with the component. This field is used by the CMS internally.
inherited
public
$isHidden
:
bool
= false
Determines whether the component is hidden from the back-end UI.
inherited public $name : string
Component class name or class alias used in the component declaration in a template.
inherited public $pluginIcon : string
Icon of the plugin that defines the component. This field is used by the CMS internally.
inherited
protected
$assets
:
array
= {"js":[],"css":[],"rss":[],"vite":[]}
Collection of assets to display in the layout.
inherited protected $controller : Cms\Classes\Controller
Controller object.
inherited protected $dirName : string
Specifies the component directory name.
inherited
protected
static
$extendableCallbacks
:
array
= []
Used to extend the constructor of an extendable class. Eg:
Class::extend(function($obj) { })
inherited
protected
static
$extendableClassLoader
:
ClassLoader
|
null
= null
Class loader instance.
inherited
protected
$extendableConstructed
:
bool
= false
Indicates if the extendable constructor has completed.
inherited
protected
static
$extendableStaticMethods
:
array
= []
Collection of static methods used by behaviors.
inherited
protected
$extensionData
:
array
= {"extensions":[],"methods":[],"dynamicMethods":[],"dynamicProperties":[]}
Class reflection information, including behaviors.
inherited
protected
$externalPropertyNames
:
array
= []
A collection of external property names used by this component.
inherited
protected
$localCallbacks
:
array
= []
This stores any locally-scoped callbacks fired before the extendable constructor had completed.
inherited protected $orderFactor : integer
Ensures "first-come, first-served" applies to assets of the same ordering.
inherited protected $page : Cms\Classes\PageCode
Page object object.
inherited
protected
$properties
:
array
= []
Contains the object property values.
Methods
public __construct ($properties)
Component constructor. Takes in the page or layout code section object and properties set by the page or layout.
Property | Type | Description |
---|---|---|
$properties | mixed |
mixed
|
public componentDetails () : array
inherited public __call (string $method, array $parameters) : mixed
Dynamically handle calls into the controller instance.
Property | Type | Description |
---|---|---|
$method | string |
string
|
$parameters | array |
array
|
inherited public static __callStatic ($name, $params)
Property | Type | Description |
---|---|---|
$name | mixed |
mixed
|
$params | mixed |
mixed
|
inherited public __get ($name)
Property | Type | Description |
---|---|---|
$name | mixed |
mixed
|
inherited public __set ($name, $value)
Property | Type | Description |
---|---|---|
$name | mixed |
mixed
|
$value | mixed |
mixed
|
inherited public __toString ()
Returns the component's alias, used by SELF
inherited
public
addCss (string | array $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 | string | array |
string | array
When an array of paths are provided they will be passed to the Asset Combiner |
$attributes | array |
array
When a string is provided it will be used as the 'build' attribute value |
inherited
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
|
inherited
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 |
inherited
public
addJs (string | array $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 | string | array |
string | array
When an array of paths are provided they will be passed to the Asset Combiner |
$attributes | array |
array
When a string is provided it will be used as the 'build' attribute value |
inherited
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
|
$attributes | array |
array
|
inherited
public
addVite (array | string $entrypoints, ?string $package = null
)
: void
Adds Vite tags
Property | Type | Description |
---|---|---|
$entrypoints | array | string |
array | string
The list of entry points for Vite |
$package | ?string |
?string
The package name of the plugin or theme |
inherited 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
|
inherited public static clearExtendedClasses () : void
Clear the list of extended classes so they will be re-extended.
inherited
public
combineAssets (array $assets, string $localPath = ""
)
: string
Run the provided assets through the Asset Combiner
Property | Type | Description |
---|---|---|
$assets | array |
array
|
$localPath | string |
string
|
inherited 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' ], ];
inherited public extendClassWith (string $extensionName) : void
Dynamically extend a class with a specified behavior
Property | Type | Description |
---|---|---|
$extensionName | string |
string
|
inherited
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
|
inherited
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
|
inherited
public
static
extendableCallStatic (string $name, array $params = null
)
: mixed
Magic method for __callStatic()
Property | Type | Description |
---|---|---|
$name | string |
string
|
$params | array |
array
|
inherited public extendableConstruct ()
This method should be called as part of the constructor.
inherited
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
|
inherited public extendableGet (string $name) : mixed | null
Magic method for __get()
Property | Type | Description |
---|---|---|
$name | string |
string
|
inherited public extendableSet (string $name, mixed $value) : void
Magic method for __set()
Property | Type | Description |
---|---|---|
$name | string |
string
|
$value | mixed |
mixed
|
inherited
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 |
inherited
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 |
inherited 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.
inherited
public
getAssetPath (string $fileName, $assetPath = null
)
: string
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.
Property | Type | Description |
---|---|---|
$fileName | string |
string
|
$assetPath | mixed |
mixed
|
inherited public getAssetPaths () : array
Returns an array of all registered asset paths.
Assets will be prioritized based on their defined ordering.
inherited 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 |
inherited public getClassMethods () : array
Get a list of class methods, extension equivalent of get_class_methods()
inherited public getDynamicProperties () : array
Returns all dynamic properties and their values
['property' => 'value']
inherited public getPath ()
Returns the absolute component path.
inherited public getProperties () : array
Returns all properties.
inherited 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
inherited public hasAssetsDefined () : bool
Returns true if assets any have been added.
inherited public init ()
Executed when this component is first initialized, before AJAX requests.
inherited 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 |
inherited
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
|
inherited public methodExists (string $name) : bool
Checks if a method exists, extension equivalent of method_exists()
Property | Type | Description |
---|---|---|
$name | string |
string
|
inherited public onRender ()
Executed when this component is rendered on a page or layout.
inherited public onRun ()
Executed when this component is bound to a page or layout, part of the page life cycle.
inherited public orderAssets (array $assets) : array
Prioritize assets based on the given order.
Property | Type | Description |
---|---|---|
$assets | array |
array
|
inherited
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
|
inherited
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.
inherited public propertyExists (string $name) : bool
Checks if a property exists, extension equivalent of property_exists()
Property | Type | Description |
---|---|---|
$name | string |
string
|
inherited
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
|
inherited public renderPartial ()
Renders a requested partial in context of this component, see Cms\Classes\Controller@renderPartial for usage.
inherited 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.
inherited 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 |
inherited 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. |
inherited public setProperties (array $properties) : void
Sets multiple properties.
Property | Type | Description |
---|---|---|
$properties | array |
array
|
inherited public setProperty (string $name, mixed $value) : void
Sets a property value
Property | Type | Description |
---|---|---|
$name | string |
string
|
$value | mixed |
mixed
|
inherited 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.
inherited protected addAsset (string $type, string $path, array $attributes) : void
Adds the provided asset to the internal asset collections
Property | Type | Description |
---|---|---|
$type | string |
string
|
$path | string |
string
|
$attributes | array |
array
|
inherited
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
|
inherited 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
|
inherited protected extensionCallMethod (ReflectionClass $class, string $method, array $params)
Calls a method through reflection.
Property | Type | Description |
---|---|---|
$class | ReflectionClass |
ReflectionClass
|
$method | string |
string
|
$params | array |
array
|
inherited 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
|
inherited protected extensionGetClassLoader () : Winter\Storm\Support\ClassLoader | null
Gets the class loader
inherited
protected
extensionGetParentClass ($instance = null
)
: ReflectionClass | false
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.
Property | Type | Description |
---|---|---|
$instance | mixed |
mixed
|
inherited protected extensionMethodExists (ReflectionClass $class, string $methodName) : bool
Determines if the given class reflection contains the given method.
Property | Type | Description |
---|---|---|
$class | ReflectionClass |
ReflectionClass
|
$methodName | string |
string
|
inherited protected extensionNormalizeClassName (string $name) : string
Normalizes the provided extension name allowing for the ClassLoader to inject aliased classes
Property | Type | Description |
---|---|---|
$name | string |
string
|
inherited protected getAssetEntryBuildPath (array $asset) : string
Internal helper, attaches a build code to an asset path
Property | Type | Description |
---|---|---|
$asset | array |
array
|
inherited protected getAssetScheme (string $asset) : string
Internal helper, get asset scheme
Property | Type | Description |
---|---|---|
$asset | string |
string
|
inherited protected getLocalPath (string | null $relativePath) : string
Property | Type | Description |
---|---|---|
$relativePath | string | null |
string | null
|
inherited protected removeDuplicates () : void
Removes duplicate assets from the entire collection.