Beispiel #1
0
 private static function _createObject($parsedObject)
 {
     $objName = key($parsedObject);
     $href = Zipmark_Base::_findSelfHref($parsedObject);
     $newObj = new Zipmark_Resource($objName, $href);
     if (!empty($href)) {
         $newObj->setHref($href);
     } else {
         if ($newObj instanceof Zipmark_Collection) {
             $newObj->_count = Zipmark_Base::_numRecords($parsedObject);
         }
     }
     self::buildObject($objName, $parsedObject[$objName], $newObj);
     return $newObj;
 }
Beispiel #2
0
 /**
  * Save a Zipmark_Resource to the Zipmark Service
  *
  * @return Zipmark_Resource The Zipmark Object
  */
 public function save()
 {
     $method = 'POST';
     if ($this->id) {
         $method = 'PUT';
     }
     $response = $this->getClient()->request($method, $this->pathFor(), $this->toJson());
     Zipmark_Base::parseJsonToUpdateObject($response->body);
     $response->checkResponse($this);
     return $this;
 }
Beispiel #3
0
 /**
  * Refresh the current object list with the list in the current page of results
  */
 private function _loadObjects($response)
 {
     $this->_objects = array();
     $collectionName = $this->getObjectName();
     $parsedBody = json_decode($response->body, true);
     $objects = $parsedBody[$collectionName];
     $objectName = rtrim($collectionName, 's');
     foreach ($objects as $object) {
         $href = Zipmark_Collection::_findObjectHref($object);
         $newObj = new Zipmark_Resource($objectName, $href, $this->getClient());
         if ($newObj instanceof Zipmark_Collection) {
             $newObj->_count = Zipmark_Base::_numRecords($object);
         }
         self::buildObject($objectName, $object, $newObj);
         $this->_objects[] = $newObj;
     }
 }