Documentation

DoctrineRepository extends DataSource

DoctrineRepository

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()  : string
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
Check if the DataSource is Gedmo\Loggable.
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
getEntityIndexData()  : mixed
getFallbackLocaleCodes()  : array<string|int, mixed>
Returns a list of all locale codes ordered by fallback order
getRepository()  : EntityRepository
Returns the repository for this DataSource
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
init()  : mixed
Perform initializations
resolveRecursedRelations()  : mixed
Prepares an array with all relation recursions to do for this DataSource
setEntityData()  : mixed
Sets data for an entity

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('lt', 'gt', 'lte', 'gte', 'in', 'eq', 'not')

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 add(array<string|int, mixed> $data) : string
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

Return values
string —

ID of the new entry

get()

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
inheritdoc
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
Parameters
$elementId : array<string|int, mixed>

array identifying an entry

Tags
inheritDoc
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 getIdentifierFieldNames() : array<string|int, mixed>
Tags
inheritdoc
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()

Check if the DataSource is Gedmo\Loggable.

public isVersionable() : bool
Tags
inheritDoc
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
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 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

getEntityIndexData()

protected getEntityIndexData(mixed $entity) : mixed
Parameters
$entity : mixed
Tags
todo:

This method should be elsewhere

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

getRepository()

Returns the repository for this DataSource

protected getRepository() : EntityRepository
Return values
EntityRepository —

Repository for this DataSource

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

resolveRecursedRelations()

Prepares an array with all relation recursions to do for this DataSource

protected resolveRecursedRelations(array<string|int, mixed> $forcedRecursions, array<string|int, mixed> $skippedRecursions[, string|null $entityClass = '' ][, array<string|int, mixed>|null $output = array() ][, string|null $prefix = 'x.' ][, array<string|int, mixed>|null $exclusionList = array() ]) : mixed

Automatically recurses all "to 1" and n:n reltions

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

List of relations to force anyway

$skippedRecursions : array<string|int, mixed>

List of relations to not recurse to

$entityClass : string|null = ''

Fully qualified entity class name to parse relations of

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

Previously generated part of end result

$prefix : string|null = 'x.'

Prefix for keys in $output

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

List of fully qualified class names to ignore

setEntityData()

Sets data for an entity

protected setEntityData(EntityBase $entity, array<string|int, mixed> $data) : mixed
Parameters
$entity : EntityBase

Entity to set data

$data : array<string|int, mixed>

Field=>$value-type array

Tags
todo

Check relations

On this page

Search results