Documentation

DataSet extends EntityBase implements Iterator, Countable

Data Set On import and export from and to files the contents will be cached.

Tags
copyright

CLOUDREXX CMS - CLOUDREXX AG

author

CLOUDREXX Development Team info@cloudrexx.com

subpackage

coremodule_listing

Table of Contents

Interfaces

Iterator
Countable

Properties

$data  : mixed
$dataType  : mixed
$identifier  : mixed
Identifier is used as a kind of description for the DataSet. For example: If you want to save an array with frontend users in a DataSet you can name the identifier something like 'frontendUser' This is used for the ViewGenerator, so you can have separated options for all DataSets
$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()
$options  : array<string|int, mixed>
List of options
$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
$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.
$yamlInterface  : mixed

Methods

__call()  : mixed
Route methods like getName(), getType(), getDirectory(), etc.
__construct()  : mixed
Constructor for DataSet
__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
add()  : mixed
Set data-attribute $key to $value
addColumn()  : mixed
Add column to each entry
count()  : int
current()  : mixed
entryExists()  : mixed
export()  : mixed
exportToFile()  : void
Exports a DataSet to a file using an export interface
filter()  : mixed
Filters entries of this DataSet
flip()  : DataSet
Returns a flipped version of this DataSet
fromYaml()  : mixed
getComponentController()  : SystemComponent
Returns the component controller for this component
getDataType()  : mixed
getEntry()  : mixed
getIdentifier()  : string
This function returns the identifier of the DataSet
getKeyAsString()  : string
Returns this entity's key
getTranslatedFieldValue()  : mixed
Returns the value of a translatable field using fallback mechanisms
import()  : DataSet
importFromFile()  : DataSet
Imports a DataSet from a file using an import interface
initializeValidators()  : mixed
Set $this->validators
isVirtual()  : bool
Returns the virtuality of the entity
join()  : mixed
Appends the data of passed $dataSet to the current object and rewinds it
key()  : mixed
length()  : mixed
limit()  : mixed
load()  : DataSet
next()  : mixed
remove()  : mixed
Try to remove the declared key from the dataset
rewind()  : mixed
save()  : void
set()  : void
Set data-attribute $key to $value
setDataType()  : mixed
This function sets the DataType of an DataSet
setIdentifier()  : mixed
This function sets the identifier of the DataSet
setVirtual()  : mixed
Set the virtuality of the entity
size()  : mixed
sort()  : DataSet
Sort this DataSet by the fields and in the order specified
sortColumns()  : mixed
Sort the columns after the given array.
toArray()  : array<string|int, mixed>
Returns a list of all elements data of this DataSet as an array
toYaml()  : mixed
valid()  : mixed
validate()  : mixed
convert()  : mixed
convertObject()  : array<string|int, mixed>
Default conversion of objects
getFallbackLocaleCodes()  : array<string|int, mixed>
Returns a list of all locale codes ordered by fallback order
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
getYamlInterface()  : mixed
initializeOptions()  : mixed
Initializes the options, sets necessary defaults
is_iterable()  : bool
Tell if the supplied argument is iterable

Properties

$identifier

Identifier is used as a kind of description for the DataSet. For example: If you want to save an array with frontend users in a DataSet you can name the identifier something like 'frontendUser' This is used for the ViewGenerator, so you can have separated options for all DataSets

protected mixed $identifier = ''
Tags
access

protected

@var

$identifier

$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

$options

List of options

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

$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()

$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

__construct()

Constructor for DataSet

public __construct([array<string|int, mixed> $data = array() ][, callable $converter = null ][, array<string|int, mixed> $options = array() ]) : mixed
Parameters
$data : array<string|int, mixed> = array()

(optional) Array of data to convert and store

$converter : callable = null

(optional) Custom data converter

$options : array<string|int, mixed> = array()

(optional): Options for conversion

Tags
todo:

DataSet must be extended, that it can handle objects

__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

add()

Set data-attribute $key to $value

public add(mixed $key, mixed $value[, mixed &$convertedData = null ]) : mixed
Parameters
$key : mixed
$value : mixed
$convertedData : mixed = null

addColumn()

Add column to each entry

public addColumn(mixed $column) : mixed
Parameters
$column : mixed

string title of column

current()

public current() : mixed
Attributes
#[ReturnTypeWillChange]

entryExists()

public entryExists(mixed $key) : mixed
Parameters
$key : mixed

exportToFile()

Exports a DataSet to a file using an export interface

public exportToFile(Exportable $exportInterface, string $filename[, bool $useCache = true ][, bool $useCodeBaseCache = false ]) : void
Parameters
$exportInterface : Exportable
$filename : string
$useCache : bool = true

Whether to cache the exported data in user cache.

$useCodeBaseCache : bool = false

If $useCache is set to true, then data is cached in the data user-cache by default. To cache data in the codebase user-cache do set $useCodeBaseCache to true.

Tags
throws
FileSystemException

filter()

Filters entries of this DataSet

public filter(callable $filterFunction) : mixed
Parameters
$filterFunction : callable

flip()

Returns a flipped version of this DataSet

public flip() : DataSet
Return values
DataSet

Flipped DataSet (new instance)

fromYaml()

public static fromYaml(mixed $data) : mixed
Parameters
$data : mixed

getEntry()

public getEntry(mixed $key) : mixed
Parameters
$key : mixed

getIdentifier()

This function returns the identifier of the DataSet

public getIdentifier() : string
Tags
access

public

Return values
string

the 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

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

import()

public static import(Importable $importInterface, mixed $content) : DataSet
Parameters
$importInterface : Importable
$content : mixed
Tags
todo

Fix CLX-5705 so that we can set a proper return type.

Return values
DataSet

importFromFile()

Imports a DataSet from a file using an import interface

public static importFromFile(Importable $importInterface, string $filename[, bool $useCache = true ][, bool $useCodeBaseCache = false ]) : DataSet
Parameters
$importInterface : Importable
$filename : string
$useCache : bool = true

Whether to try to load the file from cache or not

$useCodeBaseCache : bool = false

If $useCache is set to true, then data is fetched from the data user-cache by default. To fetch data from the codebase user-cache do set $useCodeBaseCache to true.

Tags
todo

Fix CLX-5705 so that we can set a proper return type.

throws
FileSystemException
Return values
DataSet

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

isVirtual()

Returns the virtuality of the entity

public isVirtual() : bool
Return values
bool

TRUE if the entity is virtual, otherwise FALSE

join()

Appends the data of passed $dataSet to the current object and rewinds it

public join(DataSet $dataSet) : mixed
Parameters
$dataSet : DataSet

DataSet of which its data should be appended

key()

public key() : mixed
Attributes
#[ReturnTypeWillChange]

limit()

public limit(mixed $length, mixed $offset) : mixed
Parameters
$length : mixed
$offset : mixed

load()

public static load(string $filename[, bool $useCache = true ][, bool $useCodeBaseCache = false ]) : DataSet
Parameters
$filename : string
$useCache : bool = true

Whether to try to load the file from cache or not

$useCodeBaseCache : bool = false

If $useCache is set to true, then data is fetched from the data user-cache by default. To fetch data from the codebase user-cache do set $useCodeBaseCache to true.

Tags
todo

Fix CLX-5705 so that we can set a proper return type.

throws
FileSystemException
Return values
DataSet

next()

public next() : mixed
Attributes
#[ReturnTypeWillChange]

remove()

Try to remove the declared key from the dataset

public remove(string $key) : mixed
Parameters
$key : string
Tags
throws
DataSetException

rewind()

public rewind() : mixed
Attributes
#[ReturnTypeWillChange]

save()

public save(string $filename[, bool $useCache = true ][, bool $useCodeBaseCache = false ]) : void
Parameters
$filename : string
$useCache : bool = true

Whether to cache the exported data in user cache.

$useCodeBaseCache : bool = false

If $useCache is set to true, then data is cached in the data user-cache by default. To cache data in the codebase user-cache do set $useCodeBaseCache to true.

Tags
throws
FileSystemException

set()

Set data-attribute $key to $value

public set(mixed $key, mixed $value[, mixed &$convertedData = null ]) : void
Parameters
$key : mixed
$value : mixed
$convertedData : mixed = null

setDataType()

This function sets the DataType of an DataSet

public setDataType(string $dataType) : mixed
Parameters
$dataType : string
Tags
access

public

setIdentifier()

This function sets the identifier of the DataSet

public setIdentifier(string $identifier) : mixed
Parameters
$identifier : string

the identifier of the DataSet

Tags
access

public

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

sort()

Sort this DataSet by the fields and in the order specified

public sort(array<string|int, mixed> $order) : DataSet

$order has the following syntax: array( {fieldname} => SORT_ASC|SORT_DESC, [{fieldname2} => SORT_ASC|SORT_DESC, [...]] )

Parameters
$order : array<string|int, mixed>

Fields and order to sort

Return values
DataSet

Sorted DataSet (new instance)

sortColumns()

Sort the columns after the given array.

public sortColumns(type $orderArr) : mixed

Not defined columns are sorted after the default

Parameters
$orderArr : type

Array with the new order

toArray()

Returns a list of all elements data of this DataSet as an array

public toArray([bool $allowToReturnElement = true ]) : array<string|int, mixed>

If there is only one entry in this DataSet, the entry is returned directly instead of returning a list with just one element. If $allowToReturnElement is set to false a list with just one element is returned.

Parameters
$allowToReturnElement : bool = true

(optional) If set to false this method always returns a list of elements.

Return values
array<string|int, mixed>

List of elements as an array

valid()

public valid() : mixed
Attributes
#[ReturnTypeWillChange]

convert()

protected convert(mixed $data) : mixed
Parameters
$data : mixed

convertObject()

Default conversion of objects

protected convertObject(object $object[, string &$key = '' ][, array<string|int, mixed> $forbiddenClasses = array('DoctrineORMPersistentCollection') ][, string $prefix = 'x.' ]) : array<string|int, mixed>
Parameters
$object : object

Object to convert

$key : string = ''

(Reference) Object key, might get replaced by object's ID

$forbiddenClasses : array<string|int, mixed> = array('DoctrineORMPersistentCollection')

(Optional) List of classes to skip recursion of

$prefix : string = 'x.'

(Optional) Path to current object (see \Cx\Core\DataSource\Model\Entity\DoctrineRepository)

Return values
array<string|int, mixed>

Converted data

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

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

getYamlInterface()

protected static getYamlInterface() : mixed

initializeOptions()

Initializes the options, sets necessary defaults

protected initializeOptions(array<string|int, mixed> $options) : mixed
Parameters
$options : array<string|int, mixed>

Options to set

is_iterable()

Tell if the supplied argument is iterable

private is_iterable(mixed $var) : bool
Parameters
$var : mixed

Variable to test iterability

Tags
todo

Rethink this method, DataSet is always iterable, this is a general helper method

Return values
bool

True if $var is iterable, false otherwise


        
On this page

Search results