本文整理汇总了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();
}
}
示例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);
}
示例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);
}
示例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());
}
示例5: serialize
public function serialize(VisitorInterface $visitor, Form $form, array $type, SerializationContext $context)
{
return $context->accept($form->createView());
}