PHP code example of sbooker / doctrine-object-mapping
1. Go to this page and download the library: Download sbooker/doctrine-object-mapping library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
sbooker / doctrine-object-mapping example snippets
class Concrete { /* ... */ }
class ConcreteType extends \Sbooker\DoctrineObjectMapping\ObjectType
{
protected function getObjectClass(): string
{
return Concrete::class;
}
public function getName()
{
return 'concrete';
}
}
\Doctrine\DBAL\Types\Type::addType('concrete', ConcreteType::class);
// Create or get normalizer
$normalizer = new \Symfony\Component\Serializer\Normalizer\ObjectNormalizer(/*...*/);
// Set serializer to type on boot application
/** @var \Sbooker\DoctrineObjectMapping\NormalizableType $type */
$type = \Doctrine\DBAL\Types\Type::getType('concrete');
$type->setNormalizer($normalizer);
$type->setDenormalizer($normalizer);