CRUDlex\EntityDefinition¶
-
class
EntityDefinition
¶ The class for defining a single entity.
-
property
table
¶ protected
The table where the data is stored.
-
property
fields
¶ protected
Holds all fields in the same structure as in the CRUD YAML file.
-
property
label
¶ protected
The label for the entity.
-
property
localeLabels
¶ protected
The labels of the entity in the locales.
-
property
children
¶ protected
An array with the children referencing the entity. All entries are arrays with three referencing elements: table, fieldName, entity
-
property
standardFieldLabels
¶ protected
Labels for the fields “id”, “created_at” and “updated_at”.
-
property
listFields
¶ protected
An array containing the fields which should appear in the list view of the entity.
-
property
childrenLabelFields
¶ protected
The fields used to display the children on the details page of an entity. The keys are the entity names as in the CRUD YAML and the values are the field names.
-
property
deleteCascade
¶ protected
Whether to delete its children when an instance is deleted.
-
property
pageSize
¶ protected
The amount of items to display per page on the listview.
-
property
filter
¶ protected
The fields offering to be filtered.
-
property
locale
¶ protected
Holds the locale.
-
property
initialSortField
¶ protected
Holds the initial sort field.
-
property
initialSortAscending
¶ protected
Holds the initial sort order.
-
getFilteredFieldNames
($exclude)¶ Gets the field names exluding the given ones.
Parameters: - $exclude (string[]) – the field names to exclude
Returns: array all field names excluding the given ones
-
getFieldValue
($name, $key)¶ Gets the value of a field key.
Parameters: - $name (string) – the name of the field
- $key (string) – the value of the key
Returns: mixed the value of the field key or null if not existing
-
setFieldValue
($name, $key, $value)¶ Sets the value of a field key. If the field or the key in the field don’t exist, they get created.
Parameters: - $name (string) – the name of the field
- $key (string) – the value of the key
- $value (mixed) – the new value
-
getReferenceValue
($fieldName, $key)¶ Gets the value of a reference field.
Parameters: - $fieldName (string) – the field name of the reference
- $key (string) – the key of the reference value
Returns: string the value of the reference field
-
isConstraint
($fieldName, $constraint)¶ Checks if the given field has the given constraint.
Parameters: - $fieldName (string) – the field name maybe having the constraint
- $constraint (string) – the constraint to check, ‘required’ or ‘unique’
Returns: boolean true if the given field has the given constraint
-
__construct
($table, $fields, $label, $localeLabels, $standardFieldLabels, ServiceProvider $serviceProvider)¶ Constructor.
Parameters: - $table (string) – the table of the entity
- $fields (array) – the fieldstructure just like the CRUD YAML
- $label (string) – the label of the entity
- $localeLabels (array) – the labels of the entity in the locales
- $standardFieldLabels (array) – labels for the fields “id”, “created_at” and “updated_at”
- $serviceProvider (ServiceProvider) – The current service provider
-
getFieldNames
()¶ Gets all field names, including the implicit ones like “id” or “created_at”.
Returns: string[] the field names
-
setListFields
($listFields)¶ Sets the field names to be used in the listview.
Parameters: - $listFields (array) – the field names to be used in the listview
-
getListFields
()¶ Gets the field names to be used in the listview. If they were not specified, all public field names are returned.
Returns: array the field names to be used in the listview
-
getChildrenLabelFields
()¶ Gets the fields used to display the children on the details page of an entity. The keys are the entity names as in the CRUD YAML and the values are the field names.
Returns: array the fields used to display the children on the details page
-
setChildrenLabelFields
($childrenLabelFields)¶ Sets the fields used to display the children on the details page of an entity. The keys are the entity names as in the CRUD YAML and the values are the field names.
Parameters: - $childrenLabelFields (array) – the fields used to display the children on the details page
-
isDeleteCascade
()¶ Gets whether to delete its children when an instance is deleted.
Returns: boolean true if so
-
setDeleteCascade
($deleteCascade)¶ Sets whether to delete its children when an instance is deleted.
Parameters: - $deleteCascade (boolean) – whether to delete its children when an instance is deleted
-
getPageSize
()¶ Gets the amount of items to display per page on the listview.
Returns: integer the amount of items to display per page on the listview
-
setPageSize
($pageSize)¶ Sets the amount of items to display per page on the listview.
Parameters: - $pageSize (integer) – the amount of items to display per page on the listview
-
getFilter
()¶ Gets the fields offering a filter.
Returns: array the fields to filter
-
setFilter
($filter)¶ Sets the fields offering a filter.
Parameters: - $filter (array) – the fields to filter
-
getServiceProvider
()¶ Gets the service provider.
Returns: ServiceProvider the service provider
-
setServiceProvider
(ServiceProvider $serviceProvider)¶ Sets the service provider.
Parameters: - $serviceProvider (ServiceProvider) – the new service provider
-
getPublicFieldNames
()¶ Gets the public field names. The internal fields “version” and “deleted_at” are filtered.
Returns: array the public field names
-
getEditableFieldNames
()¶ Gets the field names which are editable. Not editable are fields like the id or the created_at.
Returns: array the editable field names
-
getReadOnlyFields
()¶ Gets the read only field names like the id or the created_at.
Returns: string[] the read only field names
-
getType
($fieldName)¶ Gets the type of a field.
Parameters: - $fieldName (string) – the field name
Returns: string the type or null on invalid field name
-
setType
($fieldName, $value)¶ Sets the type of a field.
Parameters: - $fieldName (string) – the field name
- $value (string) – the new field type
-
isRequired
($fieldName)¶ Gets whether a field is required.
Parameters: - $fieldName (string) – the field name
Returns: boolean true if so
-
setRequired
($fieldName, $value)¶ Sets whether a field is required.
Parameters: - $fieldName (string) – the new required state
- $value –
-
isUnique
($fieldName)¶ Gets whether a field is unique.
Parameters: - $fieldName (string) – the field name
Returns: boolean true if so
-
setUnique
($fieldName, $value)¶ Sets whether a field is unique.
Parameters: - $fieldName (string) – the field name
- $value (boolean) – true if so
-
getReferenceTable
($fieldName)¶ Gets the table field of a reference.
Parameters: - $fieldName (string) – the field name of the reference
Returns: string the table field of a reference or null on invalid field name
-
getReferenceNameField
($fieldName)¶ Gets the name field of a reference.
Parameters: - $fieldName (string) – the field name of the reference
Returns: string the name field of a reference or null on invalid field name
-
getReferenceEntity
($fieldName)¶ Gets the entity field of a reference.
Parameters: - $fieldName (string) – the field name of the reference
Returns: string the entity field of a reference or null on invalid field name
-
getFilePath
($fieldName)¶ Gets the file path of a field.
Parameters: - $fieldName (string) – the field name
Returns: string the file path of a field or null on invalid field name
-
setFilePath
($fieldName, $value)¶ Sets the file path of a field.
Parameters: - $fieldName (string) – the field name
- $value (string) – the file path of a field or null on invalid field name
-
getFixedValue
($fieldName)¶ Gets the value of a fixed field.
Parameters: - $fieldName (string) – the field name
Returns: string the value of a fixed field or null on invalid field name
-
setFixedValue
($fieldName, $value)¶ Sets the value of a fixed field.
Parameters: - $fieldName (string) – the field name
- $value (string) – the new value for the fixed field
-
getSetItems
($fieldName)¶ Gets the items of a set field.
Parameters: - $fieldName (string) – the field name
Returns: array the items of the set field or null on invalid field name
-
setSetItems
($fieldName, $value)¶ Sets the items of a set field.
Parameters: - $fieldName (string) – the field name
- $value (string) – the new items of the set field
-
getFloatStep
($fieldName)¶ Gets the step size of a float field.
Parameters: - $fieldName (string) – the field name
Returns: array the step size of a float field or null on invalid field name
-
setFloatStep
($fieldName, $value)¶ Sets the step size of a float field.
Parameters: - $fieldName (string) – the field name
- $value (string) – the new step size of the float field
-
getFieldLabel
($fieldName)¶ Gets the label of a field.
Parameters: - $fieldName (string) – the field name
Returns: string the label of the field or the field name if no label is set in the CRUD YAML
-
setFieldLabel
($fieldName, $value)¶ Gets the label of a field.
Parameters: - $fieldName (string) – the field name
- $value (string) – the new label of the field
-
getTable
()¶ Gets the table where the data is stored.
Returns: string the table where the data is stored
-
setTable
($table)¶ Sets the table where the data is stored.
Parameters: - $table (string) – the new table where the data is stored
-
getLabel
()¶ Gets the label for the entity.
Returns: string the label for the entity
-
setLabel
($label)¶ Sets the label for the entity.
Parameters: - $label (string) – the new label for the entity
-
getDescription
($fieldName)¶ Gets the description of a field.
Parameters: - $fieldName (string) – the field name
Returns: string the description of the field
-
setDescription
($fieldName, $value)¶ Sets the description of a field.
Parameters: - $fieldName (string) – the field name
- $value (string) – the new description of the field
-
addChild
($table, $fieldName, $entity)¶ Adds a child to this definition in case the other definition has a reference to this one.
Parameters: - $table (string) – the table of the referencing definition
- $fieldName (string) – the field name of the referencing definition
- $entity (string) – the entity of the referencing definition
-
getChildren
()¶ Gets the referencing children to this definition.
Returns: array an array with the children referencing the entity. All entries are arrays with three referencing elements: table, fieldName, entity
-
setLocale
($locale)¶ Sets the locale to be used.
Parameters: - $locale (string) – the locale to be used.
-
setInitialSortField
($initialSortField)¶ Sets the initial sort field.
Parameters: - $initialSortField (string) – the new initial sort field
-
getInitialSortField
()¶ Gets the initial sort field.
Returns: string the initial sort field
-
setInitialSortAscending
($initialSortAscending)¶ Sets the initial sort order.
Parameters: - $initialSortAscending (boolean) – the initial sort order, true if ascending
-
isInitialSortAscending
()¶ Gets the initial sort order.
Returns: boolean the initial sort order, true if ascending
-
property