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.

 trait Winter\Storm\Extension\ExtendableTrait

Properties

protected static $extendableCallbacks : array

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

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

protected static $extendableClassLoader : ClassLoader | null

Class loader instance.

protected static $extendableStaticMethods : array

Collection of static methods used by behaviors.

protected $extensionData : array

Class reflection information, including behaviors.

Methods

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

Programmatically adds a method to the extendable class

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

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

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

public asExtension (string $shortName) : mixed

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

$this->asExtension('FormController')

Parameters
Property Description
$shortName
string
Returns
mixed

public static clearExtendedClasses () : void

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

Returns
void

public extendClassWith (string $extensionName) : void

Dynamically extend a class with a specified behavior

Parameters
Property Description
$extensionName
string
Returns
void

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
Parameters
Property Description
$name
string
$params
array
Returns
mixed

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

Magic method for __callStatic()

Parameters
Property Description
$name
string
$params
array
Returns
mixed

public extendableConstruct ()

This method should be called as part of the constructor.

Returns
mixed

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

Helper method for ::extend() static method.

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

public extendableGet (string $name) : mixed | null

Magic method for __get()

Parameters
Property Description
$name
string
Returns
mixed | null

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

Magic method for __set()

Parameters
Property Description
$name
string
$value
mixed
Returns
void

public getClassExtension (string $name) : mixed

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

public getClassMethods () : array

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

Returns
array

public getDynamicProperties () : array

Returns all dynamic properties and their values

Returns
array

['property' => 'value']

public isClassExtendedWith (string $name) : bool

Check if extendable class is extended with a behavior object

Parameters
Property Description
$name
string

Fully qualified behavior name

Returns
bool

public methodExists (string $name) : bool

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

Parameters
Property Description
$name
string
Returns
bool

public propertyExists (string $name) : bool

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

Parameters
Property Description
$name
string
Returns
bool

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

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

Parameters
Property Description
$class
mixed
$propertyName
string
Returns
bool

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

Calls a method through reflection.

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

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

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

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

Gets the class loader

Returns
Winter\Storm\Support\ClassLoader | null

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.

Parameters
Property Description
$instance
mixed
Returns
ReflectionClass | false

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

Determines if the given class reflection contains the given method.

Parameters
Property Description
$class
ReflectionClass
$methodName
string
Returns
bool

protected extensionNormalizeClassName (string $name) : string

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

Parameters
Property Description
$name
string
Returns
string

Used by

Class Description
EventLogs

Event Logs controller

MailBrandSettings

Mail brand customization controller

MailLayouts

Mail layouts controller

MailPartials

Mail partials controller

MailTemplates

Mail templates controller

RequestLogs

Request Logs controller

Settings

Settings controller

Updates

Updates controller

File

File attachment model

Parameter

Parameters model Used for storing internal application parameters.

Revision

Revision history model

Status

System status report widget.

BackendController

This is the master controller for all back-end pages.

Controller

The Backend base controller class, used by Backend controllers.

FormWidgetBase

Form Widget base class Widgets used specifically for forms

ReportWidgetBase

Report Widget base class Report widgets are used inside the ReportContainer.

WidgetBase

Widget base class.

AccessLogs

Access Logs controller

Auth

Authentication controller

Files

Backend files controller

Index

Dashboard controller

Media

Backend Media Manager

Preferences

Editor Settings controller

UserGroups

Backend user groups controller

UserRoles

Backend user groups controller

Users

Backend user controller

CodeEditor

Code Editor Renders a code editor field.

ColorPicker

Color picker Renders a color picker field.

DataTable

Data Table Renders a table field.

DatePicker

Date picker Renders a date picker field.

FileUpload

File upload field Renders a form file uploader field.

IconPicker

Icon picker Renders an icon picker field.

MarkdownEditor

Code Editor Renders a code editor field.

MediaFinder

Media Finder Renders a record finder field.

NestedForm

Nested Form Renders a nested form bound to a jsonable field of a model.

PermissionEditor

User/group permission editor This widget is used by the system internally on the System / Administrators pages.

RecordFinder

Record Finder Renders a record finder field.

Relation

Form Relationship Renders a field prepopulated with a belongsTo and belongsToHasMany relation.

RelationManager
Repeater

Repeater Form Widget

RichEditor

Rich Editor Renders a rich content editor field.

Sensitive

Sensitive widget.

TagList

Tag List Form Widget

User

Administrator user model

UserGroup

Administrator group

UserPreference

All preferences for the backend user

UserRole

Administrator role

UserThrottle

Administrator throttling model

Welcome

User welcome report widget.

Filter

Filter Widget Renders a container used for filtering things.

Form

Form Widget Used for building back end forms and renders a form.

Lists

List Widget Used for building back end lists, renders a list of model objects

MediaManager

Media Manager widget.

ReportContainer

Report Container Widget Creates an area hosting report widgets.

Search

Search Widget Used for building a toolbar, Renders a search container.

Table

Table Widget.

Toolbar

Toolbar Widget Used for building a toolbar, renders a toolbar.

Asset

The CMS theme asset file class.

CmsCompoundObject

This is a base class for CMS objects that have multiple sections - pages, partials and layouts.

CmsController

This is the master controller for all front-end pages.

CmsObject

This is a base class for all CMS objects - content files, pages, partials and layouts.

CodeBase

Parent class for PHP classes created for layout and page code sections.

ComponentBase

Component base class

ComponentPartial

The CMS component partial class. These objects are read-only.

Content

The CMS content file class.

Layout

The CMS layout class.

LayoutCode

Parent class for PHP classes created for layout PHP sections.

Meta

The CMS meta file class, used for interacting with YAML files within the Halcyon datasources

Page

The CMS page class.

PageCode

Parent class for PHP classes created for page PHP sections.

Partial

The CMS partial class.

PartialCode

Parent class for PHP classes created for partial PHP sections.

Theme

This class represents the CMS theme.

Resources

Resources component

SoftComponent
UnknownComponent
ViewBag

The view bag stores custom template properties.

Index

CMS index

Media

CMS Media Manager

ThemeLogs

Request Logs controller

ThemeOptions

Theme customization controller

Themes

Theme selector controller

Components

Component Builder Builds a collection of Cms components and configures them.

MediaFinder

Media Finder Renders a record finder field.

ActiveTheme

Active theme report widget.

AssetList

CMS asset list widget.

ComponentList

Component list widget.

MediaManager

Media Manager widget.

TemplateList

Template list widget.

Group

Group model

Preferences

User Preferences model

Role

Role model

Throttle

Throttle model

User

User model

File

File attachment model

Model

Active Record base class.

DeferredBinding

Deferred Binding Model

Revision

Revision Model

MorphPivot

Reimplementation of \Illuminate\Database\Eloquent\Relations\MorphPivot but extends Winter's Pivot base class instead of Laravel's to get access to Winter magic.

Pivot
Extendable

Extension class

Model

This is a base template object. Equivalent to a Model in ORM.

Copyright © 2024 Winter CMS