getBinary() public static method

Deprecation:
public static getBinary ( ) : string
return string
Beispiel #1
0
 /**
  * Progress wrapper (if use stepmode).
  *
  * @param string $name
  * @param int $total
  * @param int $stepSize
  * @param \Closure $onStart
  * @param \Closure $onStepMode
  * @param \Closure $onFinish
  */
 protected function _progressWrap($name, $total, $stepSize, $onStart, $onStepMode, $onFinish)
 {
     $_this = $this;
     $step = $this->_getOpt('step');
     $profile = $this->_getOpt('profile');
     $stepMode = $this->_getOpt('stepmode');
     $isFinished = false;
     if ($stepMode) {
         if ($step >= 0) {
             $onStepMode($step);
         } else {
             $this->_progressBar($name, $total, $stepSize, function ($currentStep) use($profile, $total, $_this, $name) {
                 $phpBin = Env::getBinary();
                 $binPath = './' . FS::getRelative($_SERVER['SCRIPT_FILENAME'], JPATH_ROOT, '/');
                 $options = array('profile' => $profile, 'step' => (int) $currentStep, 'stepmode' => '', 'q' => '');
                 $command = $phpBin . ' ' . $binPath . ' ' . $name;
                 $result = Cli::exec($command, $options, JPATH_ROOT, false);
                 if (0 && $this->_isDebug()) {
                     $_this->_($result);
                 }
                 return $currentStep <= $total;
             });
             $isFinished = true;
         }
     } else {
         $isFinished = $onStart();
     }
     $onFinish($isFinished);
 }
Beispiel #2
0
 public function testBinaryCanBeRetrieved()
 {
     $this->assertInternalType('string', Env::getBinary());
 }
Beispiel #3
0
 /**
  * Execute method of command
  *
  * @param InputInterface  $input
  * @param OutputInterface $output
  * @return int|null|void
  *
  * @SuppressWarnings(PHPMD.Superglobals)
  * @SuppressWarnings(PHPMD.NPathComplexity)
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->_executePrepare($input, $output);
     $this->_init();
     // Prepare
     if ((int) $this->_config->get('reindex', 0)) {
         $this->_('Database ReIndex = true', 'info');
         $_GET['controller'] = $_REQUEST['controller'] = 'cli-import';
         // emulate browser and admin CP
     } else {
         $this->_('Database ReIndex = false', 'info');
         $_GET['controller'] = $_REQUEST['controller'] = 'jbimport';
         // emulate browser and admin CP
     }
     $stepMode = $this->_getOpt('stepmode');
     $step = $this->_getOpt('step');
     $profileName = $this->_getOpt('profile');
     $csvInfo = $this->_getCsvInfo();
     $sesData = $this->_initJoomlaSession($csvInfo);
     $stepSize = $this->_getStepSize();
     $rowsCount = $sesData['count'];
     $stepsCount = (int) ceil($rowsCount / $stepSize);
     if ($stepsCount <= 0) {
         $this->_('Count of steps is <= 0', 'Error', 1);
     }
     $this->_showProfiler('Import - prepared');
     $this->_('CSV File: ' . $csvInfo['path'], 'Info');
     $this->_('CSV lines: ' . $csvInfo['count'], 'Info');
     $this->_('Step size: ' . $stepSize, 'Info');
     $this->_('Steps count: ' . $stepsCount, 'Info');
     $this->_('Step mode: ' . ($stepMode ? 'on' : 'off'), 'Info');
     // Show progress bar and run process
     $jbimport = $this->_jbimport;
     $_this = $this;
     $isFinished = false;
     if ($stepMode) {
         if ($step >= 0) {
             $jbimport->itemsProcess($step);
             $this->_addTmpData($this->_jbsession->get('ids', 'import-ids'));
         } else {
             $this->_cleanTmpData();
             $this->_progressBar('import', $stepsCount, 1, function ($currentStep) use($jbimport, $stepsCount, $profileName, $_this) {
                 $phpBin = Env::getBinary();
                 $binPath = './' . FS::getRelative($_SERVER['SCRIPT_FILENAME'], JPATH_ROOT, '/');
                 $options = array('profile' => $profileName, 'step' => (int) $currentStep, 'stepmode' => '', 'q' => '');
                 $result = Cli::exec($phpBin . ' ' . $binPath . ' import:items', $options, JPATH_ROOT, false);
                 if (0 && $this->_isDebug()) {
                     $_this->_($result);
                 }
                 return $currentStep <= $stepsCount;
             });
             $this->_jbsession->set('ids', $this->_getTmpData(), 'import-ids');
             $isFinished = true;
         }
     } else {
         $this->_progressBar('import', $stepsCount, 1, function ($currentStep) use($jbimport) {
             $result = $jbimport->itemsProcess($currentStep);
             return $result['progress'] >= 100 ? false : true;
         });
         $isFinished = true;
     }
     if ($isFinished) {
         $this->_showProfiler('Import - finished');
         // Remove or disable other items
         $this->_jbsession->set('ids', $this->_getTmpData(), 'import-ids');
         $this->_postImport();
         $this->_showProfiler('Import - Post handler');
         $this->_moveCsvFile($csvInfo['path']);
         $this->_showProfiler('Import - Done!');
         $this->_cleanTmpData();
     }
 }