Class ApiBaseController
ApiBaseController class
Abstract Base Api Controller It must to be extended by ApiController in frontend apps
- Controller
-
AppController
-
FrontendController
-
ApiBaseController
Methods summary
public
|
|
public
mixed
|
|
public
string
|
|
private
array
|
|
public
array
|
|
private
|
#
setupPagination( )
Setup the pagination options self:paginationOptions Merging default with query url params |
protected
|
|
protected
mixed
|
|
protected
mixed
|
|
private
|
|
private
|
|
private
|
|
private
|
|
protected
|
|
protected
|
|
public
|
|
public
string
|
|
protected
|
|
protected
|
|
public
array
|
|
public
array
|
|
protected
|
#
setupLocale( )
Setup locale settings - nothing to set, for api override FrontendController::setupLocale override AppController::setupLocale |
protected
|
|
protected
array
|
#
addRelatedObjects( array $object, array $relations )
Add related objects to $object The $relations is an array that contains info about the number of objects to get for each relation For example |
protected
|
#
loadRelationParams( array & $items, integer $objectId, string $relName )
Load available relation params for a list of related objects. |
private
|
#
routeObjectsFilterType( integer $id, string $filterType )
Route calls made by /objects endpoint using $filterType and request method self::requestMethod |
protected
|
|
protected
|
#
putObjects( integer|string $name = null, string $filterType = null )
PUT /objects/:id PUT of entire object is not allowed. If you want modify an object you should use POST |
protected
|
|
protected
|
|
protected
|
#
postObjectsRelations( integer $objectId, string $relationName )
Save relations $relationName between $objectId and related objects in $this->data |
protected
|
#
postObjectsChildren( integer $objectId )
Save (insert or update) children ($this->data) of $objectId |
protected
|
#
putObjectsRelations( integer $objectId, string $relationName = null, integer $relatedId = null )
Update relation $relationName between $objectId and $relatedId objects |
protected
|
#
putObjectsChildren( integer $objectId, integer $childId = null )
Update 'priority' (position relative to all children) of $childId son of $objectId |
protected
|
#
deleteObjectsRelations( integer $objectId, string $relation, integer $relatedId )
Delete a relation named $relation between $objectId and $relatedId |
protected
|
#
deleteObjectsChildren( integer $parentId, integer $childId )
Delete from trees object $childId with $parentId as parent |
protected
array
|
#
forbiddenChildren( integer $parentId, array $user = array() )
Get list of children with access restricted to $user. If it's set to skip permissions or to show unauthorized objects it returns empty array. |
protected
|
#
responseChildren( integer $parentId, array $options = array() )
Get children of $parentId object, prepare and set response data
The response is automatically paginated using |
protected
|
#
getObjectsChildren( integer $id, $childId = null )
Load children of object $id setting data for response |
protected
|
|
protected
|
|
protected
|
|
protected
|
|
protected
|
#
getObjectsRelations( integer $id, string $relation = null, integer $relatedId = null )
Load relations of object $id setting data for response |
protected
|
|
protected
|
|
protected
|
#
getPosters( integer|string $id = null )
GET /posters endpoint Return a poster thumbnail url of object $id or list of id's using 'id' parameter with a comma separated list of id's As 'posters' an image object is retrived using following order: 1. if object $id has a 'poster' relation return that image object 2. else if object $id is an image object type return it 3. else if object $id has an 'attach' relation with an image return that image |
private
array
|
#
posterThumbConf( )
Returns thumbnail configuration array from URL and general configuration (used in /posters) |
protected
array
|
#
posterData( integer $id, array $thumbConf = array() )
Returns poster data for a single object (used in /posters) |
protected
|
|
protected
|
|
protected
|
#
deleteAuth( string $refreshToken )
Revoke authentication removing refresh token If refresh token was removed successufully a 204 NO CONTENT status code returns |
protected
|
|
protected
|
#
updateSiblingsPriority( string $objectId, string $childId, integer $priority, boolean $moveSiblings = false )
set child priority and update siblings priority. |
protected
|
#
response( array $options = array() )
Build response data for client $options array permits to customize the response. Possible values are: - 'emptyBody' true to send empty body to client (default false) - 'statusCode' the HTTP status code you want to send to client - 'setBase' false to avoid to set base response metadata (default true) |
protected
|
#
emptyResponse( integer $statusCode = 204 )
Send an empty response body to client Optionally it can send an HTTP status code |
protected
boolean
|
#
checkOrigin( )
Checks if an origin is allowed.
Allowed origins are set in |
Methods inherited from FrontendController
accessDenied(),
buildRssItem(),
captchaImage(),
category(),
checkPubblicationDate(),
clearObjectCacheArray(),
content(),
delete(),
download(),
excludeRelations(),
georss(),
georssatom(),
getParentsObject(),
getPath(),
getPublication(),
getRelatedCacheExpiration(),
getSectionCacheExpiration(),
getShowUnauthorized(),
getSkipCheck(),
getStatus(),
handleExceptions(),
hashjob(),
homePage(),
initAttributes(),
isLogged(),
json(),
kml(),
lang(),
loadAndSetObj(),
loadAndSetObjByNick(),
loadAndSetSectionObjects(),
loadAndSetSectionObjectsByNick(),
loadAnnotations(),
loadArchiveTree(),
loadObj(),
loadObjByNick(),
loadObjectsByCategory(),
loadObjectsByTag(),
loadPublications(),
loadRelatedObjects(),
loadSectionObjects(),
loadSectionObjectsByNick(),
loadSectionsLevels(),
loadSectionsTree(),
loadTags(),
login(),
logout(),
manifestAppcache(),
printme(),
publicationDisabled(),
rss(),
save(),
saveComment(),
search(),
section(),
setCanonicalPath(),
setPublicationDateFilter(),
setShowUnauthorized(),
setSkipCheck(),
showDraft(),
sitemap(),
sitemapXml(),
subscribe(),
tag(),
treeChildrenCache(),
xml(),
xmlobject()
Methods inherited from AppController
afterFilter(),
beditaAfterFilter(),
beditaBeforeFilter(),
beditaBeforeRender(),
beforeFilter(),
beforeRender(),
checkObjectWritePermission(),
currentController(),
eventError(),
eventInfo(),
eventLog(),
eventWarn(),
forward(),
handleError(),
idFromNicknameCache(),
loadModelByObjectTypeId(),
loadModelByType(),
modelBindings(),
objectRelationArray(),
objectTypeCache(),
objectTypeIdCache(),
prepareRelationsToSave(),
setModelBindings(),
setObjectBindings(),
setResult(),
setupAnnotations(),
setup_args(),
startProfiler(),
stopProfiler(),
unsetModelBindings(),
updateHistory(),
usedUrl(),
userErrorMessage(),
userInfoMessage(),
userWarnMessage(),
viewRevision()
Constants summary
Constants inherited from FrontendController
Constants inherited from AppController
Properties summary
public
array
|
$uses
The Models used |
#
array()
|
public
array
|
$components
The Components used |
#
array(
'ResponseHandler' => array('type' => 'json'),
'ApiFormatter',
'ApiValidator',
'ApiUpload'
)
|
public
Object
|
$ApiAuth
Contain the instance of API auth component used Normally it corresponds to ApiAuthComponent but it can contain another auth component To do it a custom component, named for example 'MyAuth', has to be activated via conf |
#
null
|
private
array
|
$defaultEndPoints
The default endpoints |
#
array('objects', 'auth', 'me', 'posters', 'files')
|
protected
string
|
$defaultBindingLevel
The default binding level |
#
'api'
|
protected
array
|
$allowedModelBindings
Allowed model bindings Used to get more or less fields and associations through GET /objects param 'binding' By default no one is permit but it is overridable in ApiController |
#
array()
|
protected
array
|
$endPoints
Other endpoints specified in the frontend app They will be merged with self::defaultEndPoints() |
#
array()
|
protected
array
|
$blacklistEndPoints
Endpoints blacklisted Useful for blacklisting self::defaultEndPoints |
#
array()
|
protected
array
|
$whitelistObjectTypes
White list of object types that have to be mapped to endpoints For example setting |
#
array()
|
protected
array
|
$responseData
The response data for client |
#
array()
|
protected
boolean
|
$autoResponse
If response has to be built automatically at the end of the action |
#
true
|
protected
array
|
$paginationOptions
Pagination options used to paginate objects Default values are |
#
array(
'page' => 1,
'pageSize' => 20,
'maxPageSize' => 100
)
|
private
array
|
$postData
The POST data in request |
#
array()
|
protected
array
|
$objectsFilter
An array of filter to apply to objects |
#
array()
|
protected
string
|
$requestMethod
The request method invoked (get, post, put, delete) |
#
null
|
private
string
|
$fullApiBaseUrl
The complete base url for API i.e. https://example.com/api/v1 It is filled the first time self::baseUrl() is called |
#
null
|
protected
array
|
$allowedObjectsUrlPath
The allowed url path you can apply to /objects endpoint. The url path is divided by request type 'get', 'post', 'put' and 'delete' |
#
array(
'get' => array(
'relations',
'children',
'contents',
'sections',
'descendants',
'siblings',
//'ancestors',
//'parents'
),
'post' => array(
'relations',
'children'
),
'put' => array(
'relations',
'children'
),
'delete' => array(
'relations',
'children'
)
)
|
private
array
|
$defaultAllowedUrlParams
The default supported url query string parameters names for every endpoint It's an array as |
#
array(
'__all' => array('access_token'),
'_pagination' => array('page', 'page_size'),
'objects' => array('id', 'filter[object_type]', 'filter[substring]', 'filter[query]', 'embed[relations]', '_pagination', 'lang'),
'posters' => array('id', 'width', 'height', 'mode')
)
|
protected
array
|
$allowedUrlParams
Other supported query string parameters names for every endpoint. Override it according to your needs. |
#
array()
|
Properties inherited from FrontendController
$annotationOptions,
$baseLevel,
$captchaOptions,
$checkPubDate,
$logged,
$loginRedirect,
$logoutRedirect,
$objectCache,
$publication,
$searchOptions,
$sectionOptions,
$showUnauthorized,
$tagOptions,
$xmlFormat
Properties inherited from AppController
$BeObjectCache,
$currLang,
$currLocale,
$current,
$ext,
$fullBaseUrl,
$helpers,
$historyItem,
$modelBindings,
$moduleList,
$moduleName,
$modulePerms,
$objectData,
$profiling,
$result,
$skipCheck,
$view