public function __construct(private readonly EntityRepository
$salutationRepository) { } /**
* @param array|\Traversable $entity
*
* @return array|\Traversable
*/
public function deserialize(Config
$config, EntityDefinition
$definition,
$entity) { $deserialized = parent::
deserialize($config,
$definition,
$entity);
$deserialized = \
is_array($deserialized) ?
$deserialized :
iterator_to_array($deserialized);
if (!
isset($deserialized['id'
]) &&
isset($deserialized['salutationKey'
])) { $id =
$this->
getSalutationId($deserialized['salutationKey'
]);
// if we dont find it by salutationKey, only set the id to the fallback if we dont have any other data
if (!
$id && \
count($deserialized) === 1
) { $id =
$this->
getSalutationId('not_specified'
);
unset($deserialized['salutationKey'
]);
}