当前位置: 首页>>代码示例>>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;未经允许,请勿转载。