Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Server.php
Go to the documentation of this file.
1 <?php
7 
12 use Zend\Uri\Uri;
13 use Zend\Uri\UriFactory;
14 
15 class Server
16 {
20  protected $urlBuilder;
21 
25  private $config;
26 
30  private $request;
31 
32  const DEFAULT_PORT = 80;
33 
41  public function __construct(
43  DeploymentConfig $config,
44  RequestInterface $request
45  ) {
46  $this->urlBuilder = $urlBuilder;
47  $this->config = $config;
48  $this->request = $request;
49  }
50 
56  public function getUris()
57  {
58  $servers = [];
59  $configuredHosts = $this->config->get(ConfigOptionsListConstants::CONFIG_PATH_CACHE_HOSTS);
60 
61  if (is_array($configuredHosts)) {
62  foreach ($configuredHosts as $host) {
63  $servers[] = UriFactory::factory('')
64  ->setHost($host['host'])
65  ->setPort(isset($host['port']) ? $host['port'] : self::DEFAULT_PORT)
66  ;
67  }
68  } elseif ($this->request->getHttpHost()) {
69  $servers[] = UriFactory::factory('')->setHost($this->request->getHttpHost())->setPort(self::DEFAULT_PORT);
70  } else {
71  $servers[] = UriFactory::factory($this->urlBuilder->getUrl('*', ['_nosid' => true]));
72  }
73 
74  foreach (array_keys($servers) as $key) {
75  $servers[$key]->setScheme('http')
76  ->setPath('/')
77  ->setQuery(null);
78  }
79  return $servers;
80  }
81 }
elseif(isset( $params[ 'redirect_parent']))
Definition: iframe.phtml:17
__construct(UrlInterface $urlBuilder, DeploymentConfig $config, RequestInterface $request)
Definition: Server.php:41
$config
Definition: fraud_order.php:17