Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

merged in master

  • Loading branch information...
commit 26283142410c1a900bf33d9a21935993227ff5a3 2 parents afb02cc + f564f0d
@zznate zznate authored
View
18 sdks/php/lib/vendor/Apigee/Usergrid/Collection.php
@@ -274,5 +274,21 @@ public function get_prev_page() {
}
return FALSE;
}
+ public function serialize(){
+ $data = array();
+ $data->type = $this->type;
+ $data->qs = $this->qs;
+ $data->iterator = $this->iterator;
+ $data->previous = $this->previous;
+ $data->next = $this->next;
+ $data->cursor = $this->cursor;
+ $data->list=[];
+ $this->reset_entity_pointer();
+ while ($this->has_next_entity()) {
+ $entity = $this->get_next_entity();
+ array_push($data->list, $entity->get_json())
+ }
+ return json_encode($data);
+ }
-}
+}
View
90 sdks/php/lib/vendor/Apigee/Usergrid/Entity.php
@@ -200,19 +200,97 @@ public function destroy() {
}
public function connect($connection, $entity) {
- // TODO
+ $connectee=Entity::get_entity_id($entity);
+ $connecteeType=$entity->get("type");
+ if(!$connectee){
+ return "Error in connect. No UUID specified for connectee";
+ }
+
+ $connector=Entity::get_entity_id($this);
+ $connectorType=$this->get("type");
+ if(!$connector){
+ return "Error in connect. No UUID specified for connector";
+ }
+
+ $endpoint = $connectorType.'/'.$connector.'/'.$connection.'/'.$connecteeType.'/'.$connectee;
+ $result=$this->client->post($endpoint, array(), array());
+ $error=$result->get_error();
+ if($error){
+ return $result->get_error_message();
+ }else{
+ return $result->get_data();
+ }
+ }
+
+ public function disconnect($connection, $entity) {
+ $connectee=Entity::get_entity_id($entity);
+ $connecteeType=$entity->get("type");
+ if(!$connectee){
+ return "Error in disconnect. No UUID specified for connectee";
+ }
+
+ $connector=Entity::get_entity_id($this);
+ $connectorType=$this->get("type");
+ if(!$connector){
+ return "Error in disconnect. No UUID specified for connector";
+ }
+
+ $endpoint = $connectorType.'/'.$connector.'/'.$connection.'/'.$connecteeType.'/'.$connectee;
+
+ $result=$this->client->delete($endpoint, array(), array());
+ $error=$result->get_error();
+ if($error){
+ return $result->get_error_message();
+ }else{
+ return $result->get_data();
+ }
}
public static function get_entity_id($entity) {
- // TODO
+ $id = false;
+ if (Client::is_uuid($entity->get('uuid'))) {
+ $id = $entity->get('uuid');
+ } else {
+ if ($type == 'users') {
+ $id = $entity->get('username');
+ } else if ($entity->get('name')) {
+ $id = $entity->get('name');
+ }
+ }
+ return $id;
}
public function get_connections($connection) {
- // TODO
+ $connectorType = $this->get('type');
+ $connector = Entity::get_entity_id($this);
+ if (!$connector) {
+ return;
+ }
+
+ $endpoint = $connectorType . '/' . $connector . '/' . $connection . '/';
+ $result=$this->client->get($endpoint, array());
+ $this->set($connection,array());
+
+ $length = count($result->entities);
+ for ($i = 0; i < $length; $i++) {
+ if ($result['entities'][i]['type'] == 'user') {
+ $this[$connection][$result['entities'][i]['username']] = $result['entities'][i];
+ } else {
+ $this[$connection][$result['entities'][i]['name']] = $result['entities'][i];
+ }
+ }
}
- public function disconnect($connection, $entity) {
- // TODO
+ public function get_connecting($connection) {
+ $connectorType = $this->get('type');
+ $connector = Entity::get_entity_id($this);
+ if (!$connector) {
+ return;
+ }
+
+ $endpoint = $connectorType. '/' . $connector . '/connecting/' . $connection . '/';
+ $result=$this->client->get($endpoint, array());
+ return $result->get_data();
}
-}
+}
Please sign in to comment.
Something went wrong with that request. Please try again.