ParseObject

Implements \Parse\Internal\Encodable

Class ParseObject - Representation of an object stored on Parse.

author

Fosco Marotto fjm@fb.com

package

Parse

Methods

Create a Parse Object.

__construct(string $className = null, mixed $objectId = null, boolean $isPointer = false) 

Creates a pointer object if an objectId is provided, otherwise creates a new object.

Throws
\Exception

Arguments

$className

string

Class Name for data on Parse.

$objectId

mixed

Object Id for Existing object.

$isPointer

boolean

Getter to catch direct property calls and pass them to the get function.

__get(string $key) : mixed

Arguments

$key

string

Key to retrieve from the Object.

Response

mixed

Magic handler to catch isset calls to object properties.

__isset(string $key) : boolean

Arguments

$key

string

Key to check on the object.

Response

boolean

Setter to catch property calls and protect certain fields.

__set(string $key, mixed $value) 
Throws
\Exception

Arguments

$key

string

Key to set a value on.

$value

mixed

Value to assign.

Return a JSON encoded value of the object.

_encode() : string

Response

string

Returns whether or not data is available for a given key

_isDataAvailable(string $key) : boolean

Arguments

$key

string

Key to check availability of

Response

boolean

Detects if the object (and optionally the child objects) has unsaved changes.

_isDirty(boolean $considerChildren) : boolean

Arguments

$considerChildren

boolean

Whether to consider children when checking for dirty state

Response

boolean

Merges data received from the server.

_mergeAfterFetch(array $result, boolean $completeData = true) 

Arguments

$result

array

Data retrieved from the server.

$completeData

boolean

Fetch all data or not.

Merges data received from the server with a given selected keys.

_mergeAfterFetchWithSelectedKeys(array $result, array $selectedKeys) 

Arguments

$result

array

Data retrieved from the server.

$selectedKeys

array

Keys to be fetched. Null or empty means all data will be fetched.

Handle merging of special fields for the object.

_mergeMagicFields( &$data) 

Arguments

$data

Perform an operation on an object property.

_performOperation(string $key, \Parse\Internal\FieldOperation $operation) 

Arguments

$key

string

Key to perform an operation upon.

$operation

\Parse\Internal\FieldOperation

Operation to perform.

Gets a Pointer referencing this Object.

_toPointer() : array
Throws
\Exception

Response

array

Un-register a subclass.

_unregisterSubclass() 
static

Cannot be called on the base class ParseObject.

Add a value to an array property.

add(string $key, mixed $value) 

Arguments

$key

string

Key for array value on object to add a value to.

$value

mixed

Value to add.

Add unique values to an array property.

addUnique(string $key, mixed $value) 

Arguments

$key

string

Key for array value on object.

$value

mixed

Value list to add uniquely.

Apply operations to a target object.

applyOperations(array $operations,  &$target) 

Arguments

$operations

array

Operations set to apply.

$target

Before save stub

beforeSave() : void

Determine if the current object can be serialized for saving.

canBeSerialized() : boolean

Response

boolean

Checks the given object and any children to see if the whole object can be serialized for saving.

canBeSerializedAsValue(mixed $object) : boolean
static

Arguments

$object

mixed

The value to check.

Response

boolean

Clear all keys on this object by creating delete operations for each key.

clear() 

Static method which returns a new Parse Object for a given class Optionally creates a pointer object if the objectId is provided.

create(string $className, string $objectId = null, boolean $isPointer = false) : \Parse\ParseObject
static

Arguments

$className

string

Class Name for data on Parse.

$objectId

string

Unique identifier for existing object.

$isPointer

boolean

If the object is a pointer.

Response

\Parse\ParseObject

Decodes and returns a ParseObject from an encoded object

decode(string|array $encoded) : \Parse\ParseObject
static
Throws
\Parse\ParseException

Arguments

$encoded

string|array

Encoded ParseObject to decode

Response

\Parse\ParseObject

Save object and unsaved children within.

deepSave(\Parse\ParseObject|array $target, boolean $useMasterKey = false) 
static
Throws
\Exception
\Parse\ParseAggregateException
\Parse\ParseException

Arguments

$target

\Parse\ParseObject|array

$useMasterKey

boolean

Whether to use the Master Key.

Delete a key from an object.

delete(string $key) 

Arguments

$key

string

Key to remove from object.

Delete the object from Parse.

destroy(boolean $useMasterKey = false) 

Arguments

$useMasterKey

boolean

Whether to use the master key.

Delete an array of objects.

destroyAll(array $objects, boolean $useMasterKey = false) 
static
Throws
\Parse\ParseAggregateException

Arguments

$objects

array

Objects to destroy.

$useMasterKey

boolean

Whether to use the master key or not.

Destroy batch of objects.

destroyBatch(array<mixed,\Parse\ParseObject> $objects, boolean $useMasterKey = false) : array
static
Throws
\Parse\ParseException

Arguments

$objects

array<mixed,\Parse\ParseObject>

$useMasterKey

boolean

Response

array

Returns a JSON encoded array of a ParseObject

encode() : string

Response

string

Fetch the whole object from the server and update the local object.

fetch(boolean $useMasterKey = false) : \Parse\ParseObject

Arguments

$useMasterKey

boolean

Whether to use the master key and override ACLs

Response

\Parse\ParseObject

Returns self, so you can chain this call.

Fetch an array of Parse objects from the server.

fetchAll(array $objects, boolean $useMasterKey = false) : array
static

Arguments

$objects

array

The ParseObjects to fetch

$useMasterKey

boolean

Whether to override ACLs

Response

array

Find unsaved children inside an object.

findUnsavedChildren(\Parse\ParseObject $object,  &$unsavedChildren,  &$unsavedFiles) 
static

Arguments

$object

\Parse\ParseObject

Object to search.

$unsavedChildren

$unsavedFiles

Get current value for an object property.

get(string $key) : mixed
Throws
\Exception

Arguments

$key

string

Key to retrieve from the estimatedData array.

Response

mixed

Get the ACL assigned to the object.

getACL() : \Parse\ParseACL

Response

\Parse\ParseACL

Internally retrieves the ACL assigned to this object, conditionally returning a copy of the existing one

getACLWithCopy(boolean $mayCopy) : \Parse\ParseACL

Arguments

$mayCopy

boolean

Whether to return a copy of this acl or not

Response

\Parse\ParseACL

Get values for all keys of an object.

getAllKeys() : array

Response

array

Get the Parse Class Name for the object.

getClassName() : string

Response

string

Get the createdAt for the object, or null if unsaved.

getCreatedAt() : \DateTime|null

Response

\DateTime|null

Get the objectId for the object, or null if unsaved.

getObjectId() : string|null

Response

string|null

Get the registered subclass for a Parse class, or a generic ParseObject if no subclass is registered.

getRegisteredSubclass( $parseClassName) : \Parse\ParseObject
static

Arguments

$parseClassName

Response

\Parse\ParseObject

Access or create a Relation value for a key.

getRelation(string $key, string $className = null) : \Parse\ParseRelation

Arguments

$key

string

The key to access the relation for.

$className

string

The target class name.

Response

\Parse\ParseRelation

The ParseRelation object if the relation already exists for the key or can be created for this key.

Returns JSON object of the unsaved operations.

getSaveJSON() : array

Response

array

Gets the Subclass className if exists, otherwise false.

getSubclass() 
static

Get the updatedAt for the object, or null if unsaved.

getUpdatedAt() : \DateTime|null

Response

\DateTime|null

Check if the object has a given key.

has(string $key) : boolean

Arguments

$key

string

Key to check

Response

boolean

Determines whether this object has child objects that are dirty

hasDirtyChildren() : boolean

Response

boolean

Check whether there is a subclass registered for a given parse class.

hasRegisteredSubclass( $parseClassName) : boolean
static

Arguments

$parseClassName

Response

boolean

Increment a numeric key by a certain value.

increment(string $key, integer $value = 1) 

Arguments

$key

string

Key for numeric value on object to increment.

$value

integer

Value to increment by.

Returns true if the object has been fetched.

isDataAvailable() : boolean

Response

boolean

Check if the object or any of its child objects have unsaved operations.

isDirty() : boolean

Response

boolean

Check if the a value associated with a key has been added/updated/removed and not saved yet.

isKeyDirty(string $key) : boolean

Arguments

$key

string

Response

boolean

Merge server data after a save completes.

mergeAfterSave(array $result) 

Arguments

$result

array

Data retrieved from server.

Merge data from other object.

mergeFromObject(\Parse\ParseObject $other) 

Arguments

$other

\Parse\ParseObject

Other object to merge data from

Merges data received from the server.

mergeFromServer(array $data, boolean $completeData = true) 

Arguments

$data

array

Data retrieved from server.

$completeData

boolean

Fetch all data or not.

Creates a ParseQuery for the subclass of ParseObject.

query() : \Parse\ParseQuery
static

Cannot be called on the base class ParseObject.

Throws
\Exception

Response

\Parse\ParseQuery

Start from serverData and process operations to generate the current value set for an object.

rebuildEstimatedData() 

Register a subclass. Should be called before any other Parse functions.

registerSubclass() 
static

Cannot be called on the base class ParseObject.

Throws
\Exception

Remove a value from an array for an object key.

remove(string $key, mixed $value) 
Throws
\Exception

Arguments

$key

string

Key to remove the value from on the object.

$value

mixed

Value to remove from the array.

Revert all unsaved operations.

revert() 

Save Object to Parse.

save(boolean $useMasterKey = false) 

Arguments

$useMasterKey

boolean

Whether to use the Master Key.

Save all the objects in the provided array.

saveAll(array $list, boolean $useMasterKey = false) 
static

Arguments

$list

array

$useMasterKey

boolean

Whether to use the Master Key.

Validate and set a value for an object key.

set(string $key, mixed $value) 
Throws
\Exception

Arguments

$key

string

Key to set a value for on the object.

$value

mixed

Value to set on the key.

Set ACL for this object.

setACL(\Parse\ParseACL $acl) 

Arguments

Set an array value for an object key.

setArray(string $key, array $value) 
Throws
\Exception

Arguments

$key

string

Key to set the value for on the object.

$value

array

Value to set on the key.

Set an associative array value for an object key.

setAssociativeArray(string $key, array $value) 
Throws
\Exception

Arguments

$key

string

Key to set the value for on the object.

$value

array

Value to set on the key.

Creates an array of object ids from a given array of ParseObjects

toObjectIdArray(array $objects) : array
static
Throws
\Parse\ParseException

Arguments

$objects

array

Objects to create id array from

Response

array

Traverse object to find children.

traverse(boolean $deep,  &$object, callable $mapFunction, array $seen = array()) : mixed
static

Arguments

$deep

boolean

Should this call traverse deeply

$object

$mapFunction

callable

Function to call for every item.

$seen

array

Objects already seen.

Response

mixed

The result of calling mapFunction on the root object.

Merges an existing array of objects with their fetched counterparts

updateWithFetchedResults(array $objects, array $fetched) : array
static
Throws
\Parse\ParseException

Arguments

$objects

array

Original objects to update

$fetched

array

Fetched object data to update with

Response

array

Properties

Data as it exists on the server.

serverData : array
var

Type(s)

array

Set of unsaved operations.

operationSet : array
var

Type(s)

array

Estimated value of applying operationSet to serverData.

estimatedData : array
var

Type(s)

array

Determine if data available for a given key or not.

dataAvailability : array
var

Type(s)

array

Class name for data on Parse.

className : string
var

Type(s)

string

Unique identifier on Parse.

objectId : string
var

Type(s)

string

Timestamp when object was created.

createdAt : \DateTime
var

Type(s)

\DateTime

Timestamp when object was last updated.

updatedAt : \DateTime
var

Type(s)

\DateTime

Whether the object has been fully fetched from Parse.

hasBeenFetched : boolean
var

Type(s)

boolean

Holds the registered subclasses and Parse class names.

registeredSubclasses : array
static
var

Type(s)

array