Exemplo n.º 1
0
    /**
     * @param InputInterface  $input
     * @param OutputInterface $output
     *
     * @return int|void
     */
    protected function execute(InputInterface $input, OutputInterface $output)
    {
        $initialized = false;
        try {
            $this->detectMagento($output);
            $initialized = $this->initMagento();
        } catch (Exception $e) {
            // do nothing
        }
        $parser = new Parser(new Lexer());
        $cleaner = new CodeCleaner($parser);
        $consoleOutput = new ShellOutput();
        $config = new Configuration();
        $config->setCodeCleaner($cleaner);
        $shell = new Shell($config);
        $shell->setScopeVariables(['di' => $this->getObjectManager()]);
        if ($initialized) {
            $ok = Charset::convertInteger(Charset::UNICODE_CHECKMARK_CHAR);
            $edition = $this->productMeta->getEdition();
            $magentoVersion = $this->productMeta->getVersion();
            $consoleOutput->writeln('<fg=black;bg=green>Magento ' . $magentoVersion . ' ' . $edition . ' initialized.</fg=black;bg=green> ' . $ok);
        } else {
            $consoleOutput->writeln('<fg=black;bg=yellow>Magento is not initialized.</fg=black;bg=yellow>');
        }
        $help = <<<'help'
At the prompt, type <comment>help</comment> for some help.

To exit the shell, type <comment>^D</comment>.
help;
        $consoleOutput->writeln($help);
        $shell->run($input, $consoleOutput);
    }
Exemplo n.º 2
0
 /**
  * Sets the response body to ProductName/Major.MinorVersion (Edition). E.g.: Magento/0.42 (Community). Omits patch
  * version from response
  *
  * @return void
  */
 public function execute()
 {
     $versionParts = explode('.', $this->productMetadata->getVersion());
     if (!isset($versionParts[0]) || !isset($versionParts[1])) {
         return;
         // Major and minor version are not set - return empty response
     }
     $majorMinorVersion = $versionParts[0] . '.' . $versionParts[1];
     $this->getResponse()->setBody($this->productMetadata->getName() . '/' . $majorMinorVersion . ' (' . $this->productMetadata->getEdition() . ')');
 }
Exemplo n.º 3
0
    /**
     * Retrieve feed data as XML element
     *
     * @return \SimpleXMLElement
     */
    public function getFeedData()
    {
        $curl = $this->curlFactory->create();
        $curl->setConfig(
            [
                'timeout'   => 2,
                'useragent' => $this->productMetadata->getName()
                    . '/' . $this->productMetadata->getVersion()
                    . ' (' . $this->productMetadata->getEdition() . ')',
                'referer'   => $this->urlBuilder->getUrl('*/*/*')
            ]
        );
        $curl->write(\Zend_Http_Client::GET, $this->getFeedUrl(), '1.0');
        $data = $curl->read();
        if ($data === false) {
            return false;
        }
        $data = preg_split('/^\r?$/m', $data, 2);
        $data = trim($data[1]);
        $curl->close();

        try {
            $xml = new \SimpleXMLElement($data);
        } catch (\Exception $e) {
            return false;
        }

        return $xml;
    }
Exemplo n.º 4
0
 public function getPxParams()
 {
     $v = $this->getVersion();
     $extension = "Mandrill;{$v}";
     $mageEdition = $this->_metaData->getEdition();
     switch ($mageEdition) {
         case 'Community':
             $mageEdition = 'CE';
             break;
         case 'Enterprise':
             $mageEdition = 'EE';
             break;
     }
     $mageVersion = $this->_metaData->getVersion();
     $mage = "Magento {$mageEdition};{$mageVersion}";
     $hash = md5($extension . '_' . $mage . '_' . $extension);
     return "ext={$extension}&mage={$mage}&ctrl={$hash}";
 }
Exemplo n.º 5
0
 /**
  * Get the 'Info' section data
  *
  * @return string[]
  */
 protected function getGeneralInfo()
 {
     $versionParts = explode('.', $this->productMetadata->getVersion());
     if (!isset($versionParts[0]) || !isset($versionParts[1])) {
         return [];
         // Major and minor version are not set - return empty response
     }
     $majorMinorVersion = $versionParts[0] . '.' . $versionParts[1];
     return ['version' => $majorMinorVersion, 'title' => $this->productMetadata->getName() . ' ' . $this->productMetadata->getEdition()];
 }
Exemplo n.º 6
0
 public function getPxParams()
 {
     $modules = $this->_loader->load();
     $v = "";
     if (isset($modules['Ebizmarts_MageMonkey'])) {
         $v = $modules['Ebizmarts_MageMonkey']['setup_version'];
     }
     $extension = "MageMonkey;{$v}";
     $mageEdition = $this->_metaData->getEdition();
     switch ($mageEdition) {
         case 'Community':
             $mageEdition = 'CE';
             break;
         case 'Enterprise':
             $mageEdition = 'EE';
             break;
     }
     $mageVersion = $this->_metaData->getVersion();
     $mage = "Magento {$mageEdition};{$mageVersion}";
     $hash = md5($extension . '_' . $mage . '_' . $extension);
     return "ext={$extension}&mage={$mage}&ctrl={$hash}";
 }
 public function getExpectedCommonData()
 {
     $versionParts = explode('.', $this->productMetadata->getVersion());
     if (!isset($versionParts[0]) || !isset($versionParts[1])) {
         return [];
         // Major and minor version are not set - return empty response
     }
     $majorMinorVersion = $versionParts[0] . '.' . $versionParts[1];
     $url = str_replace('://', '', strstr($this->baseUrl, '://'));
     $host = strpos($url, '/') ? strstr($url, '/', true) : $url;
     $basePath = strstr(rtrim($url, '/'), '/');
     $basePath = $basePath ? trim($basePath, '/') . '/' : '';
     $basePath = '/' . $basePath . 'rest/' . $this->storeCode;
     return ['swagger' => '2.0', 'info' => ['version' => $majorMinorVersion, 'title' => $this->productMetadata->getName() . ' ' . $this->productMetadata->getEdition()], 'host' => $host, 'basePath' => $basePath];
 }
 /**
  * Retrieve environment information of magento
  * And installed extensions provided by CedCommerce
  *
  * @return array
  */
 public function getEnvironmentInformation()
 {
     $info = array();
     $info['plateform'] = 'Magento2.x';
     $info['domain_name'] = $this->urlBuilder->getBaseUrl();
     $info['magento_edition'] = 'default';
     if (method_exists('Mage', 'getEdition')) {
         $info['magento_edition'] = $this->productMetadata->getEdition();
     }
     $info['magento_version'] = $this->productMetadata->getVersion();
     $info['php_version'] = phpversion();
     $info['feed_types'] = $this->_backendConfig->getValue(\Ced\DevTool\Model\Feed::XML_FEED_TYPES);
     $info['admin_name'] = $this->_backendConfig->getValue('trans_email/ident_general/name');
     if (strlen($info['admin_name']) == 0) {
         $info['admin_name'] = $this->_backendConfig->getValue('trans_email/ident_sales/name');
     }
     $info['admin_email'] = $this->_backendConfig->getValue('trans_email/ident_general/email');
     if (strlen($info['admin_email']) == 0) {
         $info['admin_email'] = $this->_backendConfig->getValue('trans_email/ident_sales/email');
     }
     $info['installed_extensions_by_cedcommerce'] = $this->getCedCommerceExtensions(true);
     return $info;
 }
Exemplo n.º 9
0
 /**
  * Generate AvaTax Client Name from a combination of Magento version number and AvaTax module version number
  * Format: Magento 2.x Community - AvaTax 1.0.0
  * Limited to 50 characters to comply with API requirements
  *
  * @return string
  */
 protected function getClientName()
 {
     return substr($this->magentoProductMetadata->getName(), 0, 7) . ' ' . substr($this->magentoProductMetadata->getVersion(), 0, 14) . ' ' . substr($this->magentoProductMetadata->getEdition(), 0, 10) . ' - ' . 'AvaTax ' . substr(AvaTaxAppInterface::APP_VERSION, 0, 7);
     // "AvaTax " & 1.x.x - 14 chars
 }
Exemplo n.º 10
0
 /**
  * Format param "channel" for transaction
  *
  * @return string
  */
 protected function getChannel()
 {
     $edition = $this->productMetaData->getEdition();
     $version = $this->productMetaData->getVersion();
     return self::CHANNEL_NAME . ' ' . $edition . ' ' . $version;
 }
Exemplo n.º 11
0
 protected function addVersionInfo()
 {
     $this->infos['Name'] = $this->productMetadata->getName();
     $this->infos['Version'] = $this->productMetadata->getVersion();
     $this->infos['Edition'] = $this->productMetadata->getEdition();
 }
Exemplo n.º 12
0
 /**
  * @inheritdoc
  */
 public function build(array $buildSubject)
 {
     return [self::$channel => sprintf(self::$channelValue, $this->productMetadata->getEdition())];
 }
Exemplo n.º 13
0
 /**
  * Sets the response body with ProductName/Version (Edition). E.g.: Magento/0.42.0-beta3 (Community)
  *
  * @return void
  */
 public function execute()
 {
     $this->getResponse()->setBody($this->productMetadata->getName() . '/' . $this->productMetadata->getVersion() . ' (' . $this->productMetadata->getEdition() . ')');
 }