public function serializeToArray(GenericSerializationVisitor $visitor, HalPagerfanta $halPager, array $type, Context $context)
 {
     $shouldSetRoot = null === $visitor->getRoot();
     $pager = $halPager->getPager();
     $data = array('page' => $pager->getCurrentPage(), 'limit' => $pager->getMaxPerPage(), 'total' => $pager->getNbResults());
     if (null !== ($links = $this->linkEventSubscriber->getOnPostSerializeData(new ObjectEvent($context, $pager, $type)))) {
         $data[$this->linksJsonKey] = $links;
     }
     if (null !== ($relations = $this->embedderEventSubscriber->getOnPostSerializeData(new ObjectEvent($context, $pager, $type)))) {
         $data[$this->relationsJsonKey] = $relations;
     }
     $resultsType = array('name' => 'array');
     if (isset($type['params'])) {
         $resultsType['params'] = $type['params'];
     }
     $data[$this->relationsJsonKey][$halPager->getRel()] = $visitor->getNavigator()->accept($pager->getCurrentPageResults(), $resultsType, $context);
     if ($shouldSetRoot) {
         $visitor->setRoot($data);
     }
     return $data;
 }
 /**
  * Normalize event container to serialize with generic serialization
  * Event class name is added
  *
  * @param GenericSerializationVisitor $visitor
  * @param EventContainer              $container
  * @param Context                     $context
  *
  * @return array
  */
 protected function serializeContainer(GenericSerializationVisitor $visitor, EventContainer $container, Context $context)
 {
     $setRoot = $visitor->getRoot() === null;
     $data = array('type' => $this->namingStrategy->classToType(get_class($container->getEvent())), 'data' => $visitor->getNavigator()->accept($container->getEvent(), null, $context));
     if ($setRoot) {
         $visitor->setRoot($data);
     }
     return $data;
 }
 /**
  * @param GenericSerializationVisitor $visitor
  * @param string                      $contentAttributeValue
  * @param array                       $type
  * @param Context                     $context
  *
  * @return null|string
  */
 public function serializeFieldType(GenericSerializationVisitor $visitor, $contentAttributeValue, array $type, Context $context)
 {
     return $visitor->getNavigator()->accept($contentAttributeValue, null, $context);
 }