class JsonArrayType extends JsonType (View source)

Extends the default doctrine JsonArrayType to work with entities.

TODO: If doctrine supports a Postgres 9.4 platform we could default to jsonb.

Constants

FLOW_JSON_ARRAY

Properties

protected $persistenceManager
protected $reflectionService

Methods

string
getName()

No description

string
getSQLDeclaration(array $column, AbstractPlatform $platform)

Use jsonb for PostgreSQL.

array
getMappedDatabaseTypes(AbstractPlatform $platform)

We map jsonb fields to our datatype by default. Doctrine doesn't use jsonb at all.

array|null
convertToPHPValue(mixed $value, AbstractPlatform $platform)

Converts a value from its database representation to its PHP representation of this type.

string|null
convertToDatabaseValue(mixed $value, AbstractPlatform $platform)

Converts a value from its PHP representation to its database representation of this type.

void
initializeDependencies()

Fetches dependencies from the static object manager.

void
decodeObjectReferences(array $array)

Traverses the $array and replaces known persisted objects (tuples of type and identifier) with actual instances.

deserializeValueObject(array $serializedValueObject)

No description

void
encodeObjectReferences(array $array)

Traverses the $array and replaces known persisted objects with a tuple of type and identifier.

static array
serializeValueObject(JsonSerializable $valueObject)

No description

bool
requiresSQLCommentHint(AbstractPlatform $platform)

We require a comment on the column to make doctrine recognize the type on already existing columns

Details

string getName()

No description

Return Value

string

string getSQLDeclaration(array $column, AbstractPlatform $platform)

Use jsonb for PostgreSQL.

The json format, is not comparable in PostgreSQL, something that leads to issues if you want to use DISTINCT in a query. Starting with PostgreSQL 9.4 the jsonb type is available, and the DB knows how to compare it, making distinct queries possible.

Parameters

array $column
AbstractPlatform $platform

Return Value

string

array getMappedDatabaseTypes(AbstractPlatform $platform)

We map jsonb fields to our datatype by default. Doctrine doesn't use jsonb at all.

Parameters

AbstractPlatform $platform

Return Value

array

array|null convertToPHPValue(mixed $value, AbstractPlatform $platform)

Converts a value from its database representation to its PHP representation of this type.

Parameters

mixed $value

The value to convert.

AbstractPlatform $platform

The currently used database platform.

Return Value

array|null

The PHP representation of the value.

Exceptions

ConversionException
TypeConverterException

string|null convertToDatabaseValue(mixed $value, AbstractPlatform $platform)

Converts a value from its PHP representation to its database representation of this type.

Parameters

mixed $value

The value to convert.

AbstractPlatform $platform

The currently used database platform.

Return Value

string|null

The database representation of the value.

Exceptions

JsonException

protected void initializeDependencies()

Fetches dependencies from the static object manager.

Injection cannot be used, since __construct on Types\Type is final.

Return Value

void

protected void decodeObjectReferences(array $array)

Traverses the $array and replaces known persisted objects (tuples of type and identifier) with actual instances.

Parameters

array $array

Return Value

void

Exceptions

TypeConverterException

static JsonSerializable deserializeValueObject(array $serializedValueObject)

No description

Parameters

array $serializedValueObject

Return Value

JsonSerializable

Exceptions

InvalidArgumentException
TypeConverterException

protected void encodeObjectReferences(array $array)

Traverses the $array and replaces known persisted objects with a tuple of type and identifier.

Parameters

array $array

Return Value

void

Exceptions

RuntimeException
JsonException

static array serializeValueObject(JsonSerializable $valueObject)

No description

Parameters

JsonSerializable $valueObject

Return Value

array

Exceptions

RuntimeException
JsonException

bool requiresSQLCommentHint(AbstractPlatform $platform)

We require a comment on the column to make doctrine recognize the type on already existing columns

Parameters

AbstractPlatform $platform

Return Value

bool