Пример #1
0
 public static function convertToCleverObject($resp, $auth)
 {
     $types = array('district' => 'CleverDistrict', 'school' => 'CleverSchool', 'teacher' => 'CleverTeacher', 'student' => 'CleverStudent', 'section' => 'CleverSection', 'event' => 'CleverEvent', 'school_admin' => 'CleverSchoolAdmin');
     if (is_array($resp) && array_key_exists('data', $resp) && self::isList($resp['data'])) {
         $mapped = array();
         foreach ($resp['data'] as $i) {
             array_push($mapped, self::convertToCleverObject($i, $auth));
         }
         return $mapped;
     } else {
         if (is_array($resp) && array_key_exists('data', $resp)) {
             if (isset($resp['uri']) && is_string($resp['uri']) && preg_match('/^\\/(\\S*)\\/(\\S+)s\\/(\\S*)$/', $resp['uri'], $match) && isset($types[$match[2]])) {
                 $class = $types[$match[2]];
             } else {
                 $class = 'CleverObject';
             }
             return CleverObject::scopedConstructFrom($class, $resp['data'], $auth);
         } else {
             return $resp;
         }
     }
 }
Пример #2
0
 public static function init()
 {
     self::$_permanentAttributes = new CleverSet(array('_auth'));
 }