Ejemplo n.º 1
0
 public function loadFromRawData($data, $reset = false)
 {
     if ($reset) {
         $this->initValues();
     }
     $excluded_properties = array('pricePoints', 'suborgProducts', 'organization', 'developerCategory', 'broker');
     foreach (array_keys($data) as $property) {
         if (in_array($property, $excluded_properties)) {
             continue;
         }
         // form the setter method name to invoke setXxxx
         $setter_method = 'set' . ucfirst($property);
         if (method_exists($this, $setter_method)) {
             $this->{$setter_method}($data[$property]);
         } else {
             self::$logger->notice('No setter method was found for property "' . $property . '"');
         }
     }
     if (array_key_exists('pricePoints', $data) && is_array($data['pricePoints'])) {
         foreach ($data['pricePoints'] as $price_point_item) {
             $price_point = new PricePoint($this->id, $this->config);
             $price_point->loadFromRawData($price_point_item);
             $this->pricePoints[] = $price_point;
         }
     }
     if (array_key_exists('suborgProducts', $data) && is_array($data['suborgProducts'])) {
         foreach ($data['suborgProducts'] as $suborg_product_item) {
             $suborg_product = new SuborgProduct($this->id, $this->config);
             $suborg_product->loadFromRawData($suborg_product_item);
             $this->suborgProducts[] = $suborg_product;
         }
     }
     if (array_key_exists('organization', $data)) {
         $organization = new Organization($this->config);
         $organization->loadFromRawData($data['organization']);
         $this->organization = $organization;
     }
     if (array_key_exists('developerCategory', $data) && is_array($data['developerCategory'])) {
         foreach ($data['developerCategory'] as $cat_item) {
             $category = new DeveloperCategory($this->config);
             $category->loadFromRawData($cat_item);
             $this->developerCategories[] = $category;
         }
     }
     // TODO verify that brokers are Developers
     if (array_key_exists('broker', $data) && is_array($data['broker'])) {
         foreach ($data['broker'] as $broker_item) {
             $broker = new Developer($this->config);
             $broker->loadFromRawData($broker_item);
             $this->brokers[] = $broker;
         }
     }
 }
Ejemplo n.º 2
0
 public function loadFromRawData($data, $reset = false)
 {
     if ($reset) {
         $this->initValues();
     }
     $excluded_properties = array('address', 'organization', 'transactionBrokerages', 'ratePlan', 'parentId', 'developerCategory');
     foreach (array_keys($data) as $property) {
         if (in_array($property, $excluded_properties)) {
             continue;
         }
         // form the setter method name to invoke setXxxx
         $setter_method = 'set' . ucfirst($property);
         if (method_exists($this, $setter_method)) {
             $this->{$setter_method}($data[$property]);
         } else {
             self::$logger->notice('No setter method was found for property "' . $property . '"');
         }
     }
     $this->id = $data['id'];
     if (isset($data['address']) && is_array($data['address']) && count($data['address']) > 0) {
         foreach ($data['address'] as $addr_item) {
             $this->addresses[] = new DataStructures\Address($addr_item);
         }
     }
     if (isset($data['organization'])) {
         $organization = new Organization($this->config);
         $organization->loadFromRawData($data['organization']);
         $this->organization = $organization;
     }
     if (isset($data['transactionBrokerages'])) {
         foreach ($data['transactionBrokerages'] as $trans_brok) {
             $this->transactionBrokerages[] = new TransactionBrokerage($trans_brok);
         }
     }
     if (isset($data['ratePlan'])) {
         foreach ($data['ratePlan'] as $rate_plan_data) {
             $dev_rate_plan = new DeveloperRatePlan($this->email, $this->config);
             $dev_rate_plan->loadFromRawData($rate_plan_data);
             $this->ratePlan[] = $dev_rate_plan;
         }
     }
     if (isset($data['parentId'])) {
         $parent = new Developer($this->config);
         $parent->loadFromRawData($data['parentId']);
         $this->parentId = $parent;
     }
     if (isset($data['developerCategory'])) {
         $dev_cat = new DeveloperCategory($this->config);
         $dev_cat->loadFromRawData($data['developerCategory']);
         $this->developerCategory = $dev_cat;
     }
 }