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


PHP SerializationContext::accept方法代码示例

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


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

示例1: serializeEmbeddeds

 /**
  * {@inheritdoc}
  */
 public function serializeEmbeddeds(array $embeddeds, XmlSerializationVisitor $visitor, SerializationContext $context)
 {
     foreach ($embeddeds as $embedded) {
         if ($embedded->getData() instanceof \Traversable || is_array($embedded->getData())) {
             foreach ($embedded->getData() as $data) {
                 $entryNode = $visitor->getDocument()->createElement('resource');
                 $visitor->getCurrentNode()->appendChild($entryNode);
                 $visitor->setCurrentNode($entryNode);
                 $visitor->getCurrentNode()->setAttribute('rel', $embedded->getRel());
                 if (null !== ($node = $context->accept($data))) {
                     $visitor->getCurrentNode()->appendChild($node);
                 }
                 $visitor->revertCurrentNode();
             }
             continue;
         }
         $entryNode = $visitor->getDocument()->createElement('resource');
         $visitor->getCurrentNode()->appendChild($entryNode);
         $visitor->setCurrentNode($entryNode);
         $visitor->getCurrentNode()->setAttribute('rel', $embedded->getRel());
         if (null !== ($node = $context->accept($embedded->getData()))) {
             $visitor->getCurrentNode()->appendChild($node);
         }
         $visitor->revertCurrentNode();
     }
 }
开发者ID:jmcclell,项目名称:Hateoas,代码行数:29,代码来源:XmlHalSerializer.php

示例2: serializeEmbeddeds

 /**
  * {@inheritdoc}
  */
 public function serializeEmbeddeds(array $embeddeds, JsonSerializationVisitor $visitor, SerializationContext $context)
 {
     $serializedEmbeddeds = array();
     $multiple = array();
     foreach ($embeddeds as $embedded) {
         if (!isset($serializedEmbeddeds[$embedded->getRel()])) {
             $serializedEmbeddeds[$embedded->getRel()] = $context->accept($embedded->getData());
         } elseif (!isset($multiple[$embedded->getRel()])) {
             $multiple[$embedded->getRel()] = true;
             $serializedEmbeddeds[$embedded->getRel()] = array($serializedEmbeddeds[$embedded->getRel()], $context->accept($embedded->getData()));
         } else {
             $serializedEmbeddeds[$embedded->getRel()][] = $context->accept($embedded->getData());
         }
     }
     $visitor->addData('_embedded', $serializedEmbeddeds);
 }
开发者ID:ruudk,项目名称:Hateoas,代码行数:19,代码来源:JsonHalSerializer.php

示例3: serializeEmbedded

 /**
  * {@inheritdoc}
  */
 public function serializeEmbedded(array $embeds, JsonSerializationVisitor $visitor, SerializationContext $context)
 {
     $serializedEmbeds = array();
     foreach ($embeds as $embed) {
         $serializedEmbeds[$embed->getRel()] = $context->accept($embed->getData());
     }
     $visitor->addData('_embedded', $serializedEmbeds);
 }
开发者ID:anthonyhowell,项目名称:Hateoas,代码行数:11,代码来源:JsonHalSerializer.php

示例4: write

 /**
  * @param DirectoryEntries $object
  * @param VisitorInterface $visitor
  * @param SerializationContext $context
  * @return string
  */
 public function write($object, VisitorInterface $visitor, SerializationContext $context) {
   return $context->accept($object, $this->getType());
 }
开发者ID:nuxeo,项目名称:nuxeo-automation-php-client,代码行数:9,代码来源:DirectoryEntriesMarshaller.php

示例5: serialize

 public function serialize(VisitorInterface $visitor, Form $form, array $type, SerializationContext $context)
 {
     return $context->accept($form->createView());
 }
开发者ID:adrienbrault,项目名称:form-serializer,代码行数:4,代码来源:FormToViewHandler.php


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