/**
  * {@inheritdoc}
  */
 public function normalize($product, $format = null, array $context = [])
 {
     if (!$this->normalizer instanceof NormalizerInterface) {
         throw new \LogicException('Serializer must be a normalizer');
     }
     $data = [];
     if (null !== $product->getId()) {
         $data[self::MONGO_ID] = $this->mongoFactory->createMongoId($product->getId());
     } else {
         $data[self::MONGO_ID] = $this->mongoFactory->createMongoId();
     }
     $context[self::MONGO_ID] = $data[self::MONGO_ID];
     if (null !== $product->getCreated()) {
         $data['created'] = $this->normalizer->normalize($product->getCreated(), self::FORMAT, $context);
     } else {
         $data['created'] = $this->mongoFactory->createMongoDate();
     }
     $data['updated'] = $this->mongoFactory->createMongoDate();
     $data['family'] = $product->getFamily() ? $product->getFamily()->getId() : null;
     $data['enabled'] = $product->isEnabled();
     $data['groupIds'] = $this->normalizeGroups($product->getGroups());
     $data['categoryIds'] = $this->normalizeCategories($product->getCategories());
     $data['associations'] = $this->normalizeAssociations($product->getAssociations(), $context);
     $data['values'] = $this->normalizeValues($product->getValues(), $context);
     $data['normalizedData'] = $this->normalizer->normalize($product, 'mongodb_json');
     $data['completenesses'] = [];
     unset($data['normalizedData']['completenesses']);
     return $data;
 }
 /**
  * {@inheritdoc}
  */
 public function normalize($dateTime, $format = null, array $context = [])
 {
     return $this->mongoFactory->createMongoDate($dateTime->getTimestamp());
 }