BEdita API doc | 4-cactus
  • Class
  • Tree
  • Deprecated
  • Download

Classes

  • Addon
  • AddressbookController
  • AddressbookShell
  • AdminController
  • Alias
  • Annotation
  • ApiAuthComponent
  • ApiBaseController
  • ApiFormatterComponent
  • ApiUploadComponent
  • ApiValidatorComponent
  • AppController
  • AppError
  • AppHelper
  • Application
  • AppModel
  • Area
  • AreasController
  • Audio
  • AuthenticationsController
  • BannedIp
  • BEAppModel
  • BEAppObjectModel
  • BeAuthComponent
  • BeAuthFacebookComponent
  • BeAuthGoogleComponent
  • BeAuthTwitterComponent
  • BeCallbackManager
  • BeConfigure
  • BeCustomPropertyComponent
  • BeditaAnnotationModel
  • BeditaBaseShell
  • BeditaCollectionModel
  • BeditaContentModel
  • BeditaExportFilter
  • BeditaImportFilter
  • BeditaObjectModel
  • BeditaProductModel
  • BeditaShell
  • BeditaSimpleObjectModel
  • BeditaSimpleStreamModel
  • BeditaStreamModel
  • BeEmbedFlashHelper
  • BeEmbedHtml5Helper
  • BeEmbedMediaHelper
  • BeErrorCode
  • BeExceptionHandler
  • BEFile
  • BeFileHandlerComponent
  • BeFormHelper
  • BeFrontHelper
  • BeHashComponent
  • BeHtmlHelper
  • BeLangTextComponent
  • BeLib
  • BeMailComponent
  • BEObject
  • BeObjectCache
  • BePaginatorToolbarHelper
  • BeSchema
  • BeSecurityComponent
  • BeSystem
  • BeSystemComponent
  • BeThumb
  • BeTimeHelper
  • BeToolbarHelper
  • BeTreeComponent
  • BeTreeHelper
  • BeUploadToObjComponent
  • BeurlHelper
  • BeVimeoComponent
  • BeYoutubeComponent
  • BuildFilterBehavior
  • CacheableBehavior
  • CacheShell
  • CallbackBehavior
  • CaptchaComponent
  • Caption
  • CaptionsBehavior
  • Card
  • CardsImportFilter
  • Category
  • CleanupDataTask
  • CleanupTask
  • Comment
  • CommentsController
  • CompactResultBehavior
  • Content
  • CreateIndexFieldsBehavior
  • DataShell
  • DataTransfer
  • DateItem
  • DbadminShell
  • DeleteDependentObjectBehavior
  • DeleteObjectBehavior
  • DeployShell
  • Document
  • DocumentsController
  • DumpModel
  • EditorialContentsShell
  • EditorNote
  • Event
  • EventLog
  • EventsController
  • FilesController
  • ForeignDependenceSaveBehavior
  • FrontendController
  • FrontendShell
  • GalleriesController
  • Gallery
  • GeoTag
  • GettextShell
  • Git
  • GravatarHelper
  • Group
  • HashJob
  • History
  • HomeController
  • Image
  • ImageInfoHelper
  • JsonExportFilter
  • JsonImportFilter
  • JsonView
  • LangText
  • Link
  • MailGroup
  • MailGroupCard
  • MailJob
  • MailLog
  • MailMessage
  • MailShell
  • MailTemplate
  • Mask
  • MediaShell
  • MigrateDumpModel
  • MigrateShell
  • Migration
  • MigrationBase
  • MigrationDateItemsShell
  • Module
  • ModulesController
  • ModuleShell
  • MultimediaController
  • NewsController
  • NewsletterController
  • NewsletterShell
  • NotifyBehavior
  • ObjectEditor
  • ObjectProperty
  • ObjectRelation
  • ObjectType
  • ObjectUser
  • PagesController
  • Permission
  • PermissionModule
  • PermsHelper
  • Product
  • Property
  • PropertyOption
  • PublicationShell
  • RedisShell
  • RelationCheck
  • RelationRepair
  • RelationShell
  • RelationStats
  • RemoveDummyNameBehavior
  • ResponseHandlerComponent
  • RestClientModel
  • Revision
  • RevisionObjectBehavior
  • SearchText
  • SearchTextSaveBehavior
  • Section
  • SectionDummy
  • SessionFilterComponent
  • SessionFilterHelper
  • ShortNews
  • SmartyView
  • SoapClientModel
  • SplitterSql
  • StatisticsController
  • Stream
  • StreamLog
  • StreamsController
  • Svn
  • TagsController
  • ThemeSmartyView
  • ThumbnailHelper
  • ThumbShell
  • TransactionComponent
  • TransactionFS
  • TranslationsController
  • Tree
  • TrHelper
  • User
  • UserProperty
  • UsersController
  • Utility
  • Version
  • Video
  • VimeoHelper
  • WebmarksController
  • XmlExportFilter
  • XmlImportFilter
  • XmlJsonConverter
  • XmlView
  • YoutubeHelper

Interfaces

  • ApiAuthInterface
  • MediaProviderInterface
  • UploadableInterface

Exceptions

  • BeditaAjaxException
  • BEditaAllowURLException
  • BeditaBadRequestException
  • BeditaConflictException
  • BEditaDeleteStreamObjException
  • BeditaException
  • BEditaFileExistException
  • BeditaForbiddenException
  • BeditaFrontAccessException
  • BeditaHashException
  • BEditaInfoException
  • BeditaInternalErrorException
  • BEditaIOException
  • BeditaLengthRequiredException
  • BeditaMailException
  • BEditaMediaProviderException
  • BeditaMethodNotAllowedException
  • BEditaMIMEException
  • BeditaNotFoundException
  • BeditaNotImplementedException
  • BeditaPublicationException
  • BeditaRuntimeException
  • BEditaSaveStreamObjException
  • BeditaServiceUnavailableException
  • BeditaUnauthorizedException
  • BEditaUploadPHPException
  • BEditaURLException

Class ApiFormatterComponent

ApiFormatter class

Format data to be consumed by client or to be saved

Object
Extended by ApiFormatterComponent
Located at controllers/components/api_formatter.php

Methods summary

public
# initialize( Controller $controller, array $settings = array() )

Initialize function

Initialize function

Parameters

$controller
$settings
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

Call without parameters to return the acutal self::objectFieldsToRemove Pass paramteres to setup new self::objectFieldsToRemove and return it

If $override is true $confFields replaces self::objectFieldsToRemove

If $override is false (default) then $confFields has to be an array like

array(
    'remove' => array(
        'fieldToRemove_1',
        'fieldToRemove_2',
        'fieldOnWhichRemoveFields' => array(
            'fieldToRemove_3',
            'fieldToRemove_4'
        )
    ),
    'keep' => array(
        'fieldToKeep_1',
        'fieldToKeep_2',
        'fieldOnWhichKeepFields' => array(
            'fieldToKeep_3'
        )
    )
)

All fields in 'remove' will be added to self::objectFieldsToRemove All fields in 'keep' will be removed from self::objectFieldsToRemove

Parameters

$confFields
$override

Returns

array
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

Transform the item passed using a transformer The transformer must be an array of 'fields' => 'type' or 'key' => array('field1' => 'type') for example

array(
    'id' => 'integer',
    'start_date' => 'datetime',
    'GeoTag' => array(
        'id' => 'integer',
        ...
    )
)

The keys that correspond to array as GeoTag will be underscorized and pluralized. So GeoTag become geo_tags in the $item array

Parameters

$transformer
the transformer array
$item
$item the item to transform

See

self::transformers comments to all 'type' possibility
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

Convert a date from db to ISO-8601 format Use DateTime::ATOM format i.e. 2005-08-15T15:52:01+00:00

Parameters

$date
the date string to convert

Returns

string
public string
# dateToDb( string $date, string $dbFormat = 'Y-m-d H:i:s' )

Convert a date from ISO-8601 to $dbFormat The format supported are: - 2005-08-15T15:52:01+02:00 - 2005-08-15T13:52:01.467Z (js Date().toISOString())

Convert a date from ISO-8601 to $dbFormat The format supported are: - 2005-08-15T15:52:01+02:00 - 2005-08-15T13:52:01.467Z (js Date().toISOString())

Parameters

$date
the ISO-8601 date string
$dbFormat
the db format (default 'datetime' db type)

Returns

string
public
# transform( string $subject, array & $item )

Transform an item using a transformer from self::transformers

Transform an item using a transformer from self::transformers

Parameters

$subject
the transformer name to use
$item
$item the item to transform
public array
# getObjectTransformer( array $object )

Return the BEdita object transformer Used to know the fields to cast and the type

Return the BEdita object transformer Used to know the fields to cast and the type

Parameters

$object
the BEdita object

Returns

array
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']

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']

The transformer is cached

Parameters

$object
$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

Prepare self::$transformer['object'] adding 'custom_properties' formatting info It is expected that $object contains the 'ObjectProperty' with custom properties details

Parameters

$object
the object on which prepare the custom properties transformer
public array
# formatRelationsCount( array $object )

Count $object relations and return a formatted array as

Count $object relations and return a formatted array as

array(
    'attach' => array(
        'count' => 8,
        'url' => 'https://example.com/api/v1/objects/1/relations/attach'
    ),
    'seealso' => array(
        'count' => 2,
        'url' => 'https://example.com/api/v1/objects/1/relations/seealso'
    )
)

It uses self::controller::relatedObjectsFilter() to eventually add conditions

Parameters

$object
the object on which to count the relations

Returns

array
public array
# formatChildrenCount( array $object )

Count $object children and return a formatted array as

Count $object children and return a formatted array as

array(
    'count' => 14, // total children
    'url' => 'https://example.com/api/v1/objects/1/children',
    'contents' => array(
        'count' => 12, // contents children
        'url' => 'https://example.com/api/v1/objects/1/contents'
    ),
    'sections' => array(
        'count' => 2, // sections children
        'url' => 'https://example.com/api/v1/objects/1/sections'
    )
)

It uses self::controller::childrenFilter() to eventually add conditions

Parameters

$object
the object on which to count children

Returns

array
public array
# getCustomPropertiesList( integer $objectTypeId )

Return a list of custom properties of specific object type id

Return a list of custom properties of specific object type id

Parameters

$objectTypeId
the object type id

Returns

array
public array
# formatObject( array $object, array $options = array() )

Given an object return the formatted data ready for api response

Given an object return the formatted data ready for api response

The $result is normally located in 'data' key of api response and it's in the form

'object' => array(...) // object data

$options is used to personalize the object formatted. Possible values are:

  • 'countRelations' (default false) to add a count of relations with url to reach them
  • 'countChildren' (default false) to add a count of children with url to reach them

Parameters

$object
representation of a BEdita object
$options

Returns

array
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

Given an array of objects return the formatted data ready for api response Iteratively call self::formatObject() on every object of the list

'objects' => array(...), // object data

$options is used to personalize the object formatted.

Parameters

$objects
array of BEdita objects
$options

Returns

array

See

self::formatObject()
public array
# formatPaging( array $toolbar )

Starting from BEdita toolbar it returns the paging item as

Starting from BEdita toolbar it returns the paging item as

'page' => int, // the current page
'page_size' => int|null, // the maximum number of items in the response
'page_count' => int, // the total number of items in the page
'total' => int, // the total number of items
'total_pages' => int // the total number of pages

Parameters

$toolbar

Returns

array
public
# cleanObject( array & $object )

Clean BEdita object array from useless fields Use self::objectFieldsToRemove

Clean BEdita object array from useless fields Use self::objectFieldsToRemove

Parameters

$object
$object
public array
# formatObjectForSave( array $object )

Arrange $object data to save

Arrange $object data to save

  • clean fields
  • transform date ISO8601 in SQL format

Parameters

$object
the $object data to save

Returns

array
public array
# formatRelationsForSave( array $relations )

Arrange relations data to save. The data returned are suitable to saving an object

Arrange relations data to save. The data returned are suitable to saving an object

The $relations array has to be in the form

array(
    'attach' => array(
        array(
            'related_id' => 1,
            ...
        ),
        array(...)
    ),
    'seealso' => array(...)
)

Parameters

$relations
array of relations

Returns

array
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

Arrange categories data for save. The data returned are suitable to saving an object. Return an array of ids

Parameters

$categories
an array of category names
$objectTypeId
the object type id

Returns

array
public array
# formatTagsForSave( array $tags )

Arrange tags data for save. The data returned are suitable to saving an object. Return an array of ids

Arrange tags data for save. The data returned are suitable to saving an object. Return an array of ids

Parameters

$tags
an array of tag names

Returns

array
public
# formatDateItemsForSave( array $dateItems )

Arrange date items for save: - format 'start_date' and 'end_date'

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

Format custom properties for save Array as

array(
    'custom_name_1' => 'value_1',
    'custom_name_2' => array('value_2', 'value_3')
)

become

array(
    0 => array(
        'property_id' => 1, // id of custom_name_1
        'property_value' => 'value_1'
    ),
    1 => array(
        'property_id' => 2, // id of custom_name_2
        'property_value' => 'value_2'
    ),
    2 => array(
        'property_id' => 2, // id of custom_name_2
        'property_value' => 'value_3'
    )
)

Parameters

$customProperties
array of custom properties to format
$objectTypeId
the object type id

Returns

array
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.

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.

For example in a request as:

https://example.com/objects?filter[object_type]=document,event&page=2

the url params are formatted as

array(
    'filter' => array(
        'object_type' => array('document', 'event')
    ),
    'page' => 2
)

Once url params has been formatted that value is returned to every next call without parse again the url unless $reset params is true

Parameters

$separator
the separator char that explode string in array
$exclude
the array of url params to exclude to the formatting
$reset
true if the url params have to be formatted again also if it had already been done

Returns

array

Properties summary

public Controller $controller

Controller instance

Controller instance

# null
public array $components

Components used

Components used

# array('ApiValidator')
protected array $objectFieldsToRemove

Fields that must be removed from object/s

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 field => type It used for cast string in other types. Some special types act on fields instead of values. See below.

Contain fields transformation as field => type It used for cast string in other types. Some special types act on fields instead of values. See below.

Possible types values are:

  • date
  • datetime
  • integer
  • float
  • boolean

Special types:

  • underscoreField underscorize field. Note that the value of field remains unchanged
  • integerArray cast to integer all array values

The object key contains transformation merged with all BEdita objects

See

self::transformObject(), self::transformItem()
# array( 'object' => array( 'publication_date' => 'datetime', 'customProperties' => 'underscoreField', 'canonicalPath' => 'underscoreField', 'parentAuthorized' => 'underscoreField' ) )
protected array $urlParams

The URL query string parameters formatted

The URL query string parameters formatted

See

self::formatUrlParams()
# array()
protected array $customPropertiesList

A list of custom properties divided by object type

A list of custom properties divided by object type

array(
    'document' => array(
        id_custom_1 => 'custom1',
        id_custom_2 => 'custom2',
    ),
    ...
)
# array()
BEdita API doc | 4-cactus API documentation generated by ApiGen