public function __construct(ApiList $list) { //Loop through each product name foreach ($list->getProdName() as $prodName) { $getInfoData = ConfigURL::getURL(ApiInfo::$name, $prodName); //Check for any errors and store them in $_errors array if (isset($getInfoData['error'])) { $this->_errors[$prodName] = $getInfoData['error']; continue; } //Initialize $data array $data = array(); //Loop through the product info and store it in the data array. //In the case of suppliers, call the sanitize escape function. foreach ($getInfoData as $prodKey) { foreach ($prodKey as $name => $value) { switch ($name) { case 'suppliers': $data[$name] = escape(implode(', ', $value)); break; default: $data[$name] = $value; break; } } } //Store all the data in $_productInfo $this->_productInfo[$prodName] = $data; } }
public function __construct() { //Store json_decode array in api1 $api1 = ConfigURL::getURL(ApiList::$name); //Check if products are received, if true, store them in $_products, else get the error received from ConfigURL class if (isset($api1['products'])) { $this->_products = $api1['products']; } else { $this->_errors = ConfigURL::errors(); } }