php - Symfony2: How to construct entities from a webservice -


i'm developing web-service entities retrieved rest web-service.

for i'm getting data service based on guzzle in controller , hydrate entities denormalizing serializer

$customer_api = $this->container->get('customer_api');  $data = $customer_api->getcustomer([     "customerid" => $id_customer, ]);  $customer = customer::hydrate($data); 

here's hydrate function

public static function hydrate($data) {     $encoders = array(new jsonencoder());     $normalizers = array(new getsetmethodnormalizer());      $serializer = new serializer($normalizers, $encoders);      $entity = $serializer->denormalize($data, get_called_class());      return $entity; } 

as i'm getting deeper in code i'm starting need entities load other entities. far i've read it's pretty bad give access container models

how refactor use model constructor instead

$customer = new customer($id_customer); 


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

jquery - javascript onscroll fade same class but with different div -