当前位置: 首页>>代码示例>>PHP>>正文


PHP ParseObject::create方法代码示例

本文整理汇总了PHP中Parse\ParseObject::create方法的典型用法代码示例。如果您正苦于以下问题:PHP ParseObject::create方法的具体用法?PHP ParseObject::create怎么用?PHP ParseObject::create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Parse\ParseObject的用法示例。


在下文中一共展示了ParseObject::create方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: createRole

 /**
  * Create a ParseRole object with a given name and ACL.
  *
  * @param string   $name
  * @param ParseACL $acl
  *
  * @return ParseRole
  */
 public static function createRole($name, ParseACL $acl)
 {
     $role = ParseObject::create(static::$parseClassName);
     $role->setName($name);
     $role->setACL($acl);
     return $role;
 }
开发者ID:alex-z82,项目名称:web-friend-smash,代码行数:15,代码来源:ParseRole.php

示例2: store

 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     try {
         ParseClient::initialize(env('PARSE_ID', 'fuck'), env('PARSE_REST', 'fuck'), env('PARSE_MASTER', 'fuck'));
         $data = Input::file('file');
         $path = $data->getRealPath();
         $mime = $data->getMimeType();
         $nomeOriginal = $data->getClientOriginalName();
         $nomeCorrigido = preg_replace('/\\s+/', '', $nomeOriginal);
         $file = ParseFile::createFromFile($path, $nomeCorrigido, $mime);
         $file->save();
         $nome = Input::get('nome');
         $especialidadeId = Input::get('especialidadeId');
         $especQuery = new ParseQuery("Especialidade");
         $especialidade = $especQuery->get($especialidadeId);
         $anexo = ParseObject::create("Anexo");
         $anexo->set('conteudo', $file);
         $anexo->set('nome', $nome);
         $anexo->set('especialidade', $especialidade);
         $anexo->save();
         return json_encode(['url' => $anexo->get('conteudo')->getURL(), 'Id' => $anexo->getObjectId()]);
     } catch (ParseException $error) {
         return $error;
     }
 }
开发者ID:pietrodegrazia,项目名称:regulaSUSWeb,代码行数:30,代码来源:AnexoController.php

示例3: purchase

 public function purchase()
 {
     $input = Input::all();
     $mailEmail = strpos($input['stripeEmail'], "mail.mcgill.ca");
     //send back if not a validStripe Token
     if (empty($input['stripeToken'])) {
         return Redirect::back();
     }
     //Charge Customer
     $charge = Stripe::charges()->create(['source' => $input['stripeToken'], 'receipt_email' => $input['stripeEmail'], 'currency' => 'CAD', 'amount' => env($input['sponsor'] . "_PRICE")]);
     //Save to Parse
     $object = ParseObject::create("Transaction");
     $objectId = $object->getObjectId();
     // Set values:
     $object->set("name", $input['email']);
     $object->set("email", $input['stripeEmail']);
     $object->set("studentID", $input['IdNumber']);
     $object->set("sponsor", $input['sponsor']);
     $object->set("stripeToken", $input['stripeToken']);
     $object->set("used", false);
     $object->set("deal", env($input['sponsor'] . "_DEAL_TITLE"));
     $object->set("deployment", env('DEPLOYMENT'));
     $object->set("experation", env($input['sponsor'] . "_EXPIRATION"));
     // Save:
     $object->save();
     //data to pass
     $data = ["expirationdate" => env($input['sponsor'] . "_EXPIRATION"), "sponsorName" => env($input['sponsor'] . "_RETAILER"), "stripeOrderNumber" => $charge['id'], "price" => env($input['sponsor'] . "_PRICE"), "email" => $input['email'], "flag" => "true"];
     $email = $input['stripeEmail'];
     Mail::send('email.billing', $data, function ($message) use($email) {
         $message->to($email)->subject('Thank you for Your Order');
     });
     return View::make('thanks', $data)->with('data', $data);
 }
开发者ID:alecharmon,项目名称:DealSite,代码行数:33,代码来源:SubscribeController.php

示例4: testFunctionsWithObjectParamsFails

 public function testFunctionsWithObjectParamsFails()
 {
     $obj = ParseObject::create('SomeClass');
     $obj->set('name', 'Zanzibar');
     $obj->save();
     $params = ['key1' => $obj];
     $this->setExpectedException('\\Exception', 'ParseObjects not allowed');
     ParseCloud::run('foo', $params);
 }
开发者ID:louk,项目名称:One-Nice-Thing,代码行数:9,代码来源:ParseCloudTest.php

示例5: testParseBytesFromBase64Data

 public function testParseBytesFromBase64Data()
 {
     $obj = ParseObject::create('BytesObject');
     $bytes = ParseBytes::createFromBase64Data('R3JhbnRsYW5k');
     $obj->set('byteColumn', $bytes);
     $obj->save();
     $query = new ParseQuery('BytesObject');
     $objAgain = $query->get($obj->getObjectId());
     $this->assertEquals('Grantland', $objAgain->get('byteColumn'));
 }
开发者ID:aglo35,项目名称:vr_beta,代码行数:10,代码来源:ParseBytesTest.php

示例6: dtestParseBytesFromBase64Data

 public function dtestParseBytesFromBase64Data()
 {
     $obj = ParseObject::create("TestObject");
     $bytes = ParseBytes::createFromBase64Data("R3JhbnRsYW5k");
     $obj->set("byteColumn", $bytes);
     $obj->save();
     $query = new ParseQuery("TestObject");
     $objAgain = $query->get($obj->getObjectId());
     $this->assertEquals("Grantland", $objAgain->get("byteColumn"));
 }
开发者ID:nidalb,项目名称:baas,代码行数:10,代码来源:ParseBytesTest.php

示例7: postUpdate

 public function postUpdate($objectId)
 {
     $object = ParseObject::create("todo", $objectId);
     if (\Input::has('title')) {
         $object->set("title", \Input::get('title'));
     }
     if (\Input::has('completed')) {
         $object->set("completed", filter_var(\Input::get('completed'), FILTER_VALIDATE_BOOLEAN));
     }
     $object->save();
 }
开发者ID:malimu,项目名称:baas,代码行数:11,代码来源:TodoController.php

示例8: upload_to_parse

function upload_to_parse($name, $image, $description, $archive)
{
    $obj = ParseObject::create("News");
    try {
        $file_image = ParseFile::createFromFile($image, basename($image));
        $obj->set("image", $file_image);
        $obj->set("caption", $name);
        $obj->save();
    } catch (\Parse\ParseException $e) {
        print $e;
    }
}
开发者ID:rochefort8,项目名称:tt85,代码行数:12,代码来源:send.php

示例9: testQueryDataUnt

 public function testQueryDataUnt()
 {
     $department = "ACCT";
     $course = "2010";
     $section = "001";
     $obj = ParseObject::create('TestObject');
     $obj->set('department', $department);
     $obj->set('course', $course);
     $obj->set('section', $section);
     $obj->save();
     $query = new ParseQuery('TestObject');
     $query->startsWith('department', $department);
     $query->equalTo('course', $course);
     $query->startsWith('section', $section);
     $query->limit(1);
     $response = $query->find();
     $this->assertTrue(count($response) == 1);
 }
开发者ID:jmc0592,项目名称:csce4444,代码行数:18,代码来源:ParseHandlerTest.php

示例10: store

 /**
  * Store a newly created resource in storag
  *
  * @return Response
  */
 public function store()
 {
     try {
         ParseClient::initialize(env('PARSE_ID', 'Credenciais Parse'), env('PARSE_REST', 'Credenciais Parse'), env('PARSE_MASTER', 'Credenciais Parse'));
         $input = Request::all();
         $especialidade = ParseObject::create("Especialidade");
         $nome = $input['nome'];
         if (!strlen($nome)) {
             throw new Exception("Nome da especialidade não pode ser vazio", 2);
         }
         $especialidade->set('nome', $nome);
         $especialidade->set('origem', $input['origem']);
         $especialidade->save();
         $id = $especialidade->getObjectId();
         return Redirect::action('EspecialidadeController@show', array($id));
     } catch (ParseException $error) {
         return $error;
     }
 }
开发者ID:pietrodegrazia,项目名称:regulaSUSWeb,代码行数:24,代码来源:EspecialidadeController.php

示例11: create

 /**
  * Show the form for creating a new resource.
  *
  * @return Response
  */
 public function create()
 {
     try {
         ParseClient::initialize(env('PARSE_ID', 'fuck'), env('PARSE_REST', 'fuck'), env('PARSE_MASTER', 'fuck'));
         $session = Cache::get('sessionToken', 'default');
         $user = ParseUser::become($session);
         $nome = Input::get('nome');
         $especialidadeId = Input::get('especialidadeId');
         $especQuery = new ParseQuery("Especialidade");
         $especialidade = $especQuery->get($especialidadeId);
         $protocolo = ParseObject::create("Protocolo");
         $protocolo->set('nome', $nome);
         $protocolo->set('especialidade', $especialidade);
         $protocolo->save();
         $id = $protocolo->getObjectId();
         return $id;
     } catch (ParseException $error) {
         return $error;
     }
 }
开发者ID:pietrodegrazia,项目名称:regulaSUSWeb,代码行数:25,代码来源:ProtocoloController.php

示例12: testFunctions

 public function testFunctions()
 {
     $params = array('key1' => 'value1', 'key2' => array(1, 2, 3));
     $response = ParseCloud::run('foo', $params);
     $obj = $response['object'];
     $this->assertTrue($obj instanceof ParseObject);
     $this->assertEquals('Foo', $obj->className);
     $this->assertEquals(2, $obj->get('x'));
     $relation = $obj->get('relation');
     $this->assertTrue($relation instanceof ParseObject);
     $this->assertEquals('Bar', $relation->className);
     $this->assertEquals(3, $relation->get('x'));
     $obj = $response['array'][0];
     $this->assertTrue($obj instanceof ParseObject);
     $this->assertEquals('Bar', $obj->className);
     $this->assertEquals(2, $obj->get('x'));
     $response = ParseCloud::run('foo', array('key1' => 'value1'));
     $this->assertEquals(2, $response['a']);
     try {
         $response = ParseCloud::run('bar', array('key1' => 'value1'));
         $this->fail('Should have thrown an exception.');
     } catch (Parse\ParseException $ex) {
         // A parse exception should occur.
     }
     $response = ParseCloud::run('bar', array('key2' => 'value1'));
     $this->assertEquals('Foo', $response);
     $obj = ParseObject::create('SomeClass');
     $obj->set('name', 'Zanzibar');
     $obj->save();
     $params = array('key2' => 'value1', 'key1' => $obj);
     try {
         $response = ParseCloud::run('foo', $params);
         $this->fail('Should have thrown an exception.');
     } catch (\Exception $ex) {
         // An exception should occur.
     }
 }
开发者ID:alex-z82,项目名称:web-friend-smash,代码行数:37,代码来源:ParseCloudTest.php

示例13: testGeoBoxTooLarge

 public function testGeoBoxTooLarge()
 {
     $centerPoint = new ParseGeoPoint(0, 0);
     $center = ParseObject::create('TestObject');
     $center->set('location', $centerPoint);
     $center->save();
     $southwest = new ParseGeoPoint(-89, -179);
     $northeast = new ParseGeoPoint(89, 179);
     // This is an interesting test case because mongo can actually handle this
     // kind of query, but
     // if one actually happens, it's probably that the developer switches the
     // two points.
     $query = new ParseQuery('TestObject');
     $query->withinGeoBox('location', $southwest, $northeast);
     try {
         $query->find();
         $this->assertTrue(false, 'Query should fail for being too large.');
     } catch (ParseException $e) {
     }
 }
开发者ID:rvdavid,项目名称:parse-php-sdk,代码行数:20,代码来源:ParseGeoBoxTest.php

示例14: catch

<?php

require 'vendor/autoload.php';
date_default_timezone_set('Asia/Tokyo');
use Parse\ParseObject;
use Parse\ParseQuery;
use Parse\ParseACL;
use Parse\ParsePush;
use Parse\ParseUser;
use Parse\ParseInstallation;
use Parse\ParseException;
use Parse\ParseAnalytics;
use Parse\ParseFile;
use Parse\ParseCloud;
use Parse\ParseClient;
$app_id = 'rLfiUPlbIE5orN0Al07gpotnvIpqwTUpoQlkhjO0';
$rest_key = 'LnIgqdYSz8krs6iKBdH5XtGqglkyjzuSEHTnNbEC';
$master_key = 'jtNDkVGTpaVeregAuvlTYOUCErbKnSMgE7F6x9Fo';
$dest_url = 'https://vivabelgianbeer-server.herokuapp.com/parse';
ParseClient::initialize($app_id, $rest_key, $master_key);
ParseClient::setServerURL($dest_url);
$obj = ParseObject::create("QuestionList");
try {
    $obj->set("title", "ビール");
    $obj->set("text", " ベルギービールは初めてだ");
    $obj->save();
} catch (\Parse\ParseException $e) {
    print $e;
}
开发者ID:rochefort8,项目名称:tt85,代码行数:29,代码来源:viva.php

示例15: _decode

 /**
  * ParseClient::_decode, internal method for decoding server responses.
  *
  * @param mixed $data The value to decode
  *
  * @return mixed
  */
 public static function _decode($data)
 {
     // The json decoded response from Parse will make JSONObjects into stdClass
     //     objects.    We'll change it to an associative array here.
     if ($data instanceof \stdClass) {
         $tmp = (array) $data;
         if (!empty($tmp)) {
             return self::_decode(get_object_vars($data));
         }
     }
     if (!isset($data) && !is_array($data)) {
         return;
     }
     if (is_array($data)) {
         $typeString = isset($data['__type']) ? $data['__type'] : null;
         if ($typeString === 'Date') {
             return new \DateTime($data['iso']);
         }
         if ($typeString === 'Bytes') {
             return base64_decode($data['base64']);
         }
         if ($typeString === 'Pointer') {
             return ParseObject::create($data['className'], $data['objectId']);
         }
         if ($typeString === 'File') {
             return ParseFile::_createFromServer($data['name'], $data['url']);
         }
         if ($typeString === 'GeoPoint') {
             return new ParseGeoPoint($data['latitude'], $data['longitude']);
         }
         if ($typeString === 'Object') {
             $output = ParseObject::create($data['className']);
             $output->_mergeAfterFetch($data);
             return $output;
         }
         if ($typeString === 'Relation') {
             return $data;
         }
         $newDict = [];
         foreach ($data as $key => $value) {
             $newDict[$key] = static::_decode($value);
         }
         return $newDict;
     }
     return $data;
 }
开发者ID:aglo35,项目名称:vr_beta,代码行数:53,代码来源:ParseClient.php


注:本文中的Parse\ParseObject::create方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。