private readonly CustomFieldService
$attributeService ) { parent::
__construct($validator,
$definitionRegistry);
} public function encode(Field
$field, EntityExistence
$existence, KeyValuePair
$data, WriteParameterBag
$parameters): \Generator
{ if (!
$field instanceof CustomFields
) { throw DataAbstractionLayerException::
invalidSerializerField(CustomFields::
class,
$field);
} $this->
validateIfNeeded($field,
$existence,
$data,
$parameters);
/** @var array<string, mixed> $attributes */
$attributes =
$data->
getValue();
if ($attributes === null
) { yield $field->
getStorageName() => null;
return;
} if (empty($attributes)) { yield $field->
getStorageName() => '{}';