Esempio n. 1
0
 /**
  * @return JsonModel
  */
 public function indexAction()
 {
     //@todo I fix it
     $moduleCount = count($this->moduleList->getModules());
     $log = $this->logger->get();
     $progress = 0;
     if (!empty($log)) {
         $progress = round(count($log) / $moduleCount * 90);
     }
     $progress += 5;
     return $this->json->setVariables(array('progress' => $progress, 'success' => !$this->logger->hasError(), 'console' => $log));
 }
Esempio n. 2
0
 /**
  * @return JsonModel
  */
 public function indexAction()
 {
     $this->logger->clear();
     $data = Json::decode($this->getRequest()->getContent(), Json::TYPE_ARRAY);
     $this->config->setConfigData($data);
     $this->config->install();
     $this->setupFactory->setConfig($this->config->getConfigData());
     $moduleNames = array_keys($this->moduleList);
     foreach ($moduleNames as $moduleName) {
         $setup = $this->setupFactory->create($moduleName);
         $setup->applyUpdates();
         $this->logger->logSuccess($moduleName);
     }
     $this->logger->logSuccess('Artifact');
     // Set data to config
     $setup->addConfigData('web/seo/use_rewrites', isset($data['config']['rewrites']['allowed']) ? $data['config']['rewrites']['allowed'] : 0);
     $setup->addConfigData('web/unsecure/base_url', isset($data['config']['address']['web']) ? $data['config']['address']['web'] : '{{unsecure_base_url}}');
     $setup->addConfigData('web/secure/use_in_frontend', isset($data['config']['https']['front']) ? $data['config']['https']['front'] : 0);
     $setup->addConfigData('web/secure/base_url', isset($data['config']['address']['web']) ? $data['config']['address']['web'] : '{{secure_base_url}}');
     $setup->addConfigData('web/secure/use_in_adminhtml', isset($data['config']['https']['admin']) ? $data['config']['https']['admin'] : 0);
     $setup->addConfigData('general/locale/code', isset($data['store']['language']) ? $data['store']['language'] : 'en_US');
     $setup->addConfigData('general/locale/timezone', isset($data['store']['timezone']) ? $data['store']['timezone'] : 'America/Los_Angeles');
     $currencyCode = isset($data['store']['currency']) ? $data['store']['currency'] : 'USD';
     $setup->addConfigData('currency/options/base', $currencyCode);
     $setup->addConfigData('currency/options/default', $currencyCode);
     $setup->addConfigData('currency/options/allow', $currencyCode);
     // Create administrator account
     $this->adminAccountFactory->setConfig($this->config->getConfigData());
     $adminAccount = $this->adminAccountFactory->create($setup);
     $adminAccount->save();
     $this->logger->logSuccess('Admin User');
     if ($data['config']['encrypt']['type'] == 'magento') {
         $key = md5($this->random->getRandomString(10));
     } else {
         $key = $data['config']['encrypt']['key'];
     }
     $this->config->replaceTmpEncryptKey($key);
     $this->config->replaceTmpInstallDate(date('r'));
     $this->json->setVariable('success', true);
     $this->json->setVariable('key', $key);
     return $this->json;
 }
 /**
  * @return JsonModel
  */
 public function indexAction()
 {
     $this->logger->clear();
     $data = Json::decode($this->getRequest()->getContent(), Json::TYPE_ARRAY);
     $this->config->setConfigData($data);
     $this->config->install();
     $this->setupFactory->setConfig($this->config->getConfigData());
     $moduleNames = array_keys($this->moduleList);
     foreach ($moduleNames as $moduleName) {
         $setup = $this->setupFactory->create($moduleName);
         $setup->applyUpdates();
         $this->logger->logSuccess($moduleName);
     }
     $this->logger->logSuccess('Artifact');
     // Set data to config
     $setup->addConfigData('web/seo/use_rewrites', isset($data['config']['rewrites']['allowed']) ? $data['config']['rewrites']['allowed'] : 0);
     $setup->addConfigData('web/unsecure/base_url', isset($data['config']['address']['web']) ? $data['config']['address']['web'] : '{{unsecure_base_url}}');
     $setup->addConfigData('web/secure/use_in_frontend', isset($data['config']['https']['front']) ? $data['config']['https']['front'] : 0);
     $setup->addConfigData('web/secure/base_url', isset($data['config']['address']['web']) ? $data['config']['address']['web'] : '{{secure_base_url}}');
     $setup->addConfigData('web/secure/use_in_adminhtml', isset($data['config']['https']['admin']) ? $data['config']['https']['admin'] : 0);
     $setup->addConfigData('general/locale/code', isset($data['store']['language']) ? $data['store']['language'] : 'en_US');
     $setup->addConfigData('general/locale/timezone', isset($data['store']['timezone']) ? $data['store']['timezone'] : 'America/Los_Angeles');
     $currencyCode = isset($data['store']['currency']) ? $data['store']['currency'] : 'USD';
     $setup->addConfigData('currency/options/base', $currencyCode);
     $setup->addConfigData('currency/options/default', $currencyCode);
     $setup->addConfigData('currency/options/allow', $currencyCode);
     // Create administrator account
     $this->adminAccountFactory->setConfig($this->config->getConfigData());
     $adminAccount = $this->adminAccountFactory->create($setup);
     $adminAccount->save();
     $this->logger->logSuccess('Admin User');
     if ($data['config']['encrypt']['type'] == 'magento') {
         $key = md5($this->random->getRandomString(10));
     } else {
         $key = $data['config']['encrypt']['key'];
     }
     $this->config->replaceTmpEncryptKey($key);
     $this->config->replaceTmpInstallDate(date('r'));
     $phpPath = $this->phpExecutablePath();
     exec($phpPath . 'php -f ' . escapeshellarg($this->systemConfig->create()->getMagentoBasePath() . '/dev/shell/run_data_fixtures.php'), $output, $exitCode);
     if ($exitCode !== 0) {
         $outputMsg = implode(PHP_EOL, $output);
         $this->logger->logError(new \Exception('Data Update Failed with Exit Code: ' . $exitCode . PHP_EOL . $outputMsg));
         $this->json->setVariable('success', false);
     } else {
         $this->logger->logSuccess('Data Updates');
         $this->json->setVariable('success', true);
     }
     $this->json->setVariable('key', $key);
     return $this->json;
 }
Esempio n. 4
0
 /**
  * Run module modification files. Return version of last applied upgrade (false if no upgrades applied)
  * @param string $actionType
  * @param string $fromVersion
  * @param string $toVersion
  * @return false|string
  * @throws \Exception
  */
 protected function _modifyResourceDb($actionType, $fromVersion, $toVersion)
 {
     switch ($actionType) {
         case self::TYPE_DB_INSTALL:
         case self::TYPE_DB_UPGRADE:
             $files = $this->_getAvailableDbFiles($actionType, $fromVersion, $toVersion);
             break;
         case self::TYPE_DATA_INSTALL:
         case self::TYPE_DATA_UPGRADE:
             break;
         default:
             $files = array();
             break;
     }
     if (empty($files) || !$this->getConnection()) {
         return false;
     }
     $version = false;
     foreach ($files as $file) {
         $fileName = $file['fileName'];
         $fileType = pathinfo($fileName, PATHINFO_EXTENSION);
         try {
             switch ($fileType) {
                 case 'php':
                     $result = $this->_includeFile($fileName);
                     break;
                 default:
                     $result = false;
                     break;
             }
             if ($result) {
                 $this->_setResourceVersion($actionType, $file['toVersion']);
                 //@todo log
             } else {
                 //@todo log "Failed resource setup: {$fileName}";
             }
         } catch (\Exception $e) {
             $this->logger->logError($e);
             throw new \Exception(sprintf('Error in file: "%s" - %s', $fileName, $e->getMessage()), 0, $e);
         }
         $version = $file['toVersion'];
     }
     return $version;
 }