mirror of
https://github.com/alrayyes/wiki.git
synced 2024-11-25 13:06:22 +00:00
37 lines
645 B
Markdown
37 lines
645 B
Markdown
---
|
|
id: 31b5b357-abf4-4abb-9241-1190cbe61f96
|
|
title: UUID Normalizer
|
|
---
|
|
|
|
# Description
|
|
|
|
[UUIDs](20201116131815-symfony_uuid_component) are automatically
|
|
serialized/deserialized as expected.
|
|
|
|
# Syntax
|
|
|
|
``` php
|
|
// src/Entity/Product.php
|
|
namespace App\Entity;
|
|
|
|
use Doctrine\ORM\Mapping as ORM;
|
|
|
|
/**
|
|
* @ORM\Entity(repositoryClass="App\Repository\ProductRepository")
|
|
*/
|
|
class Product
|
|
{
|
|
/**
|
|
* @ORM\Column(type="uuid")
|
|
*/
|
|
private $id;
|
|
|
|
// ...
|
|
}
|
|
```
|
|
|
|
``` php
|
|
$product = new Product();
|
|
$jsonContent = $serializer->serialize($product, 'json');
|
|
// $jsonContent contains {"id":"9b7541de-6f87-11ea-ab3c-9da9a81562fc","...":"..."}
|
|
```
|