當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。