當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Serializer::toArray方法代碼示例

本文整理匯總了PHP中JMS\Serializer\Serializer::toArray方法的典型用法代碼示例。如果您正苦於以下問題:PHP Serializer::toArray方法的具體用法?PHP Serializer::toArray怎麽用?PHP Serializer::toArray使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在JMS\Serializer\Serializer的用法示例。


在下文中一共展示了Serializer::toArray方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: unmapObject

 /**
  * @param mixed $object
  * @return array
  */
 public function unmapObject($object)
 {
     if (is_array($object)) {
         return $object;
     }
     return $this->serializer->toArray($object);
 }
開發者ID:raphhh,項目名稱:balloon,代碼行數:11,代碼來源:DataMapper.php

示例2: it_serializes_objects

 /** @test */
 public function it_serializes_objects()
 {
     $object = new \stdClass();
     $this->serializer->toArray($object, Argument::any())->willReturn(['key' => 'value']);
     $data = $this->converter->toArray($object);
     $this->assertEquals(['event' => ['name' => 'stdClass', 'data' => ['key' => 'value']]], $data);
 }
開發者ID:ClearcodeHQ,項目名稱:SimpleBusElkBundle,代碼行數:8,代碼來源:ObjectToArrayConverterTest.php

示例3: call

 /**
  * @param $procedureName
  * @param $arguments
  * @return \React\Promise\Promise
  */
 public function call($procedureName, $arguments, $argumentsKw = [], $options = null)
 {
     $arguments = $arguments ?: [$arguments];
     $argumentsKw = $argumentsKw ?: [$argumentsKw];
     $arguments = $this->serializer->toArray($arguments);
     $argumentsKw = $this->serializer->toArray($argumentsKw);
     //If we already have a client open that we can use, use that
     if ($this->container->initialized('wamp_kernel') && ($client = $this->container->get('wamp_kernel')->getClient())) {
         $session = $this->container->get('wamp_kernel')->getSession();
         return $session->call($procedureName, $arguments, $argumentsKw, $options);
     }
     Logger::set(new NullLogger());
     //So logs don't show up on the web page
     //If we don't already have a long running client, get a short lived one.
     $client = $this->getShortClient();
     $deferrer = new Deferred();
     $client->on("open", function (ClientSession $session, TransportInterface $transport) use($deferrer, $procedureName, $arguments, $argumentsKw, $options) {
         $session->call($procedureName, $arguments, $argumentsKw, $options)->then(function ($res) use($deferrer, $transport) {
             $transport->close();
             $deferrer->resolve($res);
         });
     });
     $client->on("error", function ($error) use($procedureName) {
         $this->container->get('logger')->addError("Got the following error when trying to call '{$procedureName}': {$error}");
         throw new \Exception("Got the following error when trying to call '{$procedureName}': {$error}");
     });
     $client->start();
     return $deferrer->promise();
 }
開發者ID:trajedy,項目名稱:ThruwayBundle,代碼行數:34,代碼來源:ClientManager.php

示例4: serializeResult

 /**
  * Run the RPC result through JMS serializer, so that entities get serialized properly
  *
  * @param $rawResult
  * @param $mapping
  * @return mixed|static
  */
 protected function serializeResult($rawResult, $mapping)
 {
     //Create a serialization context
     $context = $this->createSerializationContext($mapping);
     if ($rawResult instanceof Promise) {
         return $rawResult->then(function ($d) use($context) {
             //If the data is a CallResult, we only want to serialize the first argument
             $d = $d instanceof CallResult ? [$d[0]] : $d;
             return $this->serializer->toArray($d, $context);
         });
     } elseif ($rawResult !== null) {
         return $this->serializer->toArray($rawResult, $context);
     }
 }
開發者ID:TNAJanssen,項目名稱:ThruwayBundle,代碼行數:21,代碼來源:WampKernel.php

示例5: convert

 private function convert($object)
 {
     return ['event' => ['name' => $this->getClassName($object), 'data' => $this->serializer->toArray($object, SerializationContext::create()->setSerializeNull(true))]];
 }
開發者ID:ClearcodeHQ,項目名稱:SimpleBusElkBundle,代碼行數:4,代碼來源:ObjectToArrayConverter.php

示例6: getAttributes

 /**
  * {@inheritdoc}
  */
 public function getAttributes($model, array $fields = null)
 {
     return $this->serializer->toArray($model);
 }
開發者ID:kleijnweb,項目名稱:swagger-bundle-example,代碼行數:7,代碼來源:JmsSerializerSerializer.php


注:本文中的JMS\Serializer\Serializer::toArray方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。