Skip to content

Commit

Permalink
Merge pull request #318 from magento-ogre/MAGETWO-37728-lost-option-i…
Browse files Browse the repository at this point in the history
…n-generator

[Ogres] Two bug-fixes + [Folks] bug-fixes
  • Loading branch information
Kopylova,Olga(okopylova) committed May 22, 2015
2 parents aaa8291 + fc7ed09 commit 7b3a73a
Show file tree
Hide file tree
Showing 17 changed files with 151 additions and 104 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,9 @@ define(
this.source.set('params.invalid', false);
fields.trigger('change');
this.source.trigger('billingAddress.data.validate');
if (!customer.isLoggedIn()()) {
this.source.trigger('customerDetails.data.validate');
}
this.validateAdditionalAddressFields();
},
validateAdditionalAddressFields: function() {
Expand Down
11 changes: 11 additions & 0 deletions app/code/Magento/Customer/Block/CustomerData.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,15 @@ public function getCookieLifeTime()
\Magento\Store\Model\ScopeInterface::SCOPE_STORE
);
}

/**
* Get url for customer data ajax requests. Returns url with protocol matching used to request page.
*
* @param string $route
* @return string Customer data url.
*/
public function getCustomerDataUrl($route)
{
return $this->getUrl($route, ['_secure' => $this->getRequest()->isSecure()]);
}
}
3 changes: 3 additions & 0 deletions app/code/Magento/Customer/etc/frontend/di.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
<argument name="secureUrlList" xsi:type="array">
<item name="customer" xsi:type="string">/customer/</item>
</argument>
<argument name="excludedUrlList" xsi:type="array">
<item name="customer_sections" xsi:type="string">/customer/section/load</item>
</argument>
</arguments>
</type>
<type name="Magento\Framework\View\Layout">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<?php
echo $this->helper('Magento\Framework\Json\Helper\Data')->jsonEncode([
'*' => ['Magento_Customer/js/customer-data' => [
'sectionLoadUrl' => $block->getUrl('customer/section/load'),
'sectionLoadUrl' => $block->getCustomerDataUrl('customer/section/load'),
'cookieLifeTime' => $block->getCookieLifeTime(),
]],
]);
Expand Down
49 changes: 23 additions & 26 deletions app/code/Magento/Developer/Console/Command/XmlConverterCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Magento\Developer\Model\Tools\Formatter;
use Magento\Framework\DomDocument\DomDocumentFactory;
use Magento\Framework\XsltProcessor\XsltProcessorFactory;

/**
* Class XmlConverterCommand
Expand Down Expand Up @@ -40,39 +42,30 @@ class XmlConverterCommand extends Command
private $formatter;

/**
* @var \DOMDocument
* @var DomDocumentFactory
*/
private $domXml;
private $domFactory;

/**
* @var \DOMDocument
* @var XsltProcessorFactory
*/
private $domXsl;

/**
* @var \XSLTProcessor
*/
private $xsltProcessor;
private $xsltProcessorFactory;

/**
* Inject dependencies
*
* @param Formatter $formatter
* @param \DOMDocument $domXml
* @param \DOMDocument $domXsl
* @param \XSLTProcessor $xsltProcessor
* @SuppressWarnings(Magento.TypeDuplication)
* @param DomDocumentFactory $domFactory
* @param XsltProcessorFactory $xsltProcessorFactory
*/
public function __construct(
Formatter $formatter,
\DOMDocument $domXml,
\DOMDocument $domXsl,
\XSLTProcessor $xsltProcessor
DomDocumentFactory $domFactory,
XsltProcessorFactory $xsltProcessorFactory
) {
$this->formatter = $formatter;
$this->domXml = $domXml;
$this->domXsl = $domXsl;
$this->xsltProcessor = $xsltProcessor;
$this->domFactory = $domFactory;
$this->xsltProcessorFactory = $xsltProcessorFactory;

parent::__construct();
}
Expand Down Expand Up @@ -113,16 +106,20 @@ protected function configure()
protected function execute(InputInterface $input, OutputInterface $output)
{
try {
$domXml = $this->domFactory->create();
$domXsl = $this->domFactory->create();
$xsltProcessor = $this->xsltProcessorFactory->create();

$xmlFile = $input->getArgument(self::XML_FILE_ARGUMENT);
$this->domXml->preserveWhiteSpace = true;
$this->domXml->load($xmlFile);
$domXml->preserveWhiteSpace = true;
$domXml->load($xmlFile);

$this->domXsl->preserveWhiteSpace = true;
$this->domXsl->load($input->getArgument(self::PROCESSOR_ARGUMENT));
$domXsl->preserveWhiteSpace = true;
$domXsl->load($input->getArgument(self::PROCESSOR_ARGUMENT));

$this->xsltProcessor->registerPHPFunctions();
$this->xsltProcessor->importStylesheet($this->domXsl);
$transformedDoc = $this->xsltProcessor->transformToXml($this->domXml);
$xsltProcessor->registerPHPFunctions();
$xsltProcessor->importStylesheet($domXsl);
$transformedDoc = $xsltProcessor->transformToXml($domXml);
$result = $this->formatter->format($transformedDoc);

if ($input->getOption(self::OVERWRITE_OPTION)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
use Magento\Developer\Console\Command\XmlConverterCommand;
use Symfony\Component\Console\Tester\CommandTester;
use Magento\Developer\Model\Tools\Formatter;
use Magento\Framework\DomDocument\DomDocumentFactory;
use Magento\Framework\XsltProcessor\XsltProcessorFactory;

class XmlConverterCommandTest extends \PHPUnit_Framework_TestCase
{
Expand All @@ -23,35 +25,44 @@ class XmlConverterCommandTest extends \PHPUnit_Framework_TestCase
private $command;

/**
* @var \DOMDocument|\PHPUnit_Framework_MockObject_MockObject
* @var DomDocumentFactory|\PHPUnit_Framework_MockObject_MockObject
*/
private $domXml;
private $domFactory;

/**
* @var \DOMDocument|\PHPUnit_Framework_MockObject_MockObject
* @var XsltProcessorFactory|\PHPUnit_Framework_MockObject_MockObject
*/
private $domXsl;

/**
* @var \XSLTProcessor|\PHPUnit_Framework_MockObject_MockObject
*/
private $xsltProcessor;
private $xsltProcessorFactory;

public function setUp()
{
$this->formatter = $this->getMock('Magento\Developer\Model\Tools\Formatter', [], [], '', false);
$this->domXml = $this->getMock('DOMDocument', [], [], '', false);
$this->domXsl = $this->getMock('DOMDocument', [], [], '', false);
$this->xsltProcessor = $this->getMock('XSLTProcessor', [], [], '', false);
$this->command = new XmlConverterCommand($this->formatter, $this->domXml, $this->domXsl, $this->xsltProcessor);
$this->domFactory = $this->getMock('Magento\Framework\DomDocument\DomDocumentFactory', [], [], '', false);
$this->xsltProcessorFactory = $this->getMock(
'Magento\Framework\XsltProcessor\XsltProcessorFactory',
[],
[],
'',
false
);

$this->command = new XmlConverterCommand($this->formatter, $this->domFactory, $this->xsltProcessorFactory);
}

public function testExecute()
{
$this->domXml->expects($this->once())->method('load')->with('file.xml');
$this->domXsl->expects($this->once())->method('load')->with('file.xsl');
$domXml = $this->getMock('DOMDocument', [], [], '', false);
$domXsl = clone $domXml;
$domXml->expects($this->once())->method('load')->with('file.xml');
$domXsl->expects($this->once())->method('load')->with('file.xsl');

$this->domFactory->expects($this->at(0))->method('create')->willReturn($domXml);
$this->domFactory->expects($this->at(1))->method('create')->willReturn($domXsl);

$xsltProcessor = $this->getMock('XSLTProcessor', [], [], '', false);
$xsltProcessor->expects($this->once())->method('transformToXml')->with($domXml)->willReturn('XML');

$this->xsltProcessor->expects($this->once())->method('transformToXml')->with($this->domXml)->willReturn('XML');
$this->xsltProcessorFactory->expects($this->once())->method('create')->willReturn($xsltProcessor);

$this->formatter->expects($this->once())->method('format')->with('XML')->willReturn('result');

Expand Down
6 changes: 0 additions & 6 deletions app/code/Magento/Developer/etc/di.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,4 @@
</argument>
</arguments>
</type>
<type name="Magento\Developer\Console\Command\XmlConverterCommand">
<arguments>
<argument name="domXml" xsi:type="object" shared="false">DOMDocument</argument>
<argument name="domXsl" xsi:type="object" shared="false">DOMDocument</argument>
</arguments>
</type>
</config>
8 changes: 0 additions & 8 deletions app/code/Magento/Webapi/Model/Soap/Server.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,6 @@ class Server
*/
protected $_configScope;

/**
* @var \Magento\Framework\DomDocument\Factory
*/
protected $_domDocumentFactory;

/**
* @var \Magento\Webapi\Controller\Soap\Request
*/
Expand Down Expand Up @@ -67,7 +62,6 @@ class Server
* @param \Magento\Framework\App\AreaList $areaList
* @param \Magento\Framework\Config\ScopeInterface $configScope
* @param \Magento\Webapi\Controller\Soap\Request $request
* @param \Magento\Framework\DomDocument\Factory $domDocumentFactory
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
* @param \Magento\Webapi\Model\Soap\ServerFactory $soapServerFactory
* @param \Magento\Framework\Reflection\TypeProcessor $typeProcessor
Expand All @@ -78,7 +72,6 @@ public function __construct(
\Magento\Framework\App\AreaList $areaList,
\Magento\Framework\Config\ScopeInterface $configScope,
\Magento\Webapi\Controller\Soap\Request $request,
\Magento\Framework\DomDocument\Factory $domDocumentFactory,
\Magento\Store\Model\StoreManagerInterface $storeManager,
\Magento\Webapi\Model\Soap\ServerFactory $soapServerFactory,
\Magento\Framework\Reflection\TypeProcessor $typeProcessor,
Expand All @@ -94,7 +87,6 @@ public function __construct(
$this->_areaList = $areaList;
$this->_configScope = $configScope;
$this->_request = $request;
$this->_domDocumentFactory = $domDocumentFactory;
$this->_storeManager = $storeManager;
$this->_soapServerFactory = $soapServerFactory;
$this->_typeProcessor = $typeProcessor;
Expand Down
8 changes: 0 additions & 8 deletions app/code/Magento/Webapi/Test/Unit/Model/Soap/ServerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@ class ServerTest extends \PHPUnit_Framework_TestCase
/** @var \Magento\Webapi\Controller\Soap\Request */
protected $_requestMock;

/** @var \Magento\Framework\DomDocument\Factory */
protected $_domDocumentFactory;

/** @var \Magento\Store\Model\StoreManagerInterface */
protected $_storeManagerMock;

Expand Down Expand Up @@ -67,10 +64,6 @@ protected function setUp()
'Magento\Webapi\Controller\Soap\Request'
)->disableOriginalConstructor()->getMock();

$this->_domDocumentFactory = $this->getMockBuilder(
'Magento\Framework\DomDocument\Factory'
)->disableOriginalConstructor()->getMock();

$this->_soapServerFactory = $this->getMockBuilder(
'Magento\Webapi\Model\Soap\ServerFactory'
)->disableOriginalConstructor()->getMock();
Expand All @@ -90,7 +83,6 @@ protected function setUp()
$areaListMock,
$configScopeMock,
$this->_requestMock,
$this->_domDocumentFactory,
$this->_storeManagerMock,
$this->_soapServerFactory,
$this->_typeProcessor,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,5 @@ lib/internal/Magento/Framework/App/Utility
lib/internal/Magento/Framework/Url
lib/internal/Magento/Framework/UrlInterface
lib/internal/Magento/Framework/Xml
lib/internal/Magento/Framework/XsltProcessor
lib/internal/Magento/Framework
22 changes: 22 additions & 0 deletions lib/internal/Magento/Framework/DomDocument/DomDocumentFactory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php
/**
* Copyright © 2015 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Framework\DomDocument;

/**
* DOM document factory
*/
class DomDocumentFactory
{
/**
* Create empty DOM document instance.
*
* @return \DOMDocument
*/
public function create()
{
return new \DOMDocument();
}
}
35 changes: 0 additions & 35 deletions lib/internal/Magento/Framework/DomDocument/Factory.php

This file was deleted.

14 changes: 13 additions & 1 deletion lib/internal/Magento/Framework/Url/SecurityInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ class SecurityInfo implements \Magento\Framework\Url\SecurityInfoInterface
*/
protected $secureUrlsList = [];

/**
* List of patterns excluded form secure url list
*/
protected $excludedUrlsList = [];

/**
* List of already checked urls
*
Expand All @@ -25,10 +30,12 @@ class SecurityInfo implements \Magento\Framework\Url\SecurityInfoInterface

/**
* @param string[] $secureUrlList
* @param string[] $excludedUrlList
*/
public function __construct($secureUrlList = [])
public function __construct($secureUrlList = [], $excludedUrlList = [])
{
$this->secureUrlsList = $secureUrlList;
$this->excludedUrlsList = $excludedUrlList;
}

/**
Expand All @@ -41,6 +48,11 @@ public function isSecure($url)
{
if (!isset($this->secureUrlsCache[$url])) {
$this->secureUrlsCache[$url] = false;
foreach ($this->excludedUrlsList as $match) {
if (strpos($url, (string)$match) === 0) {
return $this->secureUrlsCache[$url];
}
}
foreach ($this->secureUrlsList as $match) {
if (strpos($url, (string)$match) === 0) {
$this->secureUrlsCache[$url] = true;
Expand Down
Loading

0 comments on commit 7b3a73a

Please sign in to comment.