DataSet
extends EntityBase
in package
implements
Iterator, Countable
Data Set On import and export from and to files the contents will be cached.
Tags
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
$data
protected
mixed
$data
= array()
$dataType
protected
mixed
$dataType
= 'array'
$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
$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
$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
$stringRepresentationFields
List of fields that should be available in the string representation
protected
array<string|int, mixed>
$stringRepresentationFields
= array()
List of field names
Tags
$stringRepresentationFormat
Sprintf format for the string representation
protected
string
$stringRepresentationFormat
= ''
Sprintf format string
Tags
$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.
$yamlInterface
protected
static mixed
$yamlInterface
= null
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
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
__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
count()
public
count() : int
Return values
intcurrent()
public
current() : mixed
Attributes
- #[ReturnTypeWillChange]
entryExists()
public
entryExists(mixed $key) : mixed
Parameters
- $key : mixed
export()
public
export(Exportable $exportInterface) : mixed
Parameters
- $exportInterface : Exportable
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
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
getComponentController()
Returns the component controller for this component
public
getComponentController() : SystemComponent
Return values
SystemComponentgetDataType()
public
getDataType() : mixed
getEntry()
public
getEntry(mixed $key) : mixed
Parameters
- $key : mixed
getIdentifier()
This function returns the identifier of the DataSet
public
getIdentifier() : string
Tags
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
Return values
DataSetimportFromFile()
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
Return values
DataSetinitializeValidators()
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]
length()
public
length() : mixed
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
Return values
DataSetnext()
public
next() : mixed
Attributes
- #[ReturnTypeWillChange]
remove()
Try to remove the declared key from the dataset
public
remove(string $key) : mixed
Parameters
- $key : string
Tags
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
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
setIdentifier()
This function sets the identifier of the DataSet
public
setIdentifier(string $identifier) : mixed
Parameters
- $identifier : string
-
the identifier of the DataSet
Tags
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
size()
public
size() : mixed
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
toYaml()
public
toYaml() : mixed
valid()
public
valid() : mixed
Attributes
- #[ReturnTypeWillChange]
validate()
public
validate() : mixed
Tags
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
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
Return values
bool —True if $var is iterable, false otherwise