countryCollectionFactory->create() ->loadByStore() ->toOptionArray(false); } public function getContactBackgroundUrl(): string { return $this->storeManager->getStore()->getBaseUrl(UrlInterface::URL_TYPE_MEDIA) . 'wysiwyg/about/icons/esun-contact-bk.png'; } public function getConfigJson(): string { $moduleDir = $this->moduleDirReader->getModuleDir('', 'Esun_Agent'); $dataFile = $moduleDir . '/view/frontend/web/data/agents.json'; if (!$this->file->isExists($dataFile)) { throw new RuntimeException('Agent data file does not exist.'); } $data = json_decode($this->file->fileGetContents($dataFile), true, 512, JSON_THROW_ON_ERROR); $data['agents'] = []; $mediaUrl = $this->storeManager->getStore()->getBaseUrl(UrlInterface::URL_TYPE_MEDIA); $collection = $this->collectionFactory->create() ->addFieldToFilter('is_active', 1) ->setOrder('sort_order', 'ASC') ->setOrder('entity_id', 'ASC'); foreach ($collection as $agentModel) { $logo = (string) $agentModel->getData('logo'); $position = $this->countryPosition->get((string) $agentModel->getData('country_code')); $data['agents'][] = [ 'id' => (int) $agentModel->getId(), 'system_name' => (string) $agentModel->getData('system_name'), 'name' => (string) $agentModel->getData('name'), 'continent' => (string) $agentModel->getData('continent'), 'country_code' => (string) $agentModel->getData('country_code'), 'country' => (string) $agentModel->getData('country'), 'website' => (string) $agentModel->getData('website'), 'address' => (string) $agentModel->getData('address'), 'note' => (string) $agentModel->getData('note'), 'map_x' => $position['x'] ?? null, 'map_y' => $position['y'] ?? null, 'sort_order' => (int) $agentModel->getData('sort_order'), 'logo_url' => $logo !== '' ? $mediaUrl . ltrim($logo, '/') : $this->getViewFileUrl('Esun_Agent::images/agents/placeholder.svg'), ]; } unset($agent); $config = [ 'data' => $data, 'mapUrl' => $this->getViewFileUrl('Esun_Agent::images/world-map-dots.svg'), 'labels' => [ 'agents' => (string) __('Agents'), 'exploreAll' => (string) __('Explore All'), 'noResults' => (string) __('No agents match the selected filters.'), 'website' => (string) __('Website'), 'filteredResults' => (string) __('Filtered Results (%1 matched partners)'), 'previousPage' => (string) __('Previous page'), 'nextPage' => (string) __('Next page'), 'page' => (string) __('Page %1'), ], ]; return (string) json_encode( $config, JSON_HEX_TAG | JSON_HEX_AMP | JSON_HEX_APOS | JSON_HEX_QUOT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE | JSON_THROW_ON_ERROR ); } }