Documentation

DataSource extends EntityBase

AbstractYes

DataSource

Tags
copyright

Cloudrexx AG

author

Project Team SS4U info@cloudrexx.com

subpackage

core_datasource

Table of Contents

Properties

$dataAccesses  : Collection
$id  : int
$identifier  : string
$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  : 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
$supportedOperations  : array<string|int, mixed>
List of operations supported by this DataSource
$type  : 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.
__construct()  : mixed
Constructor
__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
Adds a new entry to this DataSource
addDataAccess()  : DataSource
Add dataAccesses
get()  : array<string|int, mixed>
Gets one or more entries from this DataSource
getComponentController()  : SystemComponent
Returns the component controller for this component
getCurrentVersion()  : int
Returns version number if DataSource is versionable
getDataAccesses()  : type
Get the data access
getId()  : int
Get id
getIdentifier()  : string
Get the identifier
getIdentifierFieldNames()  : array<string|int, mixed>
Returns a list of field names that uniquely identify objects
getKeyAsString()  : string
Returns this entity's key
getOption()  : mixed
Get an option by key
getOptions()  : array<string|int, mixed>
Get the options
getSupportedOperations()  : array<string|int, mixed>
Returns the list of operations supported by this DataSource
getTranslatedFieldValue()  : mixed
Returns the value of a translatable field using fallback mechanisms
getType()  : string
Get the type
hasField()  : bool
Tells whether this DataSource has a field named $field
initializeValidators()  : mixed
Set $this->validators
isVersionable()  : bool
Returns if DataSource supports versioning
isVirtual()  : bool
Returns the virtuality of the entity
listFields()  : array<string|int, mixed>
Returns a list of field names this DataSource consists of
remove()  : mixed
Drops an entry from this DataSource
removeDataAccess()  : mixed
Remove dataAccesses
setDataAccesses()  : mixed
Set the data access
setIdentifier()  : mixed
Set the identifier
setOptions()  : mixed
Set the options
setVirtual()  : mixed
Set the virtuality of the entity
supportsOperation()  : bool
Tells whether operation $operation is supported by this DataSource
update()  : mixed
Updates an existing entry of this DataSource
validate()  : mixed
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

Properties

$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

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

$supportedOperations

List of operations supported by this DataSource

protected array<string|int, mixed> $supportedOperations = array('eq')

List of operations

$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

add()

Adds a new entry to this DataSource

public abstract add(array<string|int, mixed> $data) : mixed
Parameters
$data : array<string|int, mixed>

Field=>value-type array. Not all fields may be required.

Tags
throws
Exception

If something did not go as planned

get()

Gets one or more entries from this DataSource

public abstract get([array<string|int, mixed> $elementId = array() ][, array<string|int, mixed> $filter = array() ][, array<string|int, mixed> $order = array() ][, int $limit = 0 ][, int $offset = 0 ][, int &$count = 0 ][, array<string|int, mixed> $fieldList = array() ]) : array<string|int, mixed>

If an argument is not provided, no restriction is made for this argument. So if this is called without any arguments, all entries of this DataSource are returned. If no entry is found, an empty array is returned.

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

(optional) field=>value-type condition array identifying an entry

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

(optional) field=>value-type condition array, only supports = for now

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

(optional) field=>order-type array, order is either "ASC" or "DESC"

$limit : int = 0

(optional) If set, no more than $limit results are returned

$offset : int = 0

(optional) Entry to start with

$count : int = 0

(optional / passed by reference) Will be set to the total matched entries

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

(optional) Limits the result to the values for the fields in this list

Tags
throws
Exception

If something did not go as planned

Return values
array<string|int, mixed>

Two dimensional array (/table) of results (array($row=>array($fieldName=>$value)))

getCurrentVersion()

Returns version number if DataSource is versionable

public getCurrentVersion(array<string|int, mixed> $elementId) : int

You can use this method to get the current version number of a DataSource. If the DataSource is not versionable, the default value is 0. Version number needs to be >= 1 to be versionable, 0 is no valid version number. Subclasses can overwrite this method isVersionable()

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

array identifying an entry

Return values
int

see description above

getDataAccesses()

Get the data access

public getDataAccesses() : type
Return values
type

getIdentifier()

Get the identifier

public getIdentifier() : string
Return values
string

$identifier

getIdentifierFieldNames()

Returns a list of field names that uniquely identify objects

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

List of field names

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

getOption()

Get an option by key

public getOption(string $key) : mixed
Parameters
$key : string

Path to desired info, delimited by "."

Return values
mixed

Desired information or false if not found

getOptions()

Get the options

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

$options

getSupportedOperations()

Returns the list of operations supported by this DataSource

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

List of supported operations

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

getType()

Get the type

public getType() : string
Return values
string

$type

hasField()

Tells whether this DataSource has a field named $field

public hasField(string $field) : bool
Parameters
$field : string

Name of a field

Return values
bool

True if $field exists in this DataSource, false otherwise

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

isVersionable()

Returns if DataSource supports versioning

public isVersionable() : bool

This method is to ensure that DataAccess can check if DataSource supports versioning. The default value is set to false. If the desired DataSource should be versionable, this method can be overwritten to achieve this.

Return values
bool

If set true, DataSource supports versioning

isVirtual()

Returns the virtuality of the entity

public isVirtual() : bool
Return values
bool

TRUE if the entity is virtual, otherwise FALSE

listFields()

Returns a list of field names this DataSource consists of

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

List of field names

remove()

Drops an entry from this DataSource

public abstract remove(array<string|int, mixed> $elementId) : mixed
Parameters
$elementId : array<string|int, mixed>

field=>value-type condition array identifying an entry

Tags
throws
Exception

If something did not go as planned

setIdentifier()

Set the identifier

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

setOptions()

Set the options

public setOptions(array<string|int, mixed> $options) : mixed
Parameters
$options : array<string|int, mixed>

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

supportsOperation()

Tells whether operation $operation is supported by this DataSource

public supportsOperation(string $operation) : bool
Parameters
$operation : string

Name of an operation

Return values
bool

True if $operation is supported by this DataSource

update()

Updates an existing entry of this DataSource

public abstract update(array<string|int, mixed> $elementId, array<string|int, mixed> $data) : mixed
Parameters
$elementId : array<string|int, mixed>

field=>value-type condition array identifying an entry

$data : array<string|int, mixed>

Field=>value-type array. Not all fields are required.

Tags
throws
Exception

If something did not go as planned

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


        
On this page

Search results