Пример #1
0
 public static function convertToTrustedSearchObject($resp, $apiKey)
 {
     $types = array('token' => 'TrustedSearch_Token', 'local_business' => 'TrustedSearch_LocalBusiness', 'business_snapshots' => 'TrustedSearch_BusinessSnapshots');
     if (self::isList($resp)) {
         $mapped = array();
         foreach ($resp as $i) {
             array_push($mapped, self::convertToTrustedSearchObject($i, $apiKey));
         }
         return $mapped;
     } else {
         if (is_array($resp)) {
             if (isset($resp['object']) && is_string($resp['object']) && isset($types[$resp['object']])) {
                 $class = $types[$resp['object']];
             } else {
                 $class = 'TrustedSearch_Object';
             }
             return TrustedSearch_Object::scopedConstructFrom($class, $resp, $apiKey);
         } else {
             return $resp;
         }
     }
 }
Пример #2
0
 public function refreshFrom($values, $apiPublicKey, $apiPrivateKey, $partial = false)
 {
     $this->_apiPublicKey = $apiPublicKey;
     $this->_apiPrivateKey = $apiPrivateKey;
     if ($partial) {
         $removed = new TrustedSearch_Util_Set();
     } else {
         $removed = array_diff(array_keys($this->_values), array_keys($values));
     }
     foreach ($removed as $k) {
         if (self::$_permanentAttributes->includes($k)) {
             continue;
         }
         unset($this->{$k});
     }
     foreach ($values as $k => $v) {
         if (self::$_permanentAttributes->includes($k)) {
             continue;
         }
         if (self::$_nestedUpdatableAttributes->includes($k) && is_array($v)) {
             $this->_values[$k] = TrustedSearch_Object::scopedConstructFrom('TrustedSearch_AttachedObject', $v, $apiPublicKey, $apiPrivateKey);
         } else {
             $this->_values[$k] = TrustedSearch_Util::convertToTrustedSearchObject($v, $apiPublicKey, $apiPrivateKey);
         }
         $this->_transientValues->discard($k);
         $this->_unsavedValues->discard($k);
     }
 }
 public function testKeys()
 {
     $s = new TrustedSearch_Object();
     $s->foo = 'a';
     $this->assertEquals($s->keys(), array('foo'));
 }