/** * Returns an associative array encoding of the current operation. * * @return mixed */ public function _encode() { if ($this->isAssociativeArray) { $object = new \stdClass(); foreach ($this->value as $key => $value) { $object->{$key} = AVClient::_encode($value, true); } return AVClient::_encode($object, true); } return AVClient::_encode($this->value, true); }
/** * Returns associative array representing encoded operation. * * @return array */ public function _encode() { return array('__op' => 'Add', 'objects' => AVClient::_encode($this->objects, true)); }
/** * Returns JSON object of the unsaved operations. * * @return array */ private function getSaveJSON() { return AVClient::_encode($this->operationSet, true); }
/** * Returns an associative array encoding of the current operation. * * @return mixed * * @throws \Exception */ public function _encode() { $addRelation = array(); $removeRelation = array(); if (!empty($this->relationsToAdd)) { $addRelation = array('__op' => 'AddRelation', 'objects' => AVClient::_encode(self::convertToOneDimensionalArray($this->relationsToAdd), true)); } if (!empty($this->relationsToRemove)) { $removeRelation = array('__op' => 'RemoveRelation', 'objects' => AVClient::_encode(self::convertToOneDimensionalArray($this->relationsToRemove), true)); } if (!empty($addRelation) && !empty($removeRelation)) { return array('__op' => 'Batch', 'ops' => [$addRelation, $removeRelation]); } return empty($addRelation) ? $removeRelation : $addRelation; }