Skip to content

Instantly share code, notes, and snippets.

@m4tthumphrey
Created November 15, 2016 13:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save m4tthumphrey/96b785f1270836ad349a72d1cb79040a to your computer and use it in GitHub Desktop.
Save m4tthumphrey/96b785f1270836ad349a72d1cb79040a to your computer and use it in GitHub Desktop.
<?php namespace ContractsBundle\Dbal\Types;
use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Types\Type;
class JsonSerializable extends Type
{
public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform)
{
return 'json';
}
public function getName()
{
return 'json_serializable';
}
public function convertToPHPValue($value, AbstractPlatform $platform)
{
return json_decode($value, true);
}
public function convertToDatabaseValue($value, AbstractPlatform $platform)
{
return $value->toJson();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment