CSCometItemApiReferenceList
extends CSItemApiReferenceList
in package
Class CSCometItemApiReferenceList Defines a special CSCometItemApiReferenceList to the comet items
Note: Since CS16.1 all methods with 'product' were deleted use the corresponding method with 'item' in name.
Tags
Table of Contents
- add() : CSCometItemApiReference|null
- Adds a new row to the Table at a given position
- addMultiple() : null|array<string|int, CSItemApiReference>
- This Method can add multiple references from different record types at once
- addMultipleWithAttributes() : array<string|int, CSItemApiReference>|null
- Allows to add multiple references with different record classes with each having its own attributes at once
- clearCache() : void
- Clears the internal Item reference cache for this list
- delete() : true
- removes the references with the passed ids
- getFieldID() : int
- Returns the ID of the Field the references belong to.
- getFields() : array<string|int, mixed>
- Returns all fields of the configuration (a.k.a. class) associated with the references for an attribute of an item.
- getGroupedIds() : array<string|int, mixed>
- Returns the references for an attribute of a item as grouped array.
- getID() : int
- Returns the ID of the first selected reference
- getIDs() : array<string|int, mixed>
- Returns an array of the selected references in the form ReferenceID => TargetID
- getIterator() : array<string|int, CSItemApiReference>
- getLanguageID() : int
- Returns the languageID of the references belong to.
- getMappedConfigurationLabels() : array<string|int, mixed>
- Returns a mapping of Labels to ConfigIDs for the current ReferenceList fields
- getReference() : null|CSItemApiReference
- Returns the first (only) CSItemApiReference for the given list
- getReferenceClass() : Itemconfiguration
- Returns the configuration (a.k.a. class) associated with the references for an attribute of an item.
- getReferenceForTargetID() : null|CSItemApiReference
- Returns the first (only) CSItemApiReference
- getReferenceForTargetItem() : null|CSItemApiReference
- Returns the first (only) CSItemApiReference
- getReferenceForValues() : null|CSItemApiReference
- Returns the first (only) CSItemApiReference for the given list
- getReferences() : array<string|int, CSItemApiReference>
- Returns the CSItemApiReferences of all defined References for the given list
- getSource() : CSItemApiItem
- Returns the source of the References
- getTargetInstance() : Item
- Returns an empty instance of the first referenced target object.
- getTargetInstances() : array<string|int, Item>
- Returns empty instances of all references target objects.
- getTargetItems() : array<string|int, CSItemApiItem>
- Returns target items of the References.
- getValues() : array<string|int, mixed>
- Returns the additional values that are associated with the references for an attribute of an item.
- setValues() : bool
- Associates multiple additional values with the references for an attribute of an item.
Methods
add()
Adds a new row to the Table at a given position
public
add(int|array<string|int, mixed>|array<string|int, CSItemApiItem>|CSItemApiItem|array<string|int, Item> $refIDs[, array<string|int, mixed> $attributes = array() ][, int $position = -1 ][, string|int $sClassName = null ]) : CSCometItemApiReference|null
Parameters
- $refIDs : int|array<string|int, mixed>|array<string|int, CSItemApiItem>|CSItemApiItem|array<string|int, Item>
-
Either an ID or a list of IDs to add. Or an Array of objects.
- $attributes : array<string|int, mixed> = array()
-
Additional attributes which should be added to the reference
- $position : int = -1
-
The position where the reference should be added: -1 or TRUE: insert as last element 0 or FALSE: insert as first element 1: insert as second, ...
- $sClassName : string|int = null
-
A class name like (Pdmarticle or Pdmarticlestructure or TableInfo ClassID) for which the to added Ids belongs
Tags
Return values
CSCometItemApiReference|null —The created reference or NULL if invalid data is given or could not be stored.
addMultiple()
This Method can add multiple references from different record types at once
public
addMultiple(array<string|int, int>|array<string|int, Item> $aoItems[, array<string|int, mixed> $aAttributes = array() ][, bool $bInsertAtEnd = true ]) : null|array<string|int, CSItemApiReference>
Parameters
- $aoItems : array<string|int, int>|array<string|int, Item>
-
Either an 2-dimensional array containing the record class as key and an array of recordIDs as value or an one-dimensional array of Items|CSItemApiItems
- $aAttributes : array<string|int, mixed> = array()
-
Either an array containing all attributes or a 2-dimensional array containing the record class as key and the attributes as array per record class
- $bInsertAtEnd : bool = true
-
true to insert the items at the end. false to insert them at top
Tags
Return values
null|array<string|int, CSItemApiReference> —Either null, if something went wrong or an array containing the added references
addMultipleWithAttributes()
Allows to add multiple references with different record classes with each having its own attributes at once
public
addMultipleWithAttributes(array<string|int, mixed> $aItemIDsWithAttributes[, int $iPosition = -1 ]) : array<string|int, CSItemApiReference>|null
Parameters
- $aItemIDsWithAttributes : array<string|int, mixed>
-
An 3-dimensional array like array( [ItemClassName1] => array( [ItemID1] => array([Att1] => [Content1], [Att1] => [Content2], ...), [ItemID2] => array([Att1] => [Content1], [Att1] => [Content2], ...), ), [ItemClassName2] => array (...), .... )
- $iPosition : int = -1
-
The position where the reference should be added: -1: insert as last element 0: insert as first element 1: insert as second, ...
Tags
Return values
array<string|int, CSItemApiReference>|null —An array containing the added references or null if an error occured
clearCache()
Clears the internal Item reference cache for this list
public
clearCache() : void
Tags
Return values
void —delete()
removes the references with the passed ids
public
delete(int|array<string|int, mixed> $aRefIDs[, bool $bIdsAreReferenceIDs = FALSE ]) : true
Parameters
- $aRefIDs : int|array<string|int, mixed>
-
either an ID or a list of IDs to delete
- $bIdsAreReferenceIDs : bool = FALSE
-
whether the passed references are IDs of the target (FALSE) or the IDs of the references itself (TRUE)
Tags
Return values
true —on success otherwise false
getFieldID()
Returns the ID of the Field the references belong to.
public
getFieldID() : int
Tags
Return values
int —FieldID
getFields()
Returns all fields of the configuration (a.k.a. class) associated with the references for an attribute of an item.
public
getFields([bool $bIncludeContainerConfig = false ]) : array<string|int, mixed>
Parameters
- $bIncludeContainerConfig : bool = false
-
If set to TRUE, the configuration link containing all the fields (a.k.a. parent configuration) is included in the results.
Tags
Return values
array<string|int, mixed> —An array of item configurations. These are the attributes attached to the references stored in the attribute Returns an empty array if no configuration has been defined for the reference attribute.
getGroupedIds()
Returns the references for an attribute of a item as grouped array.
public
getGroupedIds([bool $allowInheritance = true ]) : array<string|int, mixed>
Like: [ 'Pdmarticle' => [{ReferenceID} => {PdmarticleID}, {ReferenceID} => {PdmarticleID}, ...], 'Mamfile' => [{ReferenceID} => {MamfileID}, ...] ]
Parameters
- $allowInheritance : bool = true
-
If inherited references should be added for additive inheritance
Tags
Return values
array<string|int, mixed> —An array of references
getID()
Returns the ID of the first selected reference
public
getID([bool $allowInheritance = true ]) : int
Parameters
- $allowInheritance : bool = true
-
whether inheritance may be used
Tags
Return values
int —the ID of the first (only) selected reference or null, if no reference exists
getIDs()
Returns an array of the selected references in the form ReferenceID => TargetID
public
getIDs([bool $allowInheritance = true ]) : array<string|int, mixed>
Parameters
- $allowInheritance : bool = true
-
whether inheritance may be used
Tags
Return values
array<string|int, mixed> —of selected reference IDs
getIterator()
public
getIterator() : array<string|int, CSItemApiReference>
Tags
Return values
array<string|int, CSItemApiReference> —getLanguageID()
Returns the languageID of the references belong to.
public
getLanguageID() : int
Tags
Return values
int —the ID of the references language
getMappedConfigurationLabels()
Returns a mapping of Labels to ConfigIDs for the current ReferenceList fields
public
getMappedConfigurationLabels() : array<string|int, mixed>
Tags
Return values
array<string|int, mixed> —of [Label] => [ID] pairs
getReference()
Returns the first (only) CSItemApiReference for the given list
public
getReference([int $referenceID = null ]) : null|CSItemApiReference
Parameters
- $referenceID : int = null
-
the optional IDs the target must have to get a specific reference
Tags
Return values
null|CSItemApiReference —the reference or null, if no reference is defined
getReferenceClass()
Returns the configuration (a.k.a. class) associated with the references for an attribute of an item.
public
getReferenceClass() : Itemconfiguration
Tags
Return values
Itemconfiguration —The item configuration containing the attributes attached to the references stored in the attribute Returns an empty Itemconfiguration object if no configuration has been defined for the reference attribute.
getReferenceForTargetID()
Returns the first (only) CSItemApiReference
public
getReferenceForTargetID([int $iTargetId = null ][, string|CSItemApiItem|Record $sTargetClassName = null ]) : null|CSItemApiReference
Parameters
- $iTargetId : int = null
-
the optional IDs the target item must have to get a specific reference
- $sTargetClassName : string|CSItemApiItem|Record = null
-
The optional Target object Class Name (like Pdmarticle or Pdmarticlestructure) or an CSItemApiItem / Item object
Tags
Return values
null|CSItemApiReference —the reference or null, if no reference is defined
getReferenceForTargetItem()
Returns the first (only) CSItemApiReference
public
getReferenceForTargetItem(CSItemApiItem $oApiItem) : null|CSItemApiReference
Parameters
- $oApiItem : CSItemApiItem
Tags
Return values
null|CSItemApiReference —the reference or null, if no reference is defined
getReferenceForValues()
Returns the first (only) CSItemApiReference for the given list
public
getReferenceForValues(array<string|int, mixed> $values) : null|CSItemApiReference
Parameters
- $values : array<string|int, mixed>
-
additional attributes which should be matched (ID and ReferenceID can also be used to access the TargetID or the ReferenceID). Those values have the form [ATTRIBUTE] => [VALUE] where [VALUE] might be a simple value or an array of possible values
Tags
Return values
null|CSItemApiReference —the reference or null, if no reference is defined
getReferences()
Returns the CSItemApiReferences of all defined References for the given list
public
getReferences([bool $allowInheritance = true ][, array<string|int, mixed> $values = array() ]) : array<string|int, CSItemApiReference>
Parameters
- $allowInheritance : bool = true
-
whether inheritance may be used
- $values : array<string|int, mixed> = array()
-
additional attributes which should be matched (ID and ReferenceID can also be used to access the TargetID or the ReferenceID). Those values have the form [ATTRIBUTE] => [VALUE] where [VALUE] might be a simple value or an array of possible values
Tags
Return values
array<string|int, CSItemApiReference> —getSource()
Returns the source of the References
public
getSource() : CSItemApiItem
Tags
Return values
CSItemApiItem —the source
getTargetInstance()
Returns an empty instance of the first referenced target object.
public
getTargetInstance() : Item
Note: Since CS16.1 CSItemApiReferenceList supports references to multiple objects. So this function returns only the first referenced target object!!!
Tags
Return values
Item —an empty target instance object.
getTargetInstances()
Returns empty instances of all references target objects.
public
getTargetInstances() : array<string|int, Item>
Tags
Return values
array<string|int, Item> —An array of empty (dummy) target instances or an empty array if target instances are invalid
getTargetItems()
Returns target items of the References.
public
getTargetItems() : array<string|int, CSItemApiItem>
Tags
Return values
array<string|int, CSItemApiItem> —An array with an item for each reference
getValues()
Returns the additional values that are associated with the references for an attribute of an item.
public
getValues([mixed $mRequestedAttrKeys = null ][, bool $bShowInherited = true ]) : array<string|int, mixed>
Parameters
- $mRequestedAttrKeys : mixed = null
-
A string, int or an array containing the ID(s)/label(s) of the attributes to retrieve from the references. If set to NULL, all available attributes will be retrieved. If a second or third target with the given ID is existing, it may be accessed using a suffix _[COUNTER], e.g. 11, 11_2, 11_3, ...
- $bShowInherited : bool = true
-
Set to TRUE if inherited references should be added for additive inheritance.
Tags
Return values
array<string|int, mixed> —A two-dimensional array containing the reference attribute values. The first dimension designates the IDs of the reference target item(s), the second dimension is indexed by the original $mRequestedAttrKeys.
setValues()
Associates multiple additional values with the references for an attribute of an item.
public
setValues([array<string|int, mixed> $aasReferencesValues = array() ]) : bool
Parameters
- $aasReferencesValues : array<string|int, mixed> = array()
-
A two-dimensional array containing the reference attribute values, grouped by the ReferenceIDs (first dimension's key) and the reference attribute IDs/labels (second dimension's key). Non-existent ReferenceIDs will be ignored. Upon storing the values, they will be implicitly type casted into a string.
Tags
Return values
bool —TRUE on success or FALSE if the new reference attribute values could not be set.
