5
5
*/
6
6
namespace Magento \PageCache \Model \Cache ;
7
7
8
- use Zend \ Uri \ Uri ;
8
+ use Magento \ Framework \ UrlInterface ;
9
9
use Magento \Framework \App \DeploymentConfig ;
10
10
use Magento \Framework \Config \ConfigOptionsListConstants ;
11
11
use Magento \Framework \App \RequestInterface ;
12
+ use Zend \Uri \Uri ;
12
13
use Zend \Uri \UriFactory ;
13
14
14
15
class Server
15
16
{
16
17
/**
17
- * @var \Magento\Framework\ UrlInterface
18
+ * @var UrlInterface
18
19
*/
19
20
protected $ urlBuilder ;
20
21
@@ -33,12 +34,12 @@ class Server
33
34
/**
34
35
* Constructor
35
36
*
36
- * @param \Magento\Framework\ UrlInterface $urlBuilder
37
+ * @param UrlInterface $urlBuilder
37
38
* @param DeploymentConfig $config
38
39
* @param RequestInterface $request
39
40
*/
40
41
public function __construct (
41
- \ Magento \ Framework \ UrlInterface $ urlBuilder ,
42
+ UrlInterface $ urlBuilder ,
42
43
DeploymentConfig $ config ,
43
44
RequestInterface $ request
44
45
) {
@@ -56,21 +57,25 @@ public function getUris()
56
57
{
57
58
$ servers = [];
58
59
$ configuredHosts = $ this ->config ->get (ConfigOptionsListConstants::CONFIG_PATH_CACHE_HOSTS );
59
- if (null == $ configuredHosts ) {
60
- $ httpHost = $ this ->request ->getHttpHost ();
61
- $ servers [] = $ httpHost ?
62
- UriFactory::factory ('' )->setHost ($ httpHost )->setPort (self ::DEFAULT_PORT )->setScheme ('http ' ) :
63
- UriFactory::factory ($ this ->urlBuilder ->getUrl ('* ' , ['_nosid ' => true ])) // Don't use SID in building URL
64
- ->setScheme ('http ' )
65
- ->setPath (null )
66
- ->setQuery (null );
67
60
68
- } else {
61
+ if ( is_array ( $ configuredHosts )) {
69
62
foreach ($ configuredHosts as $ host ) {
70
- $ servers [] = UriFactory::factory ('' )->setHost ($ host ['host ' ])
63
+ $ servers [] = UriFactory::factory ('' )
64
+ ->setHost ($ host ['host ' ])
71
65
->setPort (isset ($ host ['port ' ]) ? $ host ['port ' ] : self ::DEFAULT_PORT )
72
- -> setScheme ( ' http ' ) ;
66
+ ;
73
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 ($ servers as $ key => $ value ) {
75
+ $ servers [$ key ]->setScheme ('http ' )
76
+ ->setPath ('/ ' )
77
+ ->setQuery (null )
78
+ ;
74
79
}
75
80
return $ servers ;
76
81
}
0 commit comments