ComponentPartial
extends Extendable
in package
implements
CmsObject
The CMS component partial class. These objects are read-only.
Tags
Interfaces, Classes and Traits
Table of Contents
- $content : string
- $fileName : string
- $implement : array<string|int, mixed>
- $mtime : string
- $allowedExtensions : array<string|int, mixed>
- $component : ComponentBase
- $defaultExtension : string
- $extendableCallbacks : array<string|int, mixed>
- $extendableGuardProperties : bool
- $extendableStaticMethods : array<string|int, mixed>
- $extensionData : array<string|int, mixed>
- $maxNesting : int
- __call() : mixed
- __callStatic() : mixed
- __construct() : mixed
- Creates an instance of the object and associates it with a CMS component.
- __get() : mixed
- __set() : mixed
- addDynamicMethod() : mixed
- Programmatically adds a method to the extendable class
- addDynamicProperty() : mixed
- Programmatically adds a property to the extendable class
- asExtension() : mixed
- Short hand for `getClassExtension()` method, except takes the short extension name, example:
- check() : bool
- Returns true if the specific component contains a matching partial.
- clearExtendedClasses() : void
- Clear the list of extended classes so they will be re-extended.
- extend() : mixed
- extendableCall() : mixed
- Magic method for `__call()`
- extendableCallStatic() : mixed
- Magic method for `__callStatic()`
- extendableConstruct() : mixed
- This method should be called as part of the constructor.
- extendableExtendCallback() : void
- Helper method for `::extend()` static method
- extendableGet() : string
- Magic method for `__get()`
- extendableSet() : string
- Magic method for `__set()`
- extendClassWith() : void
- Dynamically extend a class with a specified behavior
- find() : mixed|static
- Find a single template by its file name.
- getBaseFileName() : string
- Returns the file name without the extension.
- getClassExtension() : mixed
- Returns a behavior object from an extendable class, example:
- getClassMethods() : array<string|int, mixed>
- Get a list of class methods, extension equivalent of get_class_methods()
- getContent() : string
- Returns the file content.
- getDefaultExtension() : string
- Returns the default extension used by this template.
- getDynamicProperties() : array<string|int, mixed>
- Returns all dynamic properties and their values
- getFileName() : string
- Returns the file name.
- getFilePath() : string
- Returns the absolute file path.
- getTwigCacheKey() : string
- Returns the key used by the Twig cache.
- getTwigContent() : string
- Returns the Twig content string.
- isClassExtendedWith() : bool
- Check if extendable class is extended with a behavior object
- load() : mixed
- Loads the object from a file.
- loadCached() : mixed
- There is not much point caching a component partial, so this behavior reverts to a regular load call.
- loadOverrideCached() : mixed
- Checks if a partial override exists in the supplied theme and returns it.
- methodExists() : bool
- Checks if a method exists, extension equivalent of method_exists()
- propertyExists() : bool
- Checks if a property exists, extension equivalent of `property_exists()`
- extendableIsAccessible() : bool
- Checks if a property is accessible, property equivalent of `is_callable()`
- extensionExtractMethods() : void
- Extracts the available methods from a behavior and adds it to the list of callable methods.
- validateFileName() : string
- Checks the supplied file name for validity.
Properties
$content
public
string
$content
Partial content.
$fileName
public
string
$fileName
The component partial file name.
$implement
public
array<string|int, mixed>
$implement
Extensions implemented by this class.
$mtime
public
string
$mtime
Last modified time.
$allowedExtensions
protected
array<string|int, mixed>
$allowedExtensions
= ['htm']
Allowable file extensions.
$component
protected
ComponentBase
$component
A reference to the CMS component containing the object.
$defaultExtension
protected
string
$defaultExtension
= 'htm'
Default file extension.
$extendableCallbacks
protected
static array<string|int, mixed>
$extendableCallbacks
= []
Used to extend the constructor of an extendable class. Eg:
Class::extend(function($obj) { })
$extendableGuardProperties
protected
static bool
$extendableGuardProperties
= true
Indicates if dynamic properties can be created.
$extendableStaticMethods
protected
static array<string|int, mixed>
$extendableStaticMethods
= []
Collection of static methods used by behaviors.
$extensionData
protected
array<string|int, mixed>
$extensionData
= ['extensions' => [], 'methods' => [], 'dynamicMethods' => [], 'dynamicProperties' => []]
Class reflection information, including behaviors.
$maxNesting
protected
int
$maxNesting
= 2
The maximum allowed path nesting level. The default value is 2, meaning that files can only exist in the root directory, or in a subdirectory. Set to null if any level is allowed.
Methods
__call()
public
__call(mixed $name, mixed $params) : mixed
Parameters
- $name : mixed
- $params : mixed
Return values
mixed —__callStatic()
public
static __callStatic(mixed $name, mixed $params) : mixed
Parameters
- $name : mixed
- $params : mixed
Return values
mixed —__construct()
Creates an instance of the object and associates it with a CMS component.
public
__construct(ComponentBase $component) : mixed
Parameters
- $component : ComponentBase
-
Specifies the component the object belongs to.
Return values
mixed —__get()
public
__get(mixed $name) : mixed
Parameters
- $name : mixed
Return values
mixed —__set()
public
__set(mixed $name, mixed $value) : mixed
Parameters
- $name : mixed
- $value : mixed
Return values
mixed —addDynamicMethod()
Programmatically adds a method to the extendable class
public
addDynamicMethod(string $dynamicName, callable $method[, string $extension = null ]) : mixed
Parameters
- $dynamicName : string
- $method : callable
- $extension : string = null
Return values
mixed —addDynamicProperty()
Programmatically adds a property to the extendable class
public
addDynamicProperty(string $dynamicName[, string $value = null ]) : mixed
Parameters
- $dynamicName : string
- $value : string = null
Return values
mixed —asExtension()
Short hand for `getClassExtension()` method, except takes the short extension name, example:
public
asExtension(string $shortName) : mixed
$this->asExtension('FormController')
Parameters
- $shortName : string
Return values
mixed —check()
Returns true if the specific component contains a matching partial.
public
static check(ComponentBase $component, string $fileName) : bool
Parameters
- $component : ComponentBase
-
Specifies a component the file belongs to.
- $fileName : string
-
Specifies the file name to check.
Return values
bool —clearExtendedClasses()
Clear the list of extended classes so they will be re-extended.
public
static clearExtendedClasses() : void
Return values
void —extend()
public
static extend(callable $callback) : mixed
Parameters
- $callback : callable
Return values
mixed —extendableCall()
Magic method for `__call()`
public
extendableCall(string $name[, array<string|int, mixed> $params = null ]) : mixed
Parameters
- $name : string
- $params : array<string|int, mixed> = null
Return values
mixed —extendableCallStatic()
Magic method for `__callStatic()`
public
static extendableCallStatic(string $name[, array<string|int, mixed> $params = null ]) : mixed
Parameters
- $name : string
- $params : array<string|int, mixed> = null
Return values
mixed —extendableConstruct()
This method should be called as part of the constructor.
public
extendableConstruct() : mixed
Return values
mixed —extendableExtendCallback()
Helper method for `::extend()` static method
public
static extendableExtendCallback(callable $callback) : void
Parameters
- $callback : callable
Return values
void —extendableGet()
Magic method for `__get()`
public
extendableGet(string $name) : string
Parameters
- $name : string
Return values
string —extendableSet()
Magic method for `__set()`
public
extendableSet(string $name, string $value) : string
Parameters
- $name : string
- $value : string
Return values
string —extendClassWith()
Dynamically extend a class with a specified behavior
public
extendClassWith(string $extensionName) : void
Parameters
- $extensionName : string
Return values
void —find()
Find a single template by its file name.
public
find(string $fileName) : mixed|static
Parameters
- $fileName : string
Return values
mixed|static —getBaseFileName()
Returns the file name without the extension.
public
getBaseFileName() : string
Return values
string —getClassExtension()
Returns a behavior object from an extendable class, example:
public
getClassExtension(string $name) : mixed
$this->getClassExtension('Backend.Behaviors.FormController')
Parameters
- $name : string
-
Fully qualified behavior name
Return values
mixed —getClassMethods()
Get a list of class methods, extension equivalent of get_class_methods()
public
getClassMethods() : array<string|int, mixed>
Return values
array<string|int, mixed> —getContent()
Returns the file content.
public
getContent() : string
Return values
string —getDefaultExtension()
Returns the default extension used by this template.
public
getDefaultExtension() : string
Return values
string —getDynamicProperties()
Returns all dynamic properties and their values
public
getDynamicProperties() : array<string|int, mixed>
Return values
array<string|int, mixed> —['property' => 'value']
getFileName()
Returns the file name.
public
getFileName() : string
Return values
string —getFilePath()
Returns the absolute file path.
public
getFilePath([string $fileName = null ]) : string
Parameters
- $fileName : string = null
-
Specifies the file name to return the path to.
Return values
string —getTwigCacheKey()
Returns the key used by the Twig cache.
public
getTwigCacheKey() : string
Return values
string —getTwigContent()
Returns the Twig content string.
public
getTwigContent() : string
Return values
string —isClassExtendedWith()
Check if extendable class is extended with a behavior object
public
isClassExtendedWith(string $name) : bool
Parameters
- $name : string
-
Fully qualified behavior name
Return values
bool —load()
Loads the object from a file.
public
static load(ComponentBase $component, string $fileName) : mixed
This method is used in the CMS back-end. It doesn't use any caching.
Parameters
- $component : ComponentBase
-
Specifies the component the object belongs to.
- $fileName : string
-
Specifies the file name, with the extension. The file name can contain only alphanumeric symbols, dashes and dots.
Return values
mixed —Returns a CMS object instance or null if the object wasn't found.
loadCached()
There is not much point caching a component partial, so this behavior reverts to a regular load call.
public
static loadCached(ComponentBase $component, string $fileName) : mixed
Parameters
- $component : ComponentBase
- $fileName : string
Return values
mixed —loadOverrideCached()
Checks if a partial override exists in the supplied theme and returns it.
public
static loadOverrideCached(Theme $theme, ComponentBase $component, string $fileName) : mixed
Since the beginning of time, October inconsistently checked for overrides using the component alias exactly, resulting in a folder with uppercase characters, subsequently this method checks for both variants.
Parameters
- $theme : Theme
- $component : ComponentBase
- $fileName : string
Return values
mixed —methodExists()
Checks if a method exists, extension equivalent of method_exists()
public
methodExists(string $name) : bool
Parameters
- $name : string
Return values
bool —propertyExists()
Checks if a property exists, extension equivalent of `property_exists()`
public
propertyExists(string $name) : bool
Parameters
- $name : string
Return values
bool —extendableIsAccessible()
Checks if a property is accessible, property equivalent of `is_callable()`
protected
extendableIsAccessible(mixed $class, string $propertyName) : bool
Parameters
- $class : mixed
- $propertyName : string
Return values
bool —extensionExtractMethods()
Extracts the available methods from a behavior and adds it to the list of callable methods.
protected
extensionExtractMethods(string $extensionName, object $extensionObject) : void
Parameters
- $extensionName : string
- $extensionObject : object
Return values
void —validateFileName()
Checks the supplied file name for validity.
protected
validateFileName(string $fileName) : string
Parameters
- $fileName : string