本文整理匯總了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());
}