PartialCode
Parent class for PHP classes created for partial PHP sections.
class Cms\Classes\PartialCode
extends Cms\Classes\CodeBase
implements
ArrayAccess
Traits
Trait | Description |
---|---|
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. |
Properties
public $controller : Cms\Classes\controller
Specifies the CMS controller
public
$implement
:
string
|
array
|
null
= null
Extensions implemented by this class.
public $layout : Cms\Classes\Layout
Specifies the current layout
public $page : Cms\Classes\Page
Specifies the current page
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.
Methods
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 __construct (Cms\Classes\Page $page, Cms\Classes\Layout $layout, Cms\Classes\Controller $controller)
Creates the object instance.
Property | Type | Description |
---|---|---|
$page | Cms\Classes\Page |
Specifies the CMS page. |
$layout | Cms\Classes\Layout |
Specifies the CMS layout. |
$controller | Cms\Classes\Controller |
Specifies the CMS controller. |
public __get (string $name) : void
This object is referenced as $this->page in Cms\Classes\ComponentBase, so to avoid $this->page->page this method will proxy there. This is also used as a helper for accessing controller variables/components easier in the page code, eg. $this->foo instead of $this['foo']
Property | Type | Description |
---|---|---|
$name | string |
string
|
public __isset (string $name) : bool
This will check if a property is set on the CMS Page object.
Property | Type | Description |
---|---|---|
$name | string |
string
|
public __set (string $name, mixed $value) : void
This will set a property on the CMS Page object.
Property | Type | Description |
---|---|---|
$name | string |
string
|
$value | mixed |
mixed
|
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 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 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 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 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 methodExists (string $name) : bool
Checks if a method exists, extension equivalent of method_exists()
Property | Type | Description |
---|---|---|
$name | string |
string
|
public offsetExists ($offset) : bool
ArrayAccess implementation
Property | Type | Description |
---|---|---|
$offset | mixed |
mixed
|
public offsetGet ($offset)
ArrayAccess implementation
Property | Type | Description |
---|---|---|
$offset | mixed |
mixed
|
public offsetSet ($offset, $value) : void
ArrayAccess implementation
Property | Type | Description |
---|---|---|
$offset | mixed |
mixed
|
$value | mixed |
mixed
|
public offsetUnset ($offset) : void
ArrayAccess implementation
Property | Type | Description |
---|---|---|
$offset | mixed |
mixed
|
public onEnd ()
This event is triggered in the end of the execution cycle, but before the page is displayed.
The layout's onEnd method triggers after the page's onEnd method.
public onInit ()
This event is triggered when all components are initialized and before AJAX is handled.
The layout's onInit method triggers before the page's onInit method.
public onStart ()
This event is triggered in the beginning of the execution cycle.
The layout's onStart method triggers before the page's onStart method.
public propertyExists (string $name) : bool
Checks if a property exists, extension equivalent of property_exists()
Property | Type | Description |
---|---|---|
$name | string |
string
|
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
|