Methods summary
public
|
#
__construct( string $className = null, string $objectId = null )
Make a new plain LeanObject.
Make a new plain LeanObject.
Parameters
Throws
InvalidArgumentException
|
public static
LeanCloud\LeanObject
|
#
create( string $className, string $objectId = null )
Make a new object for class
Make a new object for class
The returned object will be instance of sub-class, if className has
been registered.
Parameters
Returns
|
public static
|
#
registerClass( )
Register a sub-class to LeanObject.
Register a sub-class to LeanObject.
When a sub-class extends LeanObject, it should specify a static
string variable ::$className , which corresponds to a className on
LeanCloud. It shall then invoke ->registerClass to register
itself to LeanObject. Such that LeanObject maintains a map of
className to sub-classes.
It is only callable on sub-class.
Throws
RuntimeException
|
public
string
|
|
public
|
|
public
|
|
public
array
|
#
getPointer( )
Pointer representation of object
Pointer representation of object
Returns
array
|
public
array
|
#
toJSON( )
Recursively encode object and its data to JSON
Recursively encode object and its data to JSON
Top level object are encoded to literal JSON, with __type and
className stripped out.
Returns
array
See
self::toFullJSON
|
public
array
|
#
toFullJSON( array $seen = array() )
Recursively encode object and its data to full JSON
Recursively encode object and its data to full JSON
Recursively encode object and its (snapshot) data to full JSON, the
__type and className will be included in the attributes.
Parameters
- $seen
- Objects that have been traversed
Returns
array
See
self::toJSON
|
public
string
|
|
public
DateTime
|
|
public
DateTime
|
|
public
LeanCloud\LeanObject
|
#
set( string $key, mixed $val )
Set field value by key
Parameters
- $key
- field key
- $val
- field value
Returns
Throws
RuntimeException
|
public
LeanCloud\LeanObject
|
|
public
null|LeanCloud\ACL
|
#
getACL( )
Get ACL for object
Returns
|
public
LeanCloud\LeanObject
|
#
delete( string $key )
Delete field by key
Parameters
Returns
|
public
mixed
|
#
get( string $key )
Get field value by key
Parameters
Returns
mixed field value
|
public
LeanCloud\LeanObject
|
#
increment( string $key, number $amount = 1 )
Increment a numeric field
Increment a numeric field
For decrement, provide a negative amount.
Parameters
- $key
- field key
- $amount
- amount to increment
Returns
|
public
LeanCloud\LeanObject
|
#
addIn( string $key, miexed $val )
Add one object into array field
Add one object into array field
Parameters
- $key
- Field key
- $val
- Object to add
Returns
Throws
RuntimeException
|
public
LeanCloud\LeanObject
|
#
addUniqueIn( string $key, mixed $val )
Add one object uniquely into array field
Add one object uniquely into array field
Parameters
- $key
- Field key
- $val
- Object to add
Returns
Throws
RuntimeException
|
public
LeanCloud\LeanObject
|
#
removeIn( string $key, mixed $val )
Remove one object from array field
Remove one object from array field
Parameters
- $key
- Field key
- $val
- Object to remove
Returns
Throws
RuntimeException
|
public
boolean
|
#
hasData( )
If object has data attributes.
If object has data attributes.
Returns
boolean
|
public
boolean
|
#
isDirty( )
If there are unsaved operations.
If there are unsaved operations.
Returns
boolean
|
public
|
#
save( LeanCloud\SaveOption $option = null )
Save object and its children objects and files
Save object and its children objects and files
Parameters
Throws
|
public
|
#
mergeAfterSave( array $data )
Merge server data after save.
Merge server data after save.
All local changes will be cleared.
Parameters
- $data
- JSON decoded server response
|
public
|
#
mergeAfterFetch( array $data )
Merge server data after fetch.
Merge server data after fetch.
Local changes will be cleared. Though it is different from
megerAfterSave, that changes on new fields (which do not exist
on server) will be preserved until saved to server.
Parameters
- $data
- JSON decoded server response
|
public
|
#
fetch( )
Fetch data from server
Local unsaved changes will be discarded.
Throws
RuntimeException, CloudException
|
public
|
#
fetchAll( array $objects )
Fetch objects from server
Fetch objects from server
Parameters
- $objects
- Objects to fetch.
Throws
RuntimeException, CloudException
|
public
|
#
destroy( )
Destroy object on server
It does and only destroy current object.
Throws
|
public
LeanCloud\Query
|
#
getQuery( )
Return query object based on the object class
Return query object based on the object class
Returns
|
public
LeanCloud\Relation
|
#
getRelation( string $key )
Get (or build) relation on field
Get (or build) relation on field
Parameters
Returns
Throws
RuntimeException
|
public static
|
#
traverse( array $value, function & $seen, $func )
Traverse value in a hierarchy of arrays and objects
Traverse value in a hierarchy of arrays and objects
Array and data attributes of LeanObject will be traversed, each time
a non-array value found the func will be invoked with the value as
arguement.
Parameters
- $value
- $seen Objects that have been traversed
- $seen
- $func A function to call when non-array value found.
- $func
|
public
array
|
#
findUnsavedChildren( )
Find unsaved children (both files and objects) of object.
Find unsaved children (both files and objects) of object.
Returns
array
|
public static
|
#
saveAll( array $objects )
Save objects and associated unsaved children and files.
Save objects and associated unsaved children and files.
Parameters
- $objects
- Array of objects to save
Throws
RuntimeException
|
public static
|
#
destroyAll( array $objects )
Delete objects in batch
Parameters
- $objects
- Array of Objects to destroy
|