Class ApiValidatorComponent
ApiValidatorComponent class
Used to validate data before save/delete and to test conditions on objects
- Object
- ApiValidatorComponent
Methods summary
public
|
#
initialize( Controller $controller, array $settings = array() )
Initialize component (called before Controller::beforeFilter()) |
public
|
|
public
|
#
checkUrlParams( string $endpoint )
Check if url query string names of the request are valid for an endpoint |
public
boolean
|
#
isUrlParamsValid( string $endpoint )
Return true if url query string is valid for an endpoint, false otherwise All allowed url params are valid for GET requests but '__all' values that are valid for all request types |
public
array
|
#
registerAllowedUrlParams( array $stringNames, boolean $merge = true )
Register an array of query string names in self::$allowedUrlParams The array has to be divided by endpoint i.e. |
public
array
|
#
getAllowedUrlParams( string $endpoint = null )
Return the url query string names valid Passing the endpoint the list is filtered by it |
public
|
#
setAllowedUrlParams( string $endpoint, string|array $names, boolean $merge = true )
Set new valid url query string names |
public
boolean
|
|
public
|
|
public
|
#
checkObjectReachable( integer $objectId )
Check if an object is reachable: - check if object is reacheable looking also permissions - if it fails check again if it's reachable but without checking permissions - if it fails, then it throws 404 - if it is, then it checks if user is logged - if it fails then it throws 401 - if it is then it throws 403 |
public
boolean
|
#
isObjectReachable( integer $objectId, boolean $checkPermissions = true )
Return true if object $objectId is reachable, false otherwise.
If |
public
boolean
|
#
hasRelatedObjectsAccessible( integer $objectId )
Return true if at least an object related to $objectId is on tree and it's accessible, false otherwise 'Accessible' is defined in self::isObjectAccessible() |
public
boolean
|
#
isObjectAccessible( integer $objectId, boolean $parentsCheck = true )
Return true if $objectId is accessible for authorized user, false otherwise. 'Accessible' means without 'frontend_access_with_block' permission set for groups that the user doesn't belong. When $parentsCheck is true permission on them is also checked If object hasn't parents is not accessible |
public
boolean
|
#
areObjectParentsAccessible( integer $objectId )
Return true if $objectId parents are accessible for authorized user, false otherwise. 'Accessible' means without 'frontend_access_with_block' permission set for groups that the user doesn't belong. |
public
|
#
checkParents( integer|array $parentsId )
Check if $parentsId are valid parents for the saving object |
public
|
#
checkObjectAccess( integer|array $objectId )
Check if $objectId and its parents are accessible for authorized user. 'Accessible' is defined in self::isObjectAccessible() |
public
boolean
|
#
isRelationValid( string $name, string|integer $objectType )
Return true if the relation $name is valid for $objectType |
public
|
#
checkRelations( array $relations, string|integer $objectType = null )
Check if an array of relations is valid |
public
|
#
checkEmbedRelations( array $relationsData, integer $pageSize, integer $maxSize )
Check embed relations requested. $relationsData must be in the form of 'relation_name' => number_requested, for example |
public
boolean
|
|
public
|
|
public
|
#
checkChildren( array $children, integer $parentId )
Check if an array of (possible) children is valid for a parent id |
public
|
#
checkCategories( array $categories, integer $objectTypeId = null )
Check if an array of category names is valid for an object type id |
public
|
|
public
DateTime
|
|
public
|
#
checkDateItems( array $dateItems, integer $objectId = null )
Check if $dateItems contains item with allowed and valid fields $dateItems has to be an array as |
public
|
#
checkGeoTags( array $geoTags, integer $objectId = null )
Check if $geoTags contains item with allowed and valid fields $geoTags has to be an array as |
public
|
#
checkCustomProperties( array $customProperties, integer|string $objectTypeId )
Check if custom properties are valid The $customProperties array has to be in the form |
public
|
|
public
array
|
|
public
|
#
checkUploadable( string $objectType, array $metaData = array() )
Check if an |
public
boolean
|
#
isMimeTypeValid( string $mimeType, string $objectType )
Validate a mime type against an object type. It uses validate_resource.mime.ObjectModel configuration |
public
|
#
setReachableCheck( boolean $check = true )
Set check for reachable object (default true: check it) |
Properties summary
public
Controller
|
$controller
Controller instance |
#
null
|
protected
array
|
$writableObjects
List of object types writable |
#
array()
|
protected
boolean
|
$enableObjectReachableCheck
Enable check of object reachability in checkObjectReachable |
#
true
|
protected
array
|
$reachableRelations
List of relations considered reachable (used to skip object reachable check) |
#
array()
|
private
array
|
$allowedUrlParams
The supported query string parameters names for every endpoint. |
#
array(
'__all' => array()
)
|