JsonDataSource
extends DataSource
in package
JsonDataSource
Tags
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
$dataAccesses
protected
Collection
$dataAccesses
$id
protected
int
$id
$identifier
protected
string
$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
$nestingCount
Counts the nesting level of __call()
protected
static int
$nestingCount
= 0
$options
protected
string
$options
$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
$supportedOperations
List of operations supported by this DataSource
protected
array<string|int, mixed>
$supportedOperations
= array('eq')
List of operations
$type
protected
string
$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
Attributes
- #[ReturnTypeWillChange]
Return values
mixed —Return value of the method to call
__construct()
Constructor
public
__construct() : mixed
__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
add(array<string|int, mixed> $data) : mixed
Parameters
- $data : array<string|int, mixed>
-
Field=>value-type array. Not all fields may be required.
Tags
addDataAccess()
Add dataAccesses
public
addDataAccess(DataAccess $dataAccesses) : DataSource
Parameters
- $dataAccesses : DataAccess
Return values
DataSourceget()
Gets one or more entries from this DataSource
public
get([mixed $elementId = array() ][, mixed $filter = array() ][, mixed $order = array() ][, mixed $limit = 0 ][, mixed $offset = 0 ][, mixed &$count = 0 ][, mixed $fieldList = array() ]) : array<string|int, mixed>
Parameters
- $elementId : mixed = array()
-
(optional) field=>value-type condition array identifying an entry
- $filter : mixed = array()
-
(optional) field=>value-type condition array, only supports = for now
- $order : mixed = array()
-
(optional) field=>order-type array, order is either "ASC" or "DESC"
- $limit : mixed = 0
-
(optional) If set, no more than $limit results are returned
- $offset : mixed = 0
-
(optional) Entry to start with
- $count : mixed = 0
-
(optional / passed by reference) Will be set to the total matched entries
- $fieldList : mixed = array()
-
(optional) Limits the result to the values for the fields in this list
Tags
Return values
array<string|int, mixed> —Two dimensional array (/table) of results (array($row=>array($fieldName=>$value)))
getComponentController()
Returns the component controller for this component
public
getComponentController() : SystemComponent
Return values
SystemComponentgetCurrentVersion()
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
typegetId()
Get id
public
getId() : int
Return values
int —$id
getIdentifier()
Get the identifier
public
getIdentifier() : string
Return values
string —$identifier
getIdentifierFieldNames()
Returns a list of field names that uniquely identify objects
public
getIdentifierFieldNames() : array<string|int, mixed>
Tags
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
listFields() : array<string|int, mixed>
Return values
array<string|int, mixed> —List of field names
remove()
Drops an entry from this DataSource
public
remove(array<string|int, mixed> $elementId) : mixed
Parameters
- $elementId : array<string|int, mixed>
-
field=>value-type condition array identifying an entry
Tags
removeDataAccess()
Remove dataAccesses
public
removeDataAccess(DataAccess $dataAccesses) : mixed
Parameters
- $dataAccesses : DataAccess
setDataAccesses()
Set the data access
public
setDataAccesses(DataAccess $dataAccesses) : mixed
Parameters
- $dataAccesses : DataAccess
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
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
validate()
public
validate() : mixed
Tags
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