Overview

Namespaces

  • CRUDlex

Classes

  • CRUDControllerProvider
  • CRUDData
  • CRUDEntity
  • CRUDEntityDefinition
  • CRUDMySQLData
  • CRUDMySQLDataFactory
  • CRUDServiceProvider
  • CRUDSimpleFilesystemFileProcessor

Interfaces

  • CRUDDataFactoryInterface
  • CRUDFileProcessorInterface
  • Overview
  • Namespace
  • Class

Class CRUDData

The abstract class for reading and writing data.

Direct known subclasses

CRUDlex\CRUDMySQLData
Abstract
Namespace: CRUDlex
Located at CRUDData.php
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

CRUDlex\CRUDEntity
the entity containing the array data then
abstract public CRUDlex\CRUDEntity
# get( string $id )

Gets the entity with the given id.

Gets the entity with the given id.

Parameters

$id
the id

Returns

CRUDlex\CRUDEntity
the entity belonging to the id or null if not existant
abstract public array
# listEntries( array $filter = 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
$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
# 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.
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 boolean
# delete( string $id )

Deletes an entry from the datasource having the given id.

Deletes an entry from the datasource having the given id.

Parameters

$id
the id of the entry to delete

Returns

boolean
true on successful deletion
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
# getDefinition( )

Gets the CRUDlex\CRUDEntityDefinition instance.

Gets the CRUDlex\CRUDEntityDefinition instance.

Returns

CRUDlex\CRUDEntityDefinition
the definition instance
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

CRUDlex\CRUDEntity
the newly created entity
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
Properties summary
protected $definition

Holds the CRUDlex\CRUDEntityDefinition entity definition.

Holds the CRUDlex\CRUDEntityDefinition entity definition.

#
protected $fileProcessor

Holds the CRUDlex\CRUDFileProcessorInterface file processor.

Holds the CRUDlex\CRUDFileProcessorInterface file processor.

#
CRUDlex API API documentation generated by ApiGen