public function loadFromRawData($data, $reset = false) { if ($reset) { $this->initValues(); } if (isset($data['organization']) && is_array($data['organization'])) { $organization = new Organization($this->config); $organization->loadFromRawData($data['organization']); $this->organization = $organization; } if (isset($data['product'])) { $product = new Product($this->config); $product->loadFromRawData($data['product']); $this->product = $product; } $this->status = isset($data['status']) ? $data['status'] : null; }
public function addProduct($product) { if (!is_object($product) || !$product instanceof Product) { if (!is_int($product) && !is_string($product)) { throw new ParameterException('Invalid product.'); } $product_id = (string) $product; $product = new Product($this->config); $product->load($product_id); } $this->products[] = $product; }
public function getRatePlanDetailsByProduct(Product $product = null) { if ($product == null) { return $this->ratePlanDetails; } else { $rate_plan_details = array(); foreach ($this->ratePlanDetails as &$rate_plan_detail) { if (isset($rate_plan_detail->product) && $rate_plan_detail->product->getId() == $product->getId()) { $rate_plan_details[] = $rate_plan_detail; } } return $rate_plan_details; } }
/** * Implements BaseObject::loadFromRawData($data, $reset = false) * * @param array $data * @param bool $reset */ public function loadFromRawData($data, $reset = false) { if ($reset) { $this->initValues(); } if (isset($data['virtualCurrency'])) { $this->virtualCurrency = new DataStructures\SupportedCurrency($data['virtualCurrency']); } if (isset($data['organization'])) { $organization = new Organization($this->config); $organization->loadFromRawData($data['organization']); $this->organization = $organization; } if (isset($data['product'])) { foreach ($data['product'] as $product_item) { $product = new Product($this->config); $product->loadFromRawData($product_item); $this->products[] = $product; } } $excluded_properties = array('organization', 'product', 'virtualCurrency'); 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 . '"'); } } }
public function loadFromRawData($data, $reset = false) { if ($reset) { $this->initValues(); } $excluded_properties = array('organization', 'product', 'subOrg', 'developer', 'billableDeveloper', 'billableExchangeOrg'); 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 (isset($data['organization'])) { $organization = new Organization($this->config); $organization->loadFromRawData($data['organization']); $this->organization = $organization; } if (isset($data['product'])) { foreach ($data['product'] as $product_item) { $product = new Product($this->config); $product->loadFromRawData($product_item); $this->product[] = $product; } } if (isset($data['subOrg'])) { foreach ($data['subOrg'] as $sub_org_item) { $organization = new Organization($this->config); $organization->loadFromRawData($sub_org_item); $this->subOrg[] = $organization; } } if (isset($data['developer'])) { foreach ($data['developer'] as $dev_item) { $dev = new Developer($this->config); $dev->loadFromRawData($dev_item); $this->developer[] = $dev; } } if (isset($data['billableDeveloper'])) { $dev = new Developer($this->config); $dev->loadFromRawData($data['billableDeveloper']); $this->billableDeveloper = $dev; } if (isset($data['billableExchangeOrg'])) { $organization = new Organization($this->config); $organization->loadFromRawData($data['billableExchangeOrg']); $this->billableExchangeOrg = $organization; } }