renderer = $renderer; $this->regionFactory = $regionFactory; $this->countryFactory = $countryFactory; } /** * Retrieve generic object with all the misc store information values * * @param Store $store * @return DataObject */ public function getStoreInformationObject(Store $store) { $info = new DataObject([ 'name' => $store->getConfig(self::XML_PATH_STORE_INFO_NAME), 'phone' => $store->getConfig(self::XML_PATH_STORE_INFO_PHONE), 'hours' => $store->getConfig(self::XML_PATH_STORE_INFO_HOURS), 'street_line1' => $store->getConfig(self::XML_PATH_STORE_INFO_STREET_LINE1), 'street_line2' => $store->getConfig(self::XML_PATH_STORE_INFO_STREET_LINE2), 'city' => $store->getConfig(self::XML_PATH_STORE_INFO_CITY), 'postcode' => $store->getConfig(self::XML_PATH_STORE_INFO_POSTCODE), 'region_id' => $store->getConfig(self::XML_PATH_STORE_INFO_REGION_CODE), 'country_id' => $store->getConfig(self::XML_PATH_STORE_INFO_COUNTRY_CODE), 'vat_number' => $store->getConfig(self::XML_PATH_STORE_INFO_VAT_NUMBER), ]); if ($info->getRegionId()) { $info->setRegion($this->regionFactory->create()->load($info->getRegionId())->getName()); } if ($info->getCountryId()) { $info->setCountry($this->countryFactory->create()->loadByCode($info->getCountryId())->getName()); } return $info; } /** * Retrieve formatted store address from config * * @param Store $store * @return string */ public function getFormattedAddress(Store $store) { return $this->renderer->format($this->getStoreInformationObject($store)); } }