/** * @param GenericDeserializationVisitor $visitor * @param string $contentAttributeValue * @param array $type * @param Context $context * * @return null|string */ public function deserializeFieldType(GenericDeserializationVisitor $visitor, $contentAttributeValue, array $type, Context $context) { $facade = $visitor->getCurrentObject(); if ($facade instanceof ContentAttributeFacade && null !== $facade->type) { if (isset($this->fieldTypes[$facade->type]) && isset($this->fieldTypes[$facade->type]['deserialize_type'])) { return $visitor->getNavigator()->accept($contentAttributeValue, array('name' => $this->fieldTypes[$facade->type]['deserialize_type']), $context); } } return null; }
/** * Create container from generic decoded array * * @param GenericDeserializationVisitor $visitor * @param array $data * @param \JMS\Serializer\Context $context * * @return EventContainer * @throws RuntimeException */ protected function deserializeContainer(GenericDeserializationVisitor $visitor, array $data, Context $context) { if (!isset($data['data']) || !isset($data['type'])) { throw new RuntimeException('Missed properties in the deserialized data array: "event", "type"'); } $container = $this->createEventContainer(); $visitor->startVisitingObject($context->getMetadataFactory()->getMetadataForClass(get_class($container)), $container, [], $context); $event = $visitor->getNavigator()->accept($data['data'], array('name' => $this->namingStrategy->typeToClass($data['type'])), $context); if (!is_object($event)) { throw new RuntimeException(sprintf('Deserialized Event object expected, got "%s"', gettype($event))); } if (!$event instanceof Event) { throw new RuntimeException(sprintf('Deserialized Event object expected, got "%s"', get_class($event))); } $this->setContainerEvent($container, $event); return $visitor; }