$shops =
new ArrayCollection();
if (!
empty($data['shops'
])) { // Clear all shops, to save the old and new ones then
$payment->
getShops()->
clear();
foreach ($data['shops'
] as $shop) { $model =
$this->
get('models'
)->
find(Shop::
class,
$shop['id'
]);
$shops->
add($model);
} $data['shops'
] =
$shops;
} $data['surchargeString'
] =
$this->
filterSurchargeString($data['surchargeString'
] ?? '',
$data['countries'
] ??
[]);
$payment->
fromArray($data);
// A default parameter "action" is sent
// To prevent "updatePayment" written into the database
if (empty($action)) { $payment->
setAction(''
);
} else { $payment->
setAction($action);
}