Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Protected Attributes
Install Class Reference
Inheritance diagram for Install:

Public Member Functions

 __construct (WebLogger $logger, InstallerFactory $installerFactory, ProgressFactory $progressFactory, \Magento\Framework\Setup\SampleData\State $sampleDataState, DeploymentConfig $deploymentConfig, RequestDataConverter $requestDataConverter)
 
 indexAction ()
 
 startAction ()
 
 progressAction ()
 

Protected Attributes

 $sampleDataState
 

Detailed Description

Install controller

@SuppressWarnings(PHPMD.CouplingBetweenObjects)

Definition at line 27 of file Install.php.

Constructor & Destructor Documentation

◆ __construct()

__construct ( WebLogger  $logger,
InstallerFactory  $installerFactory,
ProgressFactory  $progressFactory,
\Magento\Framework\Setup\SampleData\State  $sampleDataState,
DeploymentConfig  $deploymentConfig,
RequestDataConverter  $requestDataConverter 
)

Default Constructor

Parameters
WebLogger$logger
InstallerFactory$installerFactory
ProgressFactory$progressFactory
\Magento\Framework\Setup\SampleData\State$sampleDataState
\Magento\Framework\App\DeploymentConfig$deploymentConfig
RequestDataConverter$requestDataConverter

Definition at line 69 of file Install.php.

76  {
77  $this->log = $logger;
78  $this->installer = $installerFactory->create($logger);
79  $this->progressFactory = $progressFactory;
80  $this->sampleDataState = $sampleDataState;
81  $this->deploymentConfig = $deploymentConfig;
82  $this->requestDataConverter = $requestDataConverter;
83  }
$logger
$deploymentConfig

Member Function Documentation

◆ indexAction()

indexAction ( )
Returns
ViewModel

Definition at line 88 of file Install.php.

89  {
90  $view = new ViewModel;
91  $view->setTerminal(true);
92  return $view;
93  }

◆ progressAction()

progressAction ( )

Checks progress of installation

Returns
JsonModel

Definition at line 132 of file Install.php.

133  {
134  $percent = 0;
135  $success = false;
136  $contents = [];
137  $json = new JsonModel();
138 
139  // Depending upon the install environment and network latency, there is a possibility that
140  // "progress" check request may arrive before the Install POST request. In that case
141  // "install.log" file may not be created yet. Check the "install.log" is created before
142  // trying to read from it.
143  if (!$this->log->logfileExists()) {
144  return $json->setVariables(['progress' => $percent, 'success' => true, 'console' => $contents]);
145  }
146 
147  try {
148  $progress = $this->progressFactory->createFromLog($this->log);
149  $percent = sprintf('%d', $progress->getRatio() * 100);
150  $success = true;
151  $contents = $this->log->get();
152  if ($this->sampleDataState->hasError()) {
153  $json->setVariable('isSampleDataError', true);
154  }
155  } catch (\Exception $e) {
156  $contents = [(string)$e];
157  }
158  return $json->setVariables(['progress' => $percent, 'success' => $success, 'console' => $contents]);
159  }
$contents
Definition: website.php:14
if($this->helper('Magento\Tax\Helper\Data') ->displayFullSummary()) foreach( $block->getTotal() ->getFullInfo() as $info)(isset($info['hidden']) && $info['hidden']) $percent
Definition: tax.phtml:33

◆ startAction()

startAction ( )

Index Action

Returns
JsonModel

Definition at line 100 of file Install.php.

101  {
102  $this->log->clear();
103  $json = new JsonModel;
104  try {
105  $this->checkForPriorInstall();
106  $content = $this->getRequest()->getContent();
107  $source = $content ? $source = Json::decode($content, Json::TYPE_ARRAY) : [];
108  $data = $this->requestDataConverter->convert($source);
109  $this->installer->install($data);
110  $json->setVariable(
111  'key',
112  $this->installer->getInstallInfo()[SetupConfigOptionsList::KEY_ENCRYPTION_KEY]
113  );
114  $json->setVariable('success', true);
115  if ($this->sampleDataState->hasError()) {
116  $json->setVariable('isSampleDataError', true);
117  }
118  $json->setVariable('messages', $this->installer->getInstallInfo()[Installer::INFO_MESSAGE]);
119  } catch (\Exception $e) {
120  $this->log->logError($e);
121  $json->setVariable('messages', $e->getMessage());
122  $json->setVariable('success', false);
123  }
124  return $json;
125  }
$source
Definition: source.php:23

Field Documentation

◆ $sampleDataState

$sampleDataState
protected

Definition at line 47 of file Install.php.


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