示例#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);
    }
示例#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() . ')');
 }
 /**
  * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
  */
 protected function setUp()
 {
     $this->contextMock = $this->getMockBuilder('\\Magento\\Framework\\Model\\Context')->disableOriginalConstructor()->getMock();
     $this->configMock = $this->getMockBuilder('\\Magento\\Braintree\\Model\\Config\\Cc')->disableOriginalConstructor()->getMock();
     $this->vaultMock = $this->getMockBuilder('\\Magento\\Braintree\\Model\\Vault')->disableOriginalConstructor()->getMock();
     $this->registryMock = $this->getMockBuilder('\\Magento\\Framework\\Registry')->disableOriginalConstructor()->getMock();
     $this->salesTransactionCollectionFactoryMock = $this->getMockBuilder('\\Magento\\Sales\\Model\\ResourceModel\\Order\\Payment\\Transaction\\CollectionFactory')->disableOriginalConstructor()->setMethods(['create'])->getMock();
     $this->productMetaDataMock = $this->getMockBuilder('\\Magento\\Framework\\App\\ProductMetadataInterface')->disableOriginalConstructor()->getMock();
     $this->helperMock = $this->getMockBuilder('\\Magento\\Braintree\\Helper\\Data')->disableOriginalConstructor()->getMock();
     $this->errorHelperMock = $this->getMockBuilder('\\Magento\\Braintree\\Helper\\Error')->disableOriginalConstructor()->getMock();
     $this->regionFactoryMock = $this->getMockBuilder('\\Magento\\Directory\\Model\\RegionFactory')->disableOriginalConstructor()->getMock();
     $this->loggerMock = $this->getMockBuilder('\\Magento\\Payment\\Model\\Method\\Logger')->disableOriginalConstructor()->getMock();
     $this->braintreeTransactionMock = $this->getMockBuilder('\\Magento\\Braintree\\Model\\Adapter\\BraintreeTransaction')->getMock();
     $this->braintreeCreditCardMock = $this->getMockBuilder('\\Magento\\Braintree\\Model\\Adapter\\BraintreeCreditCard')->getMock();
     $this->appStateMock = $this->getMockBuilder('\\Magento\\Framework\\App\\State')->disableOriginalConstructor()->getMock();
     $this->psrLoggerMock = $this->getMock('\\Psr\\Log\\LoggerInterface');
     $this->contextMock->expects($this->any())->method('getLogger')->willReturn($this->psrLoggerMock);
     $this->contextMock->expects($this->any())->method('getAppState')->willReturn($this->appStateMock);
     $this->orderRepository = $this->getMockBuilder('Magento\\Sales\\Api\\OrderRepositoryInterface')->getMockForAbstractClass();
     $this->objectManagerHelper = new ObjectManagerHelper($this);
     $this->model = $this->objectManagerHelper->getObject('Magento\\Braintree\\Model\\PaymentMethod', ['context' => $this->contextMock, 'config' => $this->configMock, 'vault' => $this->vaultMock, 'registry' => $this->registryMock, 'salesTransactionCollectionFactory' => $this->salesTransactionCollectionFactoryMock, 'productMetaData' => $this->productMetaDataMock, 'braintreeHelper' => $this->helperMock, 'errorHelper' => $this->errorHelperMock, 'regionFactory' => $this->regionFactoryMock, 'logger' => $this->loggerMock, 'braintreeTransaction' => $this->braintreeTransactionMock, 'braintreeCreditCard' => $this->braintreeCreditCardMock, 'orderRepository' => $this->orderRepository]);
     $this->infoInstanceMock = $this->getMockForAbstractClass('\\Magento\\Payment\\Model\\InfoInterface', [], '', false, false, false, ['setCcType', 'setCcOwner', 'setCcLast4', 'setCcNumber', 'setCcCid', 'setCcExpMonth', 'setCcExpYear', 'setCcSsIssue', 'setCcSsStartMonth', 'setCcSsStartYear', 'getOrder', 'getQuote', 'getCcType']);
     $this->productMetaDataMock->expects($this->any())->method('getEdition')->willReturn('Community Edition');
     $this->productMetaDataMock->expects($this->any())->method('getVersion')->willReturn('2.0');
 }
示例#4
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;
    }
 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}";
 }
示例#6
0
 /**
  * Returns the version number of the platform the e-commerce installation
  *
  * @return string the platforms's version
  */
 public function getPlatformVersion()
 {
     $version = 'unknown';
     if ($this->_productMetaData->getVersion()) {
         $version = $this->_productMetaData->getVersion();
     } elseif (defined(AppInterface::VERSION)) {
         $version = AppInterface::VERSION;
     }
     return $version;
 }
示例#7
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()];
 }
示例#8
0
 /**
  * create an order in ComproPago
  *
  * @return array
  */
 private function createOrder()
 {
     $order = $this->checSession->getLastRealOrder();
     $dataorder = new PlaceOrderInfo($order->getRealOrderId(), $order->getRealOrderId(), $order->getData('total_due'), $order->getCustomerFirstname() . " " . $order->getCustomerLastname(), $order->getCustomerEmail(), $_COOKIE['provider'], null, 'magento2', $this->metada->getVersion());
     if (isset($_COOKIE['payment_method']) && $_COOKIE['payment_method'] == 'compropago') {
         try {
             $client = new Client($this->instance->getPublicKey(), $this->instance->getPrivateKey(), $this->instance->getLiveMode());
             $response = $client->api->placeOrder($dataorder);
             $_COOKIE['provider'] = null;
             $_COOKIE['payment_method'] = null;
             unset($_COOKIE['provider']);
             unset($_COOKIE['payment_method']);
             return ["type" => "success", "value" => base64_encode($response->getId())];
         } catch (\Exception $e) {
             return ["type" => "error", "value" => $e->getMessage()];
         }
     } else {
         return ["type" => "error", "value" => "Metodo no reconocido"];
     }
 }
示例#9
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;
 }
 /**
  * @param string $edition
  * @param array $expected
  * @covers \Magento\Braintree\Gateway\Request\ChannelDataBuilder::build
  * @dataProvider buildDataProvider
  */
 public function testBuild($edition, array $expected)
 {
     $buildSubject = [];
     $this->productMetadataMock->expects(static::once())->method('getEdition')->willReturn($edition);
     $this->assertEquals($expected, $this->builder->build($buildSubject));
 }
示例#13
0
 /**
  * Get product version
  *
  * @return string
  */
 public function getMagentoVersion()
 {
     return $this->productMetadata->getVersion();
 }
示例#14
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
 }
示例#15
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;
 }
示例#16
0
 protected function addVersionInfo()
 {
     $this->infos['Name'] = $this->productMetadata->getName();
     $this->infos['Version'] = $this->productMetadata->getVersion();
     $this->infos['Edition'] = $this->productMetadata->getEdition();
 }
示例#17
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() . ')');
 }
 /**
  * @inheritdoc
  */
 public function build(array $buildSubject)
 {
     return [self::$channel => sprintf(self::$channelValue, $this->productMetadata->getEdition())];
 }