model/modx/modelement.class.php

Classes 
abstract
Implement a derivative of this class to represent an element which can be processed within the MODX framework.
extends
modAccessibleSimpleObject
package
modx
Classes
modElement

Description

Represents an element of source content managed by MODX.

These elements are defined by some type of source content that when processed will provide output or some type of logical result based on mutable properties.

This class creates an instance of a modElement object. This should not be called directly, but rather extended for derivative modElement classes.

\modElement

Extends from
\modAccessibleSimpleObject
abstract
Implement a derivative of this class to represent an element which can be processed within the MODX framework.
extends
modAccessibleSimpleObject
package
modx
Properties
$_cacheable
$_content
$_filters
$_invalidCharacters
$_output
$_processed
$_properties
$_propertyString
$_result
$_tag
$_token
Methods
addPropertySet
cache
filterInput
filterOutput
findPolicy
get
getContent
getInputFilter
getOutputFilter
getProperties
getPropertySet
getTag
getToken
isCacheable
process
remove
removePropertySet
set
setCacheable
setContent
setProperties
setTag
setToken

Description

Represents an element of source content managed by MODX.

These elements are defined by some type of source content that when processed will provide output or some type of logical result based on mutable properties.

This class creates an instance of a modElement object. This should not be called directly, but rather extended for derivative modElement classes.

Properties

$_cacheableIf the element is cacheable or not.

boolean $_cacheable = 'true'

Details

boolean
If the element is cacheable or not.
visibility
public
default
true
final
false
static
false
access
private

$_content

string $_content = ''

The source content of the element.

Details

string
visibility
public
default
final
false
static
false
access
private

$_filtersOptional filters that can be used during processing.

array $_filters = 'array'

Details

array
Optional filters that can be used during processing.
visibility
public
default
array
final
false
static
false
access
private

$_invalidCharactersA list of invalid characters in the name of an Element.

array $_invalidCharacters = 'array'

Details

array
A list of invalid characters in the name of an Element.
visibility
protected
default
array
final
false
static
false
access
protected

$_output

string $_output = ''

The output of the element.

Details

string
visibility
public
default
final
false
static
false
access
private

$_processedIndicates if the element was processed already.

boolean $_processed = 'false'

Details

boolean
Indicates if the element was processed already.
visibility
public
default
false
final
false
static
false
access
private

$_properties

array $_properties = 'null'

The property value array for the element.

Details

array
visibility
public
default
null
final
false
static
false
access
private

$_propertyString

string $_propertyString = ''

The string representation of the element properties.

Details

string
visibility
public
default
final
false
static
false
access
private

$_result

boolean $_result = 'true'

The boolean result of the element.

This is typically only applicable to elements that use PHP source content.

Details

boolean
visibility
public
default
true
final
false
static
false
access
private

$_tag

string $_tag = 'null'

The tag signature of the element instance.

Details

string
visibility
public
default
null
final
false
static
false
access
private

$_token

string $_token = ''

The character token which helps identify the element class in tag string.

Details

string
visibility
public
default
final
false
static
false
access
private

Methods

addPropertySet

addPropertySet( string|\modPropertySet $propertySet ) : boolean

Add a property set to this element, making it available for use.

Arguments
$propertySet
string\modPropertySet
A modPropertySet object or the name of a modPropertySet object to create a relationship with.
Output
boolean
True if a relationship was created or already exists.
Details
visibility
public
final
false
static
false
access
public

cache

cache( ) :

Cache the current output of this element instance by tag signature.

Details
visibility
public
final
false
static
false
access
public

filterInput

filterInput( ) :

Apply an input filter to an element.

This is called by default in {@link modElement::process()} after the element properties have been parsed.

Details
visibility
public
final
false
static
false
access
protected

filterOutput

filterOutput( ) :

Apply an output filter to an element.

Call this method in your {modElement::process()} implementation when it is appropriate, typically once all processing has been completed, but before any caching takes place.

Details
visibility
public
final
false
static
false
access
protected

findPolicy

findPolicy( string $context ) : array

Loads the access control policies applicable to this element.

{@inheritdoc}

Arguments
$context
string
A key identifying a specific context to use when searching for the applicable policies. If not provided, the current context is used.
Output
array
An array of access policies for this object; an empty array is returned if no policies are assigned to the object.
Details
visibility
public
final
false
static
false

get

get( string|array $k, string|array $format = null, mixed $formatTemplate = null ) : mixed

Overrides xPDOObject::get to handle when retrieving the properties field for an Element.

{@inheritdoc}

Arguments
$k
stringarray
A string (or an array of strings) representing the field key or name.
$format
stringarray
An optional variable (or an array of variables) to format the return value(s).
$formatTemplate
mixed
An additional optional variable that can be used in formatting the return value(s).
Output
mixed
The value(s) of the field(s) requested.
Details
visibility
public
final
false
static
false

getContent

getContent( array $options = array ) : string

Gets the raw, unprocessed source content for this element.

Arguments
$options
array
An array of options implementations can use to accept language, revision identifiers, or other information to alter the behavior of the method.
Output
string
The raw source content for the element.
Details
visibility
public
final
false
static
false
access
public

getInputFilter

getInputFilter( ) : \modInputFilter|null

Get an input filter instance configured for this Element.

Output
\modInputFilter|null
An input filter instance (or null if one cannot be loaded).
Details
visibility
public
final
false
static
false

getOutputFilter

getOutputFilter( ) : \modOutputFilter|null

Get an output filter instance configured for this Element.

Output
\modOutputFilter|null
An output filter instance (or null if one cannot be loaded).
Details
visibility
public
final
false
static
false

getProperties

getProperties( array|string $properties = null ) : array

Get the properties for this element instance for processing.

Arguments
$properties
arraystring
An array or string of properties to apply.
Output
array
A simple array of properties ready to use for processing.
Details
visibility
public
final
false
static
false
access
public

getPropertySet

getPropertySet( string|null $setName = null ) : array|null

Gets a named property set related to this element instance.

If a setName parameter is not provided, this function will attempt to extract a setName from the element name using the @ symbol to delimit the name of the property set.

Here is an example of an element tag using the @ modifier to specify a property set name: [[ElementName@PropertySetName:FilterCommand=FilterModifier? &PropertyKey1=PropertyValue1 &PropertyKey2=PropertyValue2 ]]

Arguments
$setName
stringnull
An explicit property set name to search for.
Output
array|null
An array of properties or null if no set is found.
Details
visibility
public
final
false
static
false
access
public

getTag

getTag( ) : string

Constructs a valid tag representation of the element.

Output
string
A tag representation of the element.
Details
visibility
public
final
false
static
false
access
public

getToken

getToken( ) : string

Accessor method for the token class var.

Output
string
The token for this element tag.
Details
visibility
public
final
false
static
false

isCacheable

isCacheable( ) : boolean

Indicates if the element is cacheable.

Output
boolean
True if the element can be stored to or retrieved from the element cache.
Details
visibility
public
final
false
static
false
access
public

process

process( array|string $properties = null, string $content = null ) : mixed

Process the element source content to produce a result.

Arguments
$properties
arraystring
A set of configuration properties for the element.
$content
string
Optional content to use in place of any persistent content associated with the element.
Output
mixed
The result of processing.
Details
visibility
public
final
false
static
false
abstract
Implement this to define behavior for a MODX content element.
access
public

remove

remove( array $ancestors = array ) : boolean

Overrides xPDOObject::remove to remove all Property Sets that are related to this object.

{@inheritdoc}

Arguments
$ancestors
array
Keeps track of classes which have already been removed to prevent loop with circular references.
Output
boolean
Returns true on success, false on failure.
Details
visibility
public
final
false
static
false

removePropertySet

removePropertySet( string|\modPropertySet $propertySet ) : boolean

Remove a property set from this element, making it unavailable for use.

Arguments
$propertySet
string\modPropertySet
A modPropertySet object or the name of a modPropertySet object to dissociate from.
Output
boolean
True if a relationship was destroyed.
Details
visibility
public
final
false
static
false
access
public

set

set( string $k, mixed $v = null, string|\callable $vType ) : boolean

Overrides xPDOObject::set to strip invalid characters from element names.

{@inheritDoc}

Arguments
$k
string
The field key or name.
$v
mixed
The value to set the field to.
$vType
string\callable
A string indicating the format of the provided value parameter, or a callable function that should be used to set the field value, overriding the default behavior.
Output
boolean
Determines whether the value was set successfully and was determined to be dirty (i.e. different from the previous value).
Details
visibility
public
final
false
static
false

setCacheable

setCacheable( boolean $cacheable = true ) :

Sets the runtime cacheability of the element.

Arguments
$cacheable
boolean
Indicates the value to set for cacheability of this element.
Details
visibility
public
final
false
static
false
access
public

setContent

setContent( mixed $content, array $options = array ) : boolean

Set the raw source content for this element.

Arguments
$content
mixed
The source content; implementations can decide if it can only be a string, or some other source from which to retrieve it.
$options
array
An array of options implementations can use to accept language, revision identifiers, or other information to alter the behavior of the method.
Output
boolean
True indicates the content was set.
Details
visibility
public
final
false
static
false
access
public

setProperties

setProperties( array|string $properties, boolean $merge = false ) : boolean

Set default properties for this element instance.

Arguments
$properties
arraystring
A property array or property string.
$merge
boolean
Indicates if properties should be merged with existing ones.
Output
boolean
true if the properties are set.
Details
visibility
public
final
false
static
false
access
public

setTag

setTag( string $tag ) :

Setter method for the tag class var.

Arguments
$tag
string
The tag to use for this element.
Details
visibility
public
final
false
static
false

setToken

setToken( string $token ) :

Setter method for the token class var.

Arguments
$token
string
The token to use for this element tag.
Details
visibility
public
final
false
static
false
Documentation was generated by DocBlox 0.11.2.