Example #1
0
 /**
  * Checks progress of installation
  *
  * @return JsonModel
  */
 public function progressAction()
 {
     $percent = 0;
     $success = false;
     $contents = [];
     $json = new JsonModel();
     // Depending upon the install environment and network latency, there is a possibility that
     // "progress" check request may arrive before the Install POST request. In that case
     // "install.log" file may not be created yet. Check the "install.log" is created before
     // trying to read from it.
     if (!$this->log->logfileExists()) {
         return $json->setVariables(['progress' => $percent, 'success' => true, 'console' => $contents]);
     }
     try {
         $progress = $this->progressFactory->createFromLog($this->log);
         $percent = sprintf('%d', $progress->getRatio() * 100);
         $success = true;
         $contents = $this->log->get();
         if ($this->sampleDataState->hasError()) {
             $json->setVariable('isSampleDataError', true);
         }
     } catch (\Exception $e) {
         $contents = [(string) $e];
     }
     return $json->setVariables(['progress' => $percent, 'success' => $success, 'console' => $contents]);
 }
 public function testCreateFromLog()
 {
     $contents = ['[Progress: 1 / 5] Installing A...', 'Output from A...', '[Progress: 2 / 5] Installing B...', 'Output from B...', '[Progress: 3 / 5] Installing C...', 'Output from C...'];
     $logger = $this->getMock('Magento\\Setup\\Model\\WebLogger', [], [], '', false);
     $logger->expects($this->once())->method('get')->will($this->returnValue($contents));
     $progressFactory = new ProgressFactory();
     $progress = $progressFactory->createFromLog($logger);
     $this->assertEquals(3, $progress->getCurrent());
     $this->assertEquals(5, $progress->getTotal());
 }
Example #3
0
 /**
  * Checks progress of installation
  *
  * @return JsonModel
  */
 public function progressAction()
 {
     $percent = 0;
     $success = false;
     try {
         $progress = $this->progressFactory->createFromLog($this->log);
         $percent = sprintf('%d', $progress->getRatio() * 100);
         $success = true;
         $contents = $this->log->get();
     } catch (\Exception $e) {
         $contents = [(string) $e];
     }
     return new JsonModel(['progress' => $percent, 'success' => $success, 'console' => $contents]);
 }
Example #4
0
 /**
  * Checks progress of installation
  *
  * @return JsonModel
  */
 public function progressAction()
 {
     $percent = 0;
     $success = false;
     $json = new JsonModel();
     try {
         $progress = $this->progressFactory->createFromLog($this->log);
         $percent = sprintf('%d', $progress->getRatio() * 100);
         $success = true;
         $contents = $this->log->get();
     } catch (\Exception $e) {
         $contents = [(string)$e];
         if ($e instanceof \Magento\Setup\SampleDataException) {
             $json->setVariable('isSampleDataError', true);
         }
     }
     return $json->setVariables(['progress' => $percent, 'success' => $success, 'console' => $contents]);
 }