ComponentPartial

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

 class Cms\Classes\ComponentPartial
extends Winter\Storm\Extension\Extendable
implements 
    Cms\Contracts\CmsObject

Extends

Class Description
Extendable

Extension class

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 $content : string

Partial content.

public $fileName : string

The component partial file name.

public $mtime : string

Last modified time.

protected $allowedExtensions : array

Allowable file extensions.

protected $component : Cms\Classes\ComponentBase

A reference to the CMS component containing the object.

protected $defaultExtension : string

Default file extension.

protected $maxNesting : int

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.

inherited public $implement : string | array | null

Inherited from Extendable

Extensions implemented by this class.

inherited protected static $extendableCallbacks : array

Inherited from ExtendableTrait

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

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

inherited protected static $extendableClassLoader : ClassLoader | null

Inherited from ExtendableTrait

Class loader instance.

inherited protected $extendableConstructed : bool

Inherited from Extendable

Indicates if the extendable constructor has completed.

inherited protected static $extendableStaticMethods : array

Inherited from ExtendableTrait

Collection of static methods used by behaviors.

inherited protected $extensionData : array

Inherited from ExtendableTrait

Class reflection information, including behaviors.

inherited protected $localCallbacks : array

Inherited from Extendable

This stores any locally-scoped callbacks fired before the extendable constructor had completed.

Methods

public __construct (Cms\Classes\ComponentBase $component)

Creates an instance of the object and associates it with a CMS component.

Parameters
Property Description
$component
Cms\Classes\ComponentBase

Specifies the component the object belongs to.

Returns
mixed

public static check (Cms\Classes\ComponentBase $component, string $fileName) : bool

Returns true if the specific component contains a matching partial.

Parameters
Property Description
$component
Cms\Classes\ComponentBase

Specifies a component the file belongs to.

$fileName
string

Specifies the file name to check.

Returns
bool

public find (string $fileName) : mixed | static

Find a single template by its file name.

Parameters
Property Description
$fileName
string
Returns
mixed | static

public getBaseFileName () : string

Returns the file name without the extension.

Returns
string

public getContent () : string

Returns the file content.

Returns
string

public getDefaultExtension () : string

Returns the default extension used by this template.

Returns
string

public getFileName () : string

Returns the file name.

Returns
string

public getFilePath (string $fileName = null) : string

Returns the absolute file path.

Parameters
Property Description
$fileName
string

Specifies the file name to return the path to.

Returns
string

public getTwigCacheKey () : string

Returns the key used by the Twig cache.

Returns
string

public getTwigContent () : string

Returns the Twig content string.

Returns
string

public static load (Cms\Classes\ComponentBase $component, string $fileName) : mixed

Loads the object from a file.

This method is used in the CMS back-end. It doesn't use any caching.

Parameters
Property Description
$component

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.

Returns
mixed

Returns a CMS object instance or null if the object wasn't found.

public static loadCached (Cms\Classes\ComponentBase $component, string $fileName) : mixed

There is not much point caching a component partial, so this behavior reverts to a regular load call.

Parameters
Property Description
$component
$fileName
string
Returns
mixed

public static loadOverrideCached (Cms\Classes\Theme $theme, Cms\Classes\ComponentBase $component, string $fileName) : mixed

Checks if a partial override exists in the supplied theme and returns it.

Since the beginning of time, Winter inconsistently checked for overrides using the component alias exactly, resulting in a folder with uppercase characters, subsequently this method checks for both variants.

Parameters
Property Description
$theme
$component
$fileName
string
Returns
mixed

protected validateFileName (string $fileName) : string

Checks the supplied file name for validity.

Parameters
Property Description
$fileName
string
Returns
string

inherited public __call ($name, $params)

Inherited from Extendable
Parameters
Property Description
$name
mixed
$params
mixed
Returns
mixed

inherited public static __callStatic ($name, $params)

Inherited from Extendable
Parameters
Property Description
$name
mixed
$params
mixed
Returns
mixed

inherited public __get ($name)

Inherited from Extendable
Parameters
Property Description
$name
mixed
Returns
mixed

inherited public __set ($name, $value)

Inherited from Extendable
Parameters
Property Description
$name
mixed
$value
mixed
Returns
mixed

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

Inherited from ExtendableTrait

Programmatically adds a method to the extendable class

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

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

Inherited from ExtendableTrait

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

inherited public asExtension (string $shortName) : mixed

Inherited from ExtendableTrait

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

$this->asExtension('FormController')

Parameters
Property Description
$shortName
string
Returns
mixed

inherited public static clearExtendedClasses () : void

Inherited from ExtendableTrait

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

Returns
void

inherited public extendClassWith (string $extensionName) : void

Inherited from ExtendableTrait

Dynamically extend a class with a specified behavior

Parameters
Property Description
$extensionName
string
Returns
void

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

Inherited from Extendable

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.

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

inherited public extendableCall (string $name, array $params = null) : mixed

Inherited from ExtendableTrait

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

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

Inherited from ExtendableTrait

Magic method for __callStatic()

Parameters
Property Description
$name
string
$params
array
Returns
mixed

inherited public extendableConstruct ()

Inherited from ExtendableTrait

This method should be called as part of the constructor.

Returns
mixed

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

Inherited from ExtendableTrait

Helper method for ::extend() static method.

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

inherited public extendableGet (string $name) : mixed | null

Inherited from ExtendableTrait

Magic method for __get()

Parameters
Property Description
$name
string
Returns
mixed | null

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

Inherited from ExtendableTrait

Magic method for __set()

Parameters
Property Description
$name
string
$value
mixed
Returns
void

inherited public getClassExtension (string $name) : mixed

Inherited from ExtendableTrait

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

inherited public getClassMethods () : array

Inherited from ExtendableTrait

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

Returns
array

inherited public getDynamicProperties () : array

Inherited from ExtendableTrait

Returns all dynamic properties and their values

Returns
array

['property' => 'value']

inherited public isClassExtendedWith (string $name) : bool

Inherited from ExtendableTrait

Check if extendable class is extended with a behavior object

Parameters
Property Description
$name
string

Fully qualified behavior name

Returns
bool

inherited public methodExists (string $name) : bool

Inherited from ExtendableTrait

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

Parameters
Property Description
$name
string
Returns
bool

inherited public propertyExists (string $name) : bool

Inherited from ExtendableTrait

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

Parameters
Property Description
$name
string
Returns
bool

inherited protected extendableAddLocalExtension (Closure $callback, $outerScope = null)

Inherited from Extendable

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.

Parameters
Property Description
$callback
Closure
$outerScope
mixed
Returns
mixed

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

Inherited from ExtendableTrait

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

Parameters
Property Description
$class
mixed
$propertyName
string
Returns
bool

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

Inherited from ExtendableTrait

Calls a method through reflection.

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

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

Inherited from ExtendableTrait

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

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

Inherited from ExtendableTrait

Gets the class loader

Returns
Winter\Storm\Support\ClassLoader | null

inherited protected extensionGetParentClass ($instance = null) : ReflectionClass | false

Inherited from ExtendableTrait

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

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

Inherited from ExtendableTrait

Determines if the given class reflection contains the given method.

Parameters
Property Description
$class
ReflectionClass
$methodName
string
Returns
bool

inherited protected extensionNormalizeClassName (string $name) : string

Inherited from ExtendableTrait

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

Parameters
Property Description
$name
string
Returns
string
Copyright © 2024 Winter CMS