Methods summary
protected
CRUDlex\CRUDEntity
|
#
hydrate( array $row )
Creates an CRUDlex\CRUDEntity from the raw data array with the field name
as keys and field values as values.
Creates an CRUDlex\CRUDEntity from the raw data array with the field name
as keys and field values as values.
Parameters
- $row
- the array with the raw data
Returns
|
protected
|
|
public
|
#
pushEvent( string $moment, string $action, anonymous $function )
Adds an event to fire for the given parameters. The event function must
have this signature:
function (CRUDEntity $entity)
and has to return true or false.
The events are executed one after another in the added order as long as
they return "true". The first event returning "false" will stop the
process.
Adds an event to fire for the given parameters. The event function must
have this signature:
function (CRUDEntity $entity)
and has to return true or false.
The events are executed one after another in the added order as long as
they return "true". The first event returning "false" will stop the
process.
Parameters
- $moment
- the "moment" of the event, can be either "before" or "after"
- $action
- the "action" of the event, can be either "create", "update" or "delete"
- $function
$function
the event function to be called if set
|
public
anonymous
|
#
popEvent( string $moment, string $action )
Removes and returns the latest event for the given parameters.
Removes and returns the latest event for the given parameters.
Parameters
- $moment
- the "moment" of the event, can be either "before" or "after"
- $action
- the "action" of the event, can be either "create", "update" or "delete"
Returns
anonymous function
the popped event or null if no event was available.
|
abstract public
CRUDlex\CRUDEntity
|
#
get( string $id )
Gets the entity with the given id.
Gets the entity with the given id.
Parameters
Returns
|
abstract public
array
|
#
listEntries( array $filter = array(), array $filterOperators = array(), integer $skip = null, integer $amount = null )
Gets a list of entities fullfilling the given filter or all if no
selection was given.
Gets a list of entities fullfilling the given filter or all if no
selection was given.
Parameters
- $filter
- the filter all resulting entities must fulfill, the keys as field names
- $filterOperators
- the operators of the filter like "=" defining the full condition of the field
- $skip
- if given and not null, it specifies the amount of rows to skip
- $amount
- if given and not null, it specifies the maximum amount of rows to retrieve
Returns
array the entities fulfilling the filter or all if no filter was given
|
abstract public
boolean
|
#
create( CRUDlex\CRUDEntity $entity )
Persists the given entity as new entry in the datasource.
Persists the given entity as new entry in the datasource.
Parameters
- $entity
- the entity to persist
Returns
boolean true on successful creation
|
abstract public
|
#
update( CRUDlex\CRUDEntity $entity )
Updates an existing entry in the datasource having the same id.
Updates an existing entry in the datasource having the same id.
Parameters
- $entity
- the entity with the new data
|
abstract public
integer
|
#
delete( CRUDlex\CRUDEntity $entity )
Deletes an entry from the datasource having the given id.
Deletes an entry from the datasource having the given id.
Parameters
- $entity
- the id of the entry to delete
Returns
integer returns one of:
- CRUDData::DELETION_SUCCESS -> successful deletion
- CRUDData::DELETION_FAILED_STILL_REFERENCED -> failed deletion due to existing references
- CRUDData::DELETION_FAILED_EVENT -> failed deletion due to a failed before delete event
|
abstract public
array
|
#
getReferences( string $table, string $nameField )
Gets ids and names of a table. Used for building up the dropdown box of
reference type fields.
Gets ids and names of a table. Used for building up the dropdown box of
reference type fields.
Parameters
- $table
- the table
- $nameField
- the field defining the name of the rows
Returns
array an array with the ids as key and the names as values
|
abstract public
integer
|
#
countBy( string $table, array $params, array $paramsOperators, boolean $excludeDeleted )
Retrieves the amount of entities in the datasource fulfilling the given
parameters.
Retrieves the amount of entities in the datasource fulfilling the given
parameters.
Parameters
- $table
- the table to count in
- $params
- an array with the field names as keys and field values as values
- $paramsOperators
$paramOperators
the operators of the parameters like "=" defining the full condition of the field
- $excludeDeleted
- false, if soft deleted entries in the datasource should be counted, too
Returns
integer the count fulfilling the given parameters
|
abstract public
|
#
fetchReferences( array & $entities = null )
Adds the id and name of referenced entities to the given entities. Each
reference field is before the raw id of the referenced entity and after
the fetch, it's an array with the keys id and name.
Adds the id and name of referenced entities to the given entities. Each
reference field is before the raw id of the referenced entity and after
the fetch, it's an array with the keys id and name.
Parameters
- $entities
- the entities to fetch the references for
|
public
CRUDlex\CRUDEntityDefinition
|
|
public
CRUDlex\CRUDEntity
|
#
createEmpty( )
Creates a new, empty entity instance having all fields prefilled with
null or the defined value in case of fixed fields.
Creates a new, empty entity instance having all fields prefilled with
null or the defined value in case of fixed fields.
Returns
|
public
|
#
createFiles( Symfony\Component\HttpFoundation\Request $request, CRUDlex\CRUDEntity $entity, string $entityName )
Creates the uploaded files of a newly created entity.
Creates the uploaded files of a newly created entity.
Parameters
- $request
- the HTTP request containing the file data
- $entity
- the just created entity
- $entityName
- the name of the entity as this class here is not aware of it
|
public
|
#
updateFiles( Symfony\Component\HttpFoundation\Request $request, CRUDlex\CRUDEntity $entity, string $entityName )
Updates the uploaded files of an updated entity.
Updates the uploaded files of an updated entity.
Parameters
- $request
- the HTTP request containing the file data
- $entity
- the updated entity
- $entityName
- the name of the entity as this class here is not aware of it
|
public
|
#
deleteFile( CRUDlex\CRUDEntity $entity, string $entityName, string $field )
Deletes a specific file from an existing entity.
Deletes a specific file from an existing entity.
Parameters
- $entity
- the entity to delete the file from
- $entityName
- the name of the entity as this class here is not aware of it
- $field
- the field of the entity containing the file to be deleted
|
public
|
#
deleteFiles( CRUDlex\CRUDEntity $entity, string $entityName )
Deletes all files of an existing entity.
Deletes all files of an existing entity.
Parameters
- $entity
- the entity to delete the files from
- $entityName
- the name of the entity as this class here is not aware of it
|
public
Symfony\Component\HttpFoundation\Response
|
#
renderFile( CRUDlex\CRUDEntity $entity, string $entityName, string $field )
Renders (outputs) a file of an entity. This includes setting headers
like the file size, mimetype and name, too.
Renders (outputs) a file of an entity. This includes setting headers
like the file size, mimetype and name, too.
Parameters
- $entity
- the entity to render the file from
- $entityName
- the name of the entity as this class here is not aware of it
- $field
- the field of the entity containing the file to be rendered
Returns
Symfony\Component\HttpFoundation\Response the HTTP response, likely to be a streamed one
|