entityManager = $entityManager; } public function transform($product) { if (null === $product) { return ''; } return $product->getId(); } public function reverseTransform($productId) { if (!$productId) { return; } $product = $this->entityManager->getRepository( $this->entityManager->getEntityName(ProductInterface::class) )->find($productId); if (null === $product) { throw new TransformationFailedException( sprintf( 'An issue with number "%s" does not exist!', $productId ) ); } return $product; } }