Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Data Fields
SetupInfo Class Reference

Public Member Functions

 __construct ($server, $projectRoot='')
 
 getUrl ()
 
 getProjectUrl ()
 
 getProjectAdminPath ()
 
 getDir ($projectRoot)
 
 isAvailable ()
 

Data Fields

const PARAM_NOT_INSTALLED_URL_PATH = 'MAGE_NOT_INSTALLED_URL_PATH'
 
const PARAM_NOT_INSTALLED_URL = 'MAGE_NOT_INSTALLED_URL'
 
const DEFAULT_PATH = 'setup'
 

Detailed Description

A model for determining information about setup application

Definition at line 14 of file SetupInfo.php.

Constructor & Destructor Documentation

◆ __construct()

__construct (   $server,
  $projectRoot = '' 
)

Constructor

Parameters
array$server
string$projectRoot
Exceptions

Definition at line 56 of file SetupInfo.php.

57  {
58  $this->server = $server;
59  if (empty($server['DOCUMENT_ROOT'])) {
60  throw new \InvalidArgumentException('DOCUMENT_ROOT variable is unavailable.');
61  }
62  $this->docRoot = rtrim(str_replace('\\', '/', $server['DOCUMENT_ROOT']), '/');
63  $this->projectRoot = $projectRoot ?: $this->detectProjectRoot();
64  $this->projectRoot = str_replace('\\', '/', $this->projectRoot);
65  }

Member Function Documentation

◆ getDir()

getDir (   $projectRoot)

Gets setup application directory path in the filesystem

Parameters
string$projectRoot
Returns
string

Definition at line 136 of file SetupInfo.php.

137  {
138  return rtrim($projectRoot, '/') . '/' . $this->getPath();
139  }

◆ getProjectAdminPath()

getProjectAdminPath ( )

Get the admin area path

Returns
string

Definition at line 125 of file SetupInfo.php.

◆ getProjectUrl()

getProjectUrl ( )

Gets the "main" application URL

Returns
string

Definition at line 109 of file SetupInfo.php.

110  {
111  $isProjectInDocRoot = false !== strpos($this->projectRoot . '/', $this->docRoot . '/');
112  if (empty($this->server['HTTP_HOST'])) {
113  return '';
114  } elseif (!$isProjectInDocRoot) {
115  return 'http://' . $this->server['HTTP_HOST'] . '/';
116  }
117  return 'http://' . $this->server['HTTP_HOST'] . substr($this->projectRoot . '/', strlen($this->docRoot));
118  }
elseif(isset( $params[ 'redirect_parent']))
Definition: iframe.phtml:17

◆ getUrl()

getUrl ( )

Gets setup application URL

Returns
string

Definition at line 96 of file SetupInfo.php.

97  {
98  if (isset($this->server[self::PARAM_NOT_INSTALLED_URL])) {
99  return $this->server[self::PARAM_NOT_INSTALLED_URL];
100  }
101  return Request\Http::getDistroBaseUrlPath($this->server) . $this->getPath() . '/';
102  }
static getDistroBaseUrlPath($server)
Definition: Http.php:362

◆ isAvailable()

isAvailable ( )

Checks if the setup application is available in current document root

Returns
bool

Definition at line 146 of file SetupInfo.php.

147  {
148  $setupDir = $this->getDir($this->projectRoot);
149  $isSubDir = false !== strpos($setupDir . '/', $this->docRoot . '/');
150  // Setup is not accessible from pub folder
151  $setupDir = rtrim($setupDir, '/');
152  $lastOccurrence = strrpos($setupDir, '/pub/setup');
153 
154  if (false !== $lastOccurrence) {
155  $setupDir = substr_replace($setupDir, '/setup', $lastOccurrence, strlen('/pub/setup'));
156  }
157 
158  return $isSubDir && realpath($setupDir);
159  }

Field Documentation

◆ DEFAULT_PATH

const DEFAULT_PATH = 'setup'

#- Default path relative to the project root

Definition at line 26 of file SetupInfo.php.

◆ PARAM_NOT_INSTALLED_URL

const PARAM_NOT_INSTALLED_URL = 'MAGE_NOT_INSTALLED_URL'

Definition at line 20 of file SetupInfo.php.

◆ PARAM_NOT_INSTALLED_URL_PATH

const PARAM_NOT_INSTALLED_URL_PATH = 'MAGE_NOT_INSTALLED_URL_PATH'

#+ Initialization parameters for redirecting if the application is not installed

Definition at line 19 of file SetupInfo.php.


The documentation for this class was generated from the following file: