October\Rain\Extension\Extendable
Overview
Extendable class
If a class extends this class, it will enable support for using "Private traits".
Usage:
public $implement = [\Path\To\Some\Namespace\Class::class];
See the ExtensionBase class for creating extension classes.
Public Properties
public array $implement
implement extensions for this class.
Protected Properties
protected array $extensionData
extensionData contains class reflection information, including behaviors
protected static array $extendableStaticMethods
extendableStaticMethods is a collection of static methods used by behaviors
Public Methods
public __call()
public __call($name, $params): void
__call calls an undefined local method
public static __callStatic()
public static __callStatic($name, $params): void
__callStatic calls an undefined static method
public __construct()
public __construct(): void
__construct the extendable class
public __get()
public __get($name): void
__get an undefined property
public __set()
public __set($name, $value): void
__set an undefined property
public __sleep()
public __sleep(): void
__sleep prepare the object for serialization.
public __wakeup()
public __wakeup(): void
__wakeup when a model is being unserialized, check if it needs to be booted.
public addDynamicMethod()
public addDynamicMethod(
string $dynamicName,
callable $method,
string $extension = null
): void
addDynamicMethod programmatically adds a method to the extendable class
public addDynamicProperty()
public addDynamicProperty(string $dynamicName, string $value = null): void
addDynamicProperty programmatically adds a property to the extendable class
public asExtension()
public asExtension(string $shortName): mixed
asExtension is short hand for getClassExtension() method, except takes the short
extension name, example:
$this->asExtension('FormController')
public static clearExtendedClasses()
public static clearExtendedClasses(): void
public static extend()
public static extend($callback): void
extend this class with a closure
public extendClassWith()
public extendClassWith(string $extensionName): void
extendClassWith dynamically extends a class with a specified behavior
public extendableCall()
public extendableCall(string $name, array $params = null): mixed
extendableCall magic method for __call()
public static extendableCallStatic()
public static extendableCallStatic(
string $name,
array $params = null
): mixed
extendableCallStatic magic method for __callStatic()
public extendableConstruct()
public extendableConstruct(): void
extendableConstruct should be called as part of the constructor
public extendableDestruct()
public extendableDestruct(): void
extendableDestruct should be called when serializing the object
public static extendableExtendCallback()
public static extendableExtendCallback(callable $callback): void
extendableExtendCallback is a helper method for ::extend() static method
public extendableGet()
public extendableGet(string $name): string
extendableGet magic method for __get()
public extendableSet()
public extendableSet(string $name, string $value): string
extendableSet magic method for __set()
public getClassExtension()
public getClassExtension(string $name): mixed
getClassExtension returns a behavior object from an extendable class, example:
$this->getClassExtension('Backend.Behaviors.FormController')
public getClassMethodAsReflector()
public getClassMethodAsReflector($name): ReflectionFunctionAbstract
public getClassMethods()
public getClassMethods(): array
getClassMethods gets a list of class methods, extension equivalent of get_class_methods()
public getDynamicProperties()
public getDynamicProperties(): array
getDynamicProperties returns all dynamic properties and their values
public implementClassWith()
public implementClassWith($extensionName): void
implementClassWith will implement an extension using non-interference and should be used with the static extend() method.
public isClassExtendedWith()
public isClassExtendedWith(string $name): boolean
isClassExtendedWith checks if extendable class is extended with a behavior object
public isClassInstanceOf()
public isClassInstanceOf($interface): bool
isClassInstanceOf checks if the class implements the supplied interface methods.
public methodExists()
public methodExists(string $name): boolean
methodExists checks if a method exists, extension equivalent of method_exists()
public propertyExists()
public propertyExists(string $name): boolean
propertyExists checks if a property exists, extension equivalent of property_exists()
Protected Methods
protected extendableIsAccessible()
protected extendableIsAccessible(
mixed $class,
string $propertyName
): boolean
extendableIsAccessible checks if a property is accessible, property equivalent
of is_callable()
protected extensionExtractImplements()
protected extensionExtractImplements(): array
extensionExtractImplements will return classes to implement.
protected extensionExtractMethods()
protected extensionExtractMethods(
string $extensionName,
object $extensionObject
): void
extensionExtractMethods extracts the available methods from a behavior and adds it to the list of callable methods
protected getExtendableMethodFromDynamicMethods()
protected getExtendableMethodFromDynamicMethods($name): callable|null
protected getExtendableMethodFromExtensions()
protected getExtendableMethodFromExtensions($name): array|null