Created
November 15, 2016 13:44
-
-
Save m4tthumphrey/96b785f1270836ad349a72d1cb79040a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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