ParentFieldManager
Table of Contents
Constants
- FIELD_PARENT_PREFIX = 'PARENT_ID'
- URL_PARAM_PARENT_ID = 'parentId'
- URL_PARAM_PARENT_TYPE_ID = 'parentTypeId'
Methods
- addParentFieldsReferences() : void
- Add references to EntityRelationTable for all custom relations with $entity.
- addParentItemToUrl() : void
- Add data about parent item to url.
- getEntityTypeIdFromFieldName() : int
- Get id of a parent entity from field name e.g. PARENT_ID_128 - return 128
- getItemIdentifierFromFilterValue() : ItemIdentifier|null
- Extract ItemIdentifier from filter $value.
- getParentFieldFilterValuePrefix() : string
- Return prefix for value to encode value in filter.
- getParentFieldName() : string
- Create a field name for the parent entity
- getParentFields() : array<string|int, mixed>
- Return an array of items of a parents entities with binding to the elements of the current entity.
- getParentFieldsInfo() : array<string|int, mixed>
- Return parent fields description for entity $entityTypeId in the same format as Factory::getFieldsInfo()
- getParentFieldsOptionsForFilterProvider() : array<string|int, mixed>
- Adds information about parent fields into $fields in filter data provider format.
- getParentFieldsSqlInfo() : array<string|int, mixed>
- Return parent fields description with info about how database should obtain their values.
- isParentFieldName() : bool
- Check if a field name is a parent field name, e.g. PARENT_ID_128 - this is a field that refers to the parent entity with id = 128
- loadParentElementsByChildren() : array<string|int, mixed>
- Method return data in the same format as getParentFields.
- prepareGridHeaders() : void
- Adds grid headers description with parent fields of entity with $entityTypeId to $headers.
- prepareParentFieldDataForFilterProvider() : array<string|int, array<string|int, mixed>>
- Return field description with code $fieldID for $entityTypeId in filter data provider format.
- saveItemRelations() : Result
- Save relations of the $item passed in $data.
- saveParentRelationsForIdentifier() : Result
- Save parent relations passed in $data for identifier $childIdentifier.
- transformEncodedFilterValueIntoInteger() : int|null
- Transforms string value (like "CRMLEAD_1") into entity identifier if possible.
- tryParseParentItemFromRequest() : ItemIdentifier|null
- Parses data about parent item from request.
- tryPrepareListComponentParametersWithParentItem() : bool
- If $componentParams has data about parent item, then checks permission to it.
Constants
FIELD_PARENT_PREFIX
public
mixed
FIELD_PARENT_PREFIX
= 'PARENT_ID'
URL_PARAM_PARENT_ID
public
mixed
URL_PARAM_PARENT_ID
= 'parentId'
URL_PARAM_PARENT_TYPE_ID
public
mixed
URL_PARAM_PARENT_TYPE_ID
= 'parentTypeId'
Methods
addParentFieldsReferences()
Add references to EntityRelationTable for all custom relations with $entity.
public
addParentFieldsReferences(Entity $entity, int $entityTypeId) : void
Parameters
- $entity : Entity
- $entityTypeId : int
addParentItemToUrl()
Add data about parent item to url.
public
static addParentItemToUrl(int $childEntityTypeId, ItemIdentifier $parentIdentifier, Uri $url) : void
Parameters
- $childEntityTypeId : int
- $parentIdentifier : ItemIdentifier
- $url : Uri
getEntityTypeIdFromFieldName()
Get id of a parent entity from field name e.g. PARENT_ID_128 - return 128
public
static getEntityTypeIdFromFieldName(string $fieldName) : int
Parameters
- $fieldName : string
Return values
intgetItemIdentifierFromFilterValue()
Extract ItemIdentifier from filter $value.
public
static getItemIdentifierFromFilterValue(mixed $value[, int|null $entityTypeId = null ]) : ItemIdentifier|null
If $entityTypeId is not passed - it will be got from encoded string $value.
Parameters
- $value : mixed
- $entityTypeId : int|null = null
Return values
ItemIdentifier|nullgetParentFieldFilterValuePrefix()
Return prefix for value to encode value in filter.
public
static getParentFieldFilterValuePrefix(int $entityTypeId) : string
Parameters
- $entityTypeId : int
Return values
stringgetParentFieldName()
Create a field name for the parent entity
public
static getParentFieldName(mixed $entityTypeId) : string
Parameters
- $entityTypeId : mixed
Return values
stringgetParentFields()
Return an array of items of a parents entities with binding to the elements of the current entity.
public
getParentFields(array<string|int, mixed> $itemIds, array<string|int, mixed> $entityFields, int $entityTypeId) : array<string|int, mixed>
Load parent fields values from database. Return array of the structure: [childEntityTypeId] => [parentEntityTypeId] => [parentEntityId] => [ 'id' => parentEntityId, 'code' => PARENT_ID_{parentEntityTypeId}, 'entityDescription' => parentEntityDescription (Lead / Deal etc.), 'title' => parentEntityTitle, 'url' => parentEntityDetailUrl, 'value' => '' . title . '', ]
Parameters
- $itemIds : array<string|int, mixed>
-
Array of items IDs
- $entityFields : array<string|int, mixed>
-
Array of parent fields names
- $entityTypeId : int
-
ID current (children) entity
Return values
array<string|int, mixed> —Array of items of a parents entities
getParentFieldsInfo()
Return parent fields description for entity $entityTypeId in the same format as Factory::getFieldsInfo()
public
getParentFieldsInfo(int $entityTypeId) : array<string|int, mixed>
Parameters
- $entityTypeId : int
Return values
array<string|int, mixed>getParentFieldsOptionsForFilterProvider()
Adds information about parent fields into $fields in filter data provider format.
public
getParentFieldsOptionsForFilterProvider(int $entityTypeId) : array<string|int, mixed>
Parameters
- $entityTypeId : int
Return values
array<string|int, mixed>getParentFieldsSqlInfo()
Return parent fields description with info about how database should obtain their values.
public
getParentFieldsSqlInfo(int $entityTypeId, string $entitySqlTableAlias) : array<string|int, mixed>
Parameters
- $entityTypeId : int
- $entitySqlTableAlias : string
Tags
Return values
array<string|int, mixed>isParentFieldName()
Check if a field name is a parent field name, e.g. PARENT_ID_128 - this is a field that refers to the parent entity with id = 128
public
static isParentFieldName(string $fieldName) : bool
Parameters
- $fieldName : string
Return values
boolloadParentElementsByChildren()
Method return data in the same format as getParentFields.
public
loadParentElementsByChildren(int $childEntityTypeId, array<string|int, mixed> $items) : array<string|int, mixed>
This method does not load parent field values from database, only description of parent items.
Parameters
- $childEntityTypeId : int
-
- identifier of the $items.
- $items : array<string|int, mixed>
-
- flat array where each element - item's data.
Return values
array<string|int, mixed>prepareGridHeaders()
Adds grid headers description with parent fields of entity with $entityTypeId to $headers.
public
prepareGridHeaders(int $entityTypeId, array<string|int, mixed> &$headers) : void
Parameters
- $entityTypeId : int
- $headers : array<string|int, mixed>
prepareParentFieldDataForFilterProvider()
Return field description with code $fieldID for $entityTypeId in filter data provider format.
public
prepareParentFieldDataForFilterProvider(int $entityTypeId, string $fieldId) : array<string|int, array<string|int, mixed>>
Parameters
- $entityTypeId : int
- $fieldId : string
Return values
array<string|int, array<string|int, mixed>>saveItemRelations()
Save relations of the $item passed in $data.
public
saveItemRelations(Item $item, array<string|int, mixed> $data) : Result
Parameters
- $item : Item
- $data : array<string|int, mixed>
Return values
ResultsaveParentRelationsForIdentifier()
Save parent relations passed in $data for identifier $childIdentifier.
public
saveParentRelationsForIdentifier(ItemIdentifier $childIdentifier, array<string|int, mixed> $data) : Result
Parameters
- $childIdentifier : ItemIdentifier
- $data : array<string|int, mixed>
Return values
ResulttransformEncodedFilterValueIntoInteger()
Transforms string value (like "CRMLEAD_1") into entity identifier if possible.
public
static transformEncodedFilterValueIntoInteger(string $fieldName, mixed $value) : int|null
If value is not correct or empty returns null.
Parameters
- $fieldName : string
- $value : mixed
Return values
int|nulltryParseParentItemFromRequest()
Parses data about parent item from request.
public
static tryParseParentItemFromRequest([Request|null $request = null ]) : ItemIdentifier|null
If item is found - return identifier.
Parameters
- $request : Request|null = null
Return values
ItemIdentifier|nulltryPrepareListComponentParametersWithParentItem()
If $componentParams has data about parent item, then checks permission to it.
public
tryPrepareListComponentParametersWithParentItem(int $entityTypeId, array<string|int, mixed> &$componentParams) : bool
If user has permissions then into $componentParameters adds info about inner filter by this item.
Return true if $componentParams has been modified successfully.
Parameters
- $entityTypeId : int
- $componentParams : array<string|int, mixed>