Symfony Serializer

This commit is contained in:
David Bomba 2024-09-07 17:28:48 +10:00
parent c0483d727f
commit e721351a4b
2 changed files with 6 additions and 5 deletions

View File

@ -32,11 +32,12 @@ class Customer
->first();
if($token && $customer = $this->getCustomer($token->gateway_customer_reference)){
return (new \App\PaymentDrivers\CBAPowerBoard\Models\Parse())->decode(ModelsCustomer::class, $customer->resource->data);
return (new \App\PaymentDrivers\CBAPowerBoard\Models\Parse())->encode(ModelsCustomer::class, $customer->resource->data);
}
if($customer = $this->findCustomer())
return $customer;
return (new \App\PaymentDrivers\CBAPowerBoard\Models\Parse())->encode(ModelsCustomer::class, $customer);
return $this->createCustomer($customer_data);
@ -140,7 +141,7 @@ class Customer
if($r->successful())
$this->storePaymentMethod($r->object());
return $r->object()->resource->data ?? $r->throw();
return (new \App\PaymentDrivers\CBAPowerBoard\Models\Parse())->encode(ModelsCustomer::class, $r->object()->resource->data) ?? $r->throw();
}

View File

@ -29,7 +29,7 @@ class Parse
{
}
public function decode($object_type, $document)
public function encode($object_type, $document)
{
$phpDocExtractor = new PhpDocExtractor();
@ -61,7 +61,7 @@ class Parse
$encoders = [new JsonEncoder()];
$serializer = new Serializer($normalizers, $encoders);
nlog($document);
$data = $serializer->deserialize(json_encode($document), $object_type, 'json', [\Symfony\Component\Serializer\Normalizer\AbstractObjectNormalizer::SKIP_NULL_VALUES => true]);
return $data;