예제 #1
0
 public static function errorResponseWithForm(AMForm $form)
 {
     $errors = array();
     foreach ($form->validators as $validator) {
         if (!$validator->isValid) {
             $error = GalaxyError::errorWithString($validator->message);
             $errors[] = $error->data();
         }
     }
     $response = new GalaxyResponse();
     $response->data = array('ok' => false, 'type' => GalaxyAPIConstants::kTypeError, 'errors' => $errors);
     return $response;
 }
예제 #2
0
 public function message_details_get($context)
 {
     if ($context->more && $context->channel) {
         $application = GalaxyAPI::applicationIdForChannelId($context->channel);
         $options = array('default' => GalaxyAPI::databaseForId($application));
         $channel = GalaxyAPI::database(GalaxyAPIConstants::kDatabaseMongoDB, GalaxyAPI::databaseForId($context->channel), $options);
         $data = $channel->findOne(array('_id' => $context->more));
         return GalaxyResponse::responseWithData($data);
     } else {
         return GalaxyResponse::responseWithError(GalaxyError::errorWithString('invalid message'));
     }
 }