BigIntType.php
3 years ago
DateTimeTzToStringType.php
3 years ago
JsonOrSerializedType.php
3 years ago
JsonType.php
3 years ago
SerializedArrayType.php
3 years ago
index.php
3 years ago
JsonOrSerializedType.php
32 lines
| 1 | <?php // phpcs:ignore SlevomatCodingStandard.TypeHints.DeclareStrictTypes.DeclareStrictTypesMissing |
| 2 | |
| 3 | namespace MailPoet\Doctrine\Types; |
| 4 | |
| 5 | if (!defined('ABSPATH')) exit; |
| 6 | |
| 7 | |
| 8 | use MailPoetVendor\Doctrine\DBAL\Platforms\AbstractPlatform; |
| 9 | |
| 10 | class JsonOrSerializedType extends JsonType { |
| 11 | const NAME = 'json_or_serialized'; |
| 12 | |
| 13 | public function convertToPHPValue($value, AbstractPlatform $platform) { |
| 14 | if ($value === null) { |
| 15 | return null; |
| 16 | } |
| 17 | |
| 18 | if (is_resource($value)) { |
| 19 | $value = stream_get_contents($value); |
| 20 | } |
| 21 | |
| 22 | if (is_serialized($value)) { |
| 23 | return unserialize($value); |
| 24 | } |
| 25 | return parent::convertToPHPValue($value, $platform); |
| 26 | } |
| 27 | |
| 28 | public function getName() { |
| 29 | return self::NAME; |
| 30 | } |
| 31 | } |
| 32 |