public function returnObjectArray(array $data, $classname, $key = null)
    {
        $objects = array();
        foreach ($data as $object) {
          if (null === $key) {
              $objects[] = new $classname($object);
          } else {
              $objects[$object->$key] = new $classname($object);
          }
        }
        return $objects;
    }