PHP Class CRUDlex\EntityDefinition

Mostra file Open project: philiplb/crudlex Class Usage Examples

Protected Properties

Property Type Description
$children An array with the children referencing the entity. All entries are arrays with three referencing elements: table, fieldName, entity
$childrenLabelFields The keys are the entity names as in the CRUD YAML and the values are the field names.
$deleteCascade Whether to delete its children when an instance is deleted.
$fields Holds all fields in the same structure as in the CRUD YAML file.
$filter The fields offering to be filtered.
$initialSortAscending Holds the initial sort order.
$initialSortField Holds the initial sort field.
$label The label for the entity.
$listFields An array containing the fields which should appear in the list view of the entity.
$locale Holds the locale.
$localeLabels The labels of the entity in the locales.
$pageSize The amount of items to display per page on the listview.
$serviceProvider Holds the {@see ServiceProvider}.
$standardFieldLabels Labels for the fields "id", "created_at" and "updated_at".
$table The table where the data is stored.

Public Methods

Method Description
__construct ( string $table, array $fields, string $label, array $localeLabels, array $standardFieldLabels, ServiceProvider $serviceProvider ) Constructor.
addChild ( string $table, string $fieldName, string $entity ) Adds a child to this definition in case the other definition has a reference to this one.
getChildren ( ) : array Gets the referencing children to this definition.
getChildrenLabelFields ( ) : array 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.
getEditableFieldNames ( ) : array Gets the field names which are editable. Not editable are fields like the id or the created_at.
getField ( string $name, string $key, mixed $default = null ) : mixed Gets the value of a field key.
getFieldLabel ( string $fieldName ) : string Gets the label of a field.
getFieldNames ( boolean $includeMany = false ) : string[] Gets all field names, including the implicit ones like "id" or "created_at".
getFilter ( ) : array Gets the fields offering a filter.
getInitialSortField ( ) : string Gets the initial sort field.
getLabel ( ) : string Gets the label for the entity.
getListFields ( ) : array Gets the field names to be used in the listview. If they were not specified, all public field names are returned.
getLocale ( ) : null | string Gets the locale to be used.
getPageSize ( ) : integer Gets the amount of items to display per page on the listview.
getPublicFieldNames ( ) : array Gets the public field names. The internal fields "version" and "deleted_at" are filtered.
getReadOnlyFields ( ) : string[] Gets the read only field names like the id or the created_at.
getServiceProvider ( ) : ServiceProvider Gets the service provider.
getSubTypeField ( string $fieldName, string $subType, string $key ) : string Gets a sub field of an field.
getTable ( ) : string Gets the table where the data is stored.
getType ( string $fieldName ) : string Gets the type of a field.
isDeleteCascade ( ) : boolean Gets whether to delete its children when an instance is deleted.
isInitialSortAscending ( ) : boolean Gets the initial sort order.
setChildrenLabelFields ( array $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.
setDeleteCascade ( boolean $deleteCascade ) Sets whether to delete its children when an instance is deleted.
setField ( string $name, string $key, mixed $value ) Sets the value of a field key. If the field or the key in the field don't exist, they get created.
setFieldLabel ( string $fieldName, string $value ) Gets the label of a field.
setFilter ( array $filter ) Sets the fields offering a filter.
setInitialSortAscending ( boolean $initialSortAscending ) Sets the initial sort order.
setInitialSortField ( string $initialSortField ) Sets the initial sort field.
setLabel ( string $label ) Sets the label for the entity.
setListFields ( array $listFields ) Sets the field names to be used in the listview.
setLocale ( string $locale ) Sets the locale to be used.
setPageSize ( integer $pageSize ) Sets the amount of items to display per page on the listview.
setServiceProvider ( ServiceProvider $serviceProvider ) Sets the service provider.
setTable ( string $table ) Sets the table where the data is stored.
setType ( string $fieldName, string $value ) Sets the type of a field.

Protected Methods

Method Description
checkFieldNames ( string $reference, array $fieldNames ) Checks whether the given field names are declared and existing.
getFilteredFieldNames ( array $exclude ) : array Gets the field names exluding the given ones.

Method Details

__construct() public method

Constructor.
public __construct ( string $table, array $fields, string $label, array $localeLabels, array $standardFieldLabels, ServiceProvider $serviceProvider )
$table string the table of the entity
$fields array the field structure 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

addChild() public method

Adds a child to this definition in case the other definition has a reference to this one.
public addChild ( string $table, string $fieldName, string $entity )
$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

checkFieldNames() protected method

Checks whether the given field names are declared and existing.
protected checkFieldNames ( string $reference, array $fieldNames )
$reference string a hint towards the source of an invalid field name
$fieldNames array the field names to check

getChildren() public method

Gets the referencing children to this definition.
public getChildren ( ) : array
return array an array with the children referencing the entity. All entries are arrays with three referencing elements: table, fieldName, entity

getChildrenLabelFields() public method

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.
public getChildrenLabelFields ( ) : array
return array the fields used to display the children on the details page

getEditableFieldNames() public method

Gets the field names which are editable. Not editable are fields like the id or the created_at.
public getEditableFieldNames ( ) : array
return array the editable field names

getField() public method

Gets the value of a field key.
public getField ( string $name, string $key, mixed $default = null ) : mixed
$name string the name of the field
$key string the value of the key
$default mixed the default value to return if nothing is found
return mixed the value of the field key or null if not existing

getFieldLabel() public method

Gets the label of a field.
public getFieldLabel ( string $fieldName ) : string
$fieldName string the field name
return string the label of the field or the field name if no label is set in the CRUD YAML

getFieldNames() public method

Gets all field names, including the implicit ones like "id" or "created_at".
public getFieldNames ( boolean $includeMany = false ) : string[]
$includeMany boolean whether to include the many fields as well
return string[] the field names

getFilter() public method

Gets the fields offering a filter.
public getFilter ( ) : array
return array the fields to filter

getFilteredFieldNames() protected method

Gets the field names exluding the given ones.
protected getFilteredFieldNames ( array $exclude ) : array
$exclude array the field names to exclude
return array all field names excluding the given ones

getInitialSortField() public method

Gets the initial sort field.
public getInitialSortField ( ) : string
return string the initial sort field

getLabel() public method

Gets the label for the entity.
public getLabel ( ) : string
return string the label for the entity

getListFields() public method

Gets the field names to be used in the listview. If they were not specified, all public field names are returned.
public getListFields ( ) : array
return array the field names to be used in the listview

getLocale() public method

Gets the locale to be used.
public getLocale ( ) : null | string
return null | string the locale to be used.

getPageSize() public method

Gets the amount of items to display per page on the listview.
public getPageSize ( ) : integer
return integer the amount of items to display per page on the listview

getPublicFieldNames() public method

Gets the public field names. The internal fields "version" and "deleted_at" are filtered.
public getPublicFieldNames ( ) : array
return array the public field names

getReadOnlyFields() public method

Gets the read only field names like the id or the created_at.
public getReadOnlyFields ( ) : string[]
return string[] the read only field names

getServiceProvider() public method

Gets the service provider.
public getServiceProvider ( ) : ServiceProvider
return ServiceProvider the service provider

getSubTypeField() public method

Gets a sub field of an field.
public getSubTypeField ( string $fieldName, string $subType, string $key ) : string
$fieldName string the field name of the sub type
$subType string the sub type like "reference" or "many"
$key string the key of the value
return string the value of the sub field

getTable() public method

Gets the table where the data is stored.
public getTable ( ) : string
return string the table where the data is stored

getType() public method

Gets the type of a field.
public getType ( string $fieldName ) : string
$fieldName string the field name
return string the type or null on invalid field name

isDeleteCascade() public method

Gets whether to delete its children when an instance is deleted.
public isDeleteCascade ( ) : boolean
return boolean true if so

isInitialSortAscending() public method

Gets the initial sort order.
public isInitialSortAscending ( ) : boolean
return boolean the initial sort order, true if ascending

setChildrenLabelFields() public method

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.
public setChildrenLabelFields ( array $childrenLabelFields )
$childrenLabelFields array the fields used to display the children on the details page

setDeleteCascade() public method

Sets whether to delete its children when an instance is deleted.
public setDeleteCascade ( boolean $deleteCascade )
$deleteCascade boolean whether to delete its children when an instance is deleted

setField() public method

Sets the value of a field key. If the field or the key in the field don't exist, they get created.
public setField ( string $name, string $key, mixed $value )
$name string the name of the field
$key string the value of the key
$value mixed the new value

setFieldLabel() public method

Gets the label of a field.
public setFieldLabel ( string $fieldName, string $value )
$fieldName string the field name
$value string the new label of the field

setFilter() public method

Sets the fields offering a filter.
public setFilter ( array $filter )
$filter array the fields to filter

setInitialSortAscending() public method

Sets the initial sort order.
public setInitialSortAscending ( boolean $initialSortAscending )
$initialSortAscending boolean the initial sort order, true if ascending

setInitialSortField() public method

Sets the initial sort field.
public setInitialSortField ( string $initialSortField )
$initialSortField string the new initial sort field

setLabel() public method

Sets the label for the entity.
public setLabel ( string $label )
$label string the new label for the entity

setListFields() public method

Sets the field names to be used in the listview.
public setListFields ( array $listFields )
$listFields array the field names to be used in the listview

setLocale() public method

Sets the locale to be used.
public setLocale ( string $locale )
$locale string the locale to be used.

setPageSize() public method

Sets the amount of items to display per page on the listview.
public setPageSize ( integer $pageSize )
$pageSize integer the amount of items to display per page on the listview

setServiceProvider() public method

Sets the service provider.
public setServiceProvider ( ServiceProvider $serviceProvider )
$serviceProvider ServiceProvider the new service provider

setTable() public method

Sets the table where the data is stored.
public setTable ( string $table )
$table string the new table where the data is stored

setType() public method

Sets the type of a field.
public setType ( string $fieldName, string $value )
$fieldName string the field name
$value string the new field type

Property Details

$children protected_oe property

An array with the children referencing the entity. All entries are arrays with three referencing elements: table, fieldName, entity
protected $children

$childrenLabelFields protected_oe property

The keys are the entity names as in the CRUD YAML and the values are the field names.
protected $childrenLabelFields

$deleteCascade protected_oe property

Whether to delete its children when an instance is deleted.
protected $deleteCascade

$fields protected_oe property

Holds all fields in the same structure as in the CRUD YAML file.
protected $fields

$filter protected_oe property

The fields offering to be filtered.
protected $filter

$initialSortAscending protected_oe property

Holds the initial sort order.
protected $initialSortAscending

$initialSortField protected_oe property

Holds the initial sort field.
protected $initialSortField

$label protected_oe property

The label for the entity.
protected $label

$listFields protected_oe property

An array containing the fields which should appear in the list view of the entity.
protected $listFields

$locale protected_oe property

Holds the locale.
protected $locale

$localeLabels protected_oe property

The labels of the entity in the locales.
protected $localeLabels

$pageSize protected_oe property

The amount of items to display per page on the listview.
protected $pageSize

$serviceProvider protected_oe property

Holds the {@see ServiceProvider}.
protected $serviceProvider

$standardFieldLabels protected_oe property

Labels for the fields "id", "created_at" and "updated_at".
protected $standardFieldLabels

$table protected_oe property

The table where the data is stored.
protected $table