Class ApiFormatterComponent
ApiFormatter class
Format data to be consumed by client or to be saved
- Object
- ApiFormatterComponent
Methods summary
public
|
|
public
array
|
#
objectFieldsToRemove( array $confFields = array(), boolean $override = false )
Call without parameters to return the acutal self::objectFieldsToRemove Pass paramteres to setup new self::objectFieldsToRemove and return it |
protected
|
#
transformItem( array $transformer, array & $item )
Transform the item passed using a transformer The transformer must be an array of 'fields' => 'type' or 'key' => array('field1' => 'type') for example |
public
string
|
#
dateFromDb( string $date )
Convert a date from db to ISO-8601 format Use DateTime::ATOM format i.e. 2005-08-15T15:52:01+00:00 |
public
string
|
|
public
|
|
public
array
|
#
getObjectTransformer( array $object )
Return the BEdita object transformer Used to know the fields to cast and the type |
public
|
#
transformObject( array & $object )
Transform a BEdita object type casting fields to the right type Use BEAppObjectModel::apiTransformer() to get the transformer and merge it with self::transformers['object'] |
public
|
#
setCustomPropertiesTransformer( array $object )
Prepare self::$transformer['object'] adding 'custom_properties' formatting info It is expected that $object contains the 'ObjectProperty' with custom properties details |
public
array
|
|
public
array
|
|
public
array
|
#
getCustomPropertiesList( integer $objectTypeId )
Return a list of custom properties of specific object type id |
public
array
|
#
formatObject( array $object, array $options = array() )
Given an object return the formatted data ready for api response |
public
array
|
#
formatObjects( array $objects, array $options = array() )
Given an array of objects return the formatted data ready for api response Iteratively call self::formatObject() on every object of the list |
public
array
|
|
public
|
#
cleanObject( array & $object )
Clean BEdita object array from useless fields Use self::objectFieldsToRemove |
public
array
|
|
public
array
|
#
formatRelationsForSave( array $relations )
Arrange relations data to save. The data returned are suitable to saving an object |
public
array
|
#
formatCategoriesForSave( array $categories, integer $objectTypeId = null )
Arrange categories data for save. The data returned are suitable to saving an object. Return an array of ids |
public
array
|
#
formatTagsForSave( array $tags )
Arrange tags data for save. The data returned are suitable to saving an object. Return an array of ids |
public
|
#
formatDateItemsForSave( array $dateItems )
Arrange date items for save: - format 'start_date' and 'end_date' |
public
array
|
#
formatCustomPropertiesForSave( array $customProperties, integer $objectTypeId )
Format custom properties for save Array as |
public
array
|
#
formatUrlParams( string $separator = ',', array $exclude = array('query'), boolean $reset = false )
Format $this->controller->params['url'] building array of values starting from $separator separated values. By default $separator is ',' char and 'query' is excluded because it represents a full text search. |
Properties summary
public
Controller
|
$controller
Controller instance |
#
null
|
public
array
|
$components
Components used |
#
array('ApiValidator')
|
protected
array
|
$objectFieldsToRemove
Fields that must be removed from object/s |
#
array(
'UserCreated',
'ObjectProperty',
'ObjectType',
'RelatedObject',
'bindings',
'fixed',
'valid',
'ip_created',
'pathSection',
// areas
'stats_code',
'stats_provider',
'stats_provider_url',
// sections
'syndicate',
'priority_order',
'last_modified',
'map_priority',
'map_changefreq',
// trees fields
'area_id',
'object_path',
'priority',
'menu',
'Category' => array(
'id',
'object_type_id',
'area_id',
'status',
'priority',
'parent_id',
'parent_path',
'url_label'
),
'Tag' => array(
'id',
'object_type_id',
'area_id',
'status',
'priority',
'parent_id',
'parent_path',
'url_label'
),
'DateItem' => array(
'object_id',
'params'
)
)
|
protected
array
|
$transformers
Contain fields transformation as |
#
array(
'object' => array(
'publication_date' => 'datetime',
'customProperties' => 'underscoreField',
'canonicalPath' => 'underscoreField',
'parentAuthorized' => 'underscoreField'
)
)
|
protected
array
|
$urlParams
The URL query string parameters formatted |
#
array()
|
protected
array
|
$customPropertiesList
A list of custom properties divided by object type |
#
array()
|