Documentation

BlockType extends EntityBase implements Tool

This class provides the magic of being validatable.

Tags
copyright

Cloudrexx AG

author

Michael Ritter michael.ritter@cloudrexx.com

subpackage

core_modules_blockeditor

Table of Contents

Interfaces

Tool

Properties

$config  : array<string|int, mixed>
$default  : bool
$localeCodes  : array<string|int, mixed>
List of locale codes ordered by translation fallback order per Cx instance
$nestingCount  : int
Counts the nesting level of __call()
$placeholderReferences  : array<string|int, mixed>
$script  : string
$stringRepresentationBlank  : bool
Whether blank string representations are valid
$stringRepresentationFields  : array<string|int, mixed>
List of fields that should be available in the string representation
$stringRepresentationFormat  : string
Sprintf format for the string representation
$style  : string
$template  : string
$validators  : array<string|int, mixed>
Initialize this array as follows: array( 'columName' => Zend_Validate )
$virtual  : bool
Defines if an entity is virtual and therefore not persistable.

Methods

__call()  : mixed
Route methods like getName(), getType(), getDirectory(), etc.
__get()  : mixed
This is an ugly solution to allow $this->cx to be available in all entity classes Since the entity's constructor is not called when an entity is loaded from DB this cannot be assigned there.
__toString()  : string
Returns this entity's identifying value
fromFile()  : BlockType
Loads a block type from block type definition file
getComponentController()  : SystemComponent
Returns the component controller for this component
getConfig()  : array<string|int, mixed>
Returns this block type's configuration
getIdentifier()  : string
Returns this block type's identifier
getKeyAsString()  : string
Returns this entity's key
getScript()  : string
Returns this block type's script
getStyle()  : string
Returns this block type's style
getTemplate()  : string
Returns this block type's markup template
getTranslatedFieldValue()  : mixed
Returns the value of a translatable field using fallback mechanisms
initializeValidators()  : mixed
Set $this->validators
isDefault()  : true
Returns whether this block type is a system or user-defined
isVirtual()  : bool
Returns the virtuality of the entity
render()  : string
Renders this block type for given data for front-end
setVirtual()  : mixed
Set the virtuality of the entity
validate()  : mixed
__construct()  : mixed
Constructs a new block type
getFallbackLocaleCodes()  : array<string|int, mixed>
Returns a list of all locale codes ordered by fallback order
getParam()  : mixed
Returns a param of this block type base on given data
getStringRepresentationBlank()  : bool
Whether blank string representations are valid
getStringRepresentationFields()  : array<string|int, mixed>
Returns a list of fields available in the string representation
getStringRepresentationFormat()  : string
Returns the sprintf() format for the string representation
getTagsForMode()  : string
Returns the tags that have a class matching the given mode set
replacePlaceholderByRef()  : mixed
replaceRefByPlaceholder()  : string
Replaces func_editor_<funcName>(<args>)
replaceTemplateRefs()  : mixed

Properties

$config

protected array<string|int, mixed> $config

Configuration for this block type

$default

protected bool $default

Whether this is a default or user-defined block type

$localeCodes

List of locale codes ordered by translation fallback order per Cx instance

protected static array<string|int, mixed> $localeCodes = array()

Array in the form: array(<instanceId> => array(<localeCode>, ...))

Tags
see
getFallbackLocaleCodes()

$nestingCount

Counts the nesting level of __call()

protected static int $nestingCount = 0

$placeholderReferences

protected array<string|int, mixed> $placeholderReferences = array()

Used for two stage parsing of nested function placeholders

$stringRepresentationBlank

Whether blank string representations are valid

protected bool $stringRepresentationBlank = false

Whether blank string representations are valid

Tags
see
getStringRepresentationBlank()

$stringRepresentationFields

List of fields that should be available in the string representation

protected array<string|int, mixed> $stringRepresentationFields = array()

List of field names

Tags
see
getStringRepresentationFields()

$stringRepresentationFormat

Sprintf format for the string representation

protected string $stringRepresentationFormat = ''

Sprintf format string

Tags
see
getStringRepresentationFormat()

$template

protected string $template

Markup template for this block type

$validators

Initialize this array as follows: array( 'columName' => Zend_Validate )

protected array<string|int, mixed> $validators = array()

$virtual

Defines if an entity is virtual and therefore not persistable.

protected bool $virtual = false

Defaults to FALSE - not virtual.

Methods

__call()

Route methods like getName(), getType(), getDirectory(), etc.

public __call(string $methodName, array<string|int, mixed> $arguments) : mixed
Parameters
$methodName : string

Name of method to call

$arguments : array<string|int, mixed>

List of arguments for the method to call

Tags
throws
Exception

If __call() nesting level reaches 20

Attributes
#[ReturnTypeWillChange]
Return values
mixed

Return value of the method to call

__get()

This is an ugly solution to allow $this->cx to be available in all entity classes Since the entity's constructor is not called when an entity is loaded from DB this cannot be assigned there.

public __get(mixed $name) : mixed
Parameters
$name : mixed
Attributes
#[ReturnTypeWillChange]

__toString()

Returns this entity's identifying value

public __toString() : string

By default this returns the same as getKeyAsString(), but this method might get overridden by subclasses.

Return values
string

Identifying value for this entity

fromFile()

Loads a block type from block type definition file

public static fromFile(SplFileInfo $file, bool $default) : BlockType
Parameters
$file : SplFileInfo

File to load

$default : bool

Whether this is a system or user-defined block type

Tags
throws
BlockTypeException

If the file is invalid

Return values
BlockType

BlockType loaded from given file

getConfig()

Returns this block type's configuration

public getConfig() : array<string|int, mixed>
Return values
array<string|int, mixed>

Configuration for this block type

getIdentifier()

Returns this block type's identifier

public getIdentifier() : string
Return values
string

BlockType identifier

getKeyAsString()

Returns this entity's key

public final getKeyAsString([string $separator = '/' ]) : string

If this entity has a composite key, the fields are separated by $separator.

Parameters
$separator : string = '/'

(optional) Separator for composite key fields, default "/"

Return values
string

Entity key as string

getScript()

Returns this block type's script

public getScript(bool $frontend) : string
Parameters
$frontend : bool

Whether to return scripts for frontend or backend

Return values
string

JS scripts for this block type

getStyle()

Returns this block type's style

public getStyle(bool $frontend) : string
Parameters
$frontend : bool

Whether to return styles for frontend or backend

Return values
string

CSS styles for this block type

getTemplate()

Returns this block type's markup template

public getTemplate(bool $frontend) : string
Parameters
$frontend : bool

Whether to return template for frontend or backend

Return values
string

Unparsed markup

getTranslatedFieldValue()

Returns the value of a translatable field using fallback mechanisms

public getTranslatedFieldValue(string $fieldName) : mixed

If the field is not translatable its value is returned anyway. Tries to return the value in the following locales (if non-empty):

  • Current locale
  • Default locale
  • All other locales
Parameters
$fieldName : string

Name of a translatable field

initializeValidators()

Set $this->validators

public initializeValidators() : mixed

Validators can be found in lib/FRAMEWORK/Validator.class.php These will be executed if validate() is called

isDefault()

Returns whether this block type is a system or user-defined

public isDefault() : true
Return values
true

if this is a system block type, false otherwise

isVirtual()

Returns the virtuality of the entity

public isVirtual() : bool
Return values
bool

TRUE if the entity is virtual, otherwise FALSE

render()

Renders this block type for given data for front-end

public render(stdClass|null $data) : string

We intentionally do not use Sigma here because:

  • We can keep the code close to the JS code parsing this in backend (ClxBlock.js)
  • We avoid any Widgets or other hooks from interfering
Parameters
$data : stdClass|null

The block data to render

Return values
string

Rendered markup

setVirtual()

Set the virtuality of the entity

public setVirtual(bool $virtual) : mixed
Parameters
$virtual : bool

TRUE to set the entity as virtual or otherwise to FALSE

__construct()

Constructs a new block type

protected __construct(array<string|int, mixed> $config, string $template, string $script, string $style, bool $default) : mixed
Parameters
$config : array<string|int, mixed>

Configuration for this block type

$template : string

Markup template for this block type

$script : string

Script for this block type

$style : string

Style for this block type

$default : bool

Whether this is a system or user-defined block type

getFallbackLocaleCodes()

Returns a list of all locale codes ordered by fallback order

protected getFallbackLocaleCodes() : array<string|int, mixed>
  • First entry is the current locale
  • Second entry is the default locale (if different from current, it's omitted otherwise)
  • Then all other locales follow (in no particular order)
Tags
todo

Order the array by the fallback order (same as in ContentManager)

Return values
array<string|int, mixed>

List of locale codes

getParam()

Returns a param of this block type base on given data

protected getParam(stdClass $data, string $param) : mixed
Parameters
$data : stdClass

Data to base return value on

$param : string

Name of the param to return

Return values
mixed

Param with its correct type

getStringRepresentationBlank()

Whether blank string representations are valid

protected getStringRepresentationBlank() : bool
Return values
bool

Whether blank string representations are valid

getStringRepresentationFields()

Returns a list of fields available in the string representation

protected getStringRepresentationFields() : array<string|int, mixed>
Return values
array<string|int, mixed>

List of field names

getStringRepresentationFormat()

Returns the sprintf() format for the string representation

protected getStringRepresentationFormat() : string
Return values
string

sprintf() format string

getTagsForMode()

Returns the tags that have a class matching the given mode set

protected getTagsForMode(string $tagname, bool $frontend, string $markup) : string
Parameters
$tagname : string

Name of the tag to match

$frontend : bool

Whether to return template for frontend or backend

$markup : string

Markup to match

Return values
string

Resulting markup matching the given mode

replacePlaceholderByRef()

protected replacePlaceholderByRef(stdClass $data, string $funcName, array<string|int, mixed> $args, mixed &$childCount) : mixed
Parameters
$data : stdClass
$funcName : string
$args : array<string|int, mixed>
$childCount : mixed

replaceRefByPlaceholder()

Replaces func_editor_<funcName>(<args>)

protected replaceRefByPlaceholder(stdClass $data, string $funcName, array<string|int, mixed> $args, mixed $childId) : string
Parameters
$data : stdClass

Data to base return value on

$funcName : string

The name of the function to parse

$args : array<string|int, mixed>

Arguments for the function

$childId : mixed
Return values
string

Replacement markup

replaceTemplateRefs()

protected replaceTemplateRefs(mixed $template) : mixed
Parameters
$template : mixed

        
On this page

Search results