Skip to content

Commit 7689e4d

Browse files
author
Shkolyarenko, Serhiy(sshkolyarenko)
committed
Merge pull request #299 from magento-folks/checkout
[Folks+South+Troll]Checkou UI rendering
2 parents 9db84b2 + d4ac936 commit 7689e4d

File tree

418 files changed

+14495
-3621
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

418 files changed

+14495
-3621
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ atlassian*
3737
!/pub/media/wysiwyg/.htaccess
3838
/pub/media/tmp/*
3939
!/pub/media/tmp/.htaccess
40+
/pub/media/captcha/*
4041
/pub/static/*
4142
!/pub/static/.htaccess
4243

app/code/Magento/Backend/Block/Context.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ class Context extends \Magento\Framework\View\Element\Context
2424
* @param \Magento\Framework\View\LayoutInterface $layout
2525
* @param \Magento\Framework\Event\ManagerInterface $eventManager
2626
* @param \Magento\Framework\UrlInterface $urlBuilder
27-
* @param \Magento\Framework\TranslateInterface $translator
2827
* @param \Magento\Framework\App\CacheInterface $cache
2928
* @param \Magento\Framework\View\DesignInterface $design
3029
* @param \Magento\Framework\Session\SessionManagerInterface $session
@@ -47,7 +46,6 @@ public function __construct(
4746
\Magento\Framework\View\LayoutInterface $layout,
4847
\Magento\Framework\Event\ManagerInterface $eventManager,
4948
\Magento\Framework\UrlInterface $urlBuilder,
50-
\Magento\Framework\TranslateInterface $translator,
5149
\Magento\Framework\App\CacheInterface $cache,
5250
\Magento\Framework\View\DesignInterface $design,
5351
\Magento\Framework\Session\SessionManagerInterface $session,
@@ -69,7 +67,6 @@ public function __construct(
6967
$layout,
7068
$eventManager,
7169
$urlBuilder,
72-
$translator,
7370
$cache,
7471
$design,
7572
$session,

app/code/Magento/Backend/Block/Template/Context.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ class Context extends \Magento\Framework\View\Element\Template\Context
4848
* @param \Magento\Framework\View\LayoutInterface $layout
4949
* @param \Magento\Framework\Event\ManagerInterface $eventManager
5050
* @param \Magento\Framework\UrlInterface $urlBuilder
51-
* @param \Magento\Framework\TranslateInterface $translator
5251
* @param \Magento\Framework\App\CacheInterface $cache
5352
* @param \Magento\Framework\View\DesignInterface $design
5453
* @param \Magento\Framework\Session\Generic $session
@@ -81,7 +80,6 @@ public function __construct(
8180
\Magento\Framework\View\LayoutInterface $layout,
8281
\Magento\Framework\Event\ManagerInterface $eventManager,
8382
\Magento\Framework\UrlInterface $urlBuilder,
84-
\Magento\Framework\TranslateInterface $translator,
8583
\Magento\Framework\App\CacheInterface $cache,
8684
\Magento\Framework\View\DesignInterface $design,
8785
\Magento\Framework\Session\Generic $session,
@@ -117,7 +115,6 @@ public function __construct(
117115
$layout,
118116
$eventManager,
119117
$urlBuilder,
120-
$translator,
121118
$cache,
122119
$design,
123120
$session,

app/code/Magento/Backend/Block/Widget/Context.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ class Context extends \Magento\Backend\Block\Template\Context
3131
* @param \Magento\Framework\View\LayoutInterface $layout
3232
* @param \Magento\Framework\Event\ManagerInterface $eventManager
3333
* @param \Magento\Framework\UrlInterface $urlBuilder
34-
* @param \Magento\Framework\TranslateInterface $translator
3534
* @param \Magento\Framework\App\CacheInterface $cache
3635
* @param \Magento\Framework\View\DesignInterface $design
3736
* @param \Magento\Framework\Session\Generic $session
@@ -66,7 +65,6 @@ public function __construct(
6665
\Magento\Framework\View\LayoutInterface $layout,
6766
\Magento\Framework\Event\ManagerInterface $eventManager,
6867
\Magento\Framework\UrlInterface $urlBuilder,
69-
\Magento\Framework\TranslateInterface $translator,
7068
\Magento\Framework\App\CacheInterface $cache,
7169
\Magento\Framework\View\DesignInterface $design,
7270
\Magento\Framework\Session\Generic $session,
@@ -99,7 +97,6 @@ public function __construct(
9997
$layout,
10098
$eventManager,
10199
$urlBuilder,
102-
$translator,
103100
$cache,
104101
$design,
105102
$session,

app/code/Magento/Bundle/etc/frontend/di.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,11 @@
99
<type name="Magento\Quote\Model\Quote\Item\ToOrderItem">
1010
<plugin name="append_bundle_data_to_order" type="Magento\Bundle\Model\Plugin\QuoteItem"/>
1111
</type>
12+
<type name="Magento\Catalog\Helper\Product\ConfigurationPool">
13+
<arguments>
14+
<argument name="instancesByType" xsi:type="array">
15+
<item name="bundle" xsi:type="object">Magento\Bundle\Helper\Catalog\Product\Configuration</item>
16+
</argument>
17+
</arguments>
18+
</type>
1219
</config>
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?xml version="1.0"?>
2+
<!--
3+
/**
4+
* Copyright © 2015 Magento. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../lib/internal/Magento/Framework/ObjectManager/etc/config.xsd">
9+
<type name="Magento\Catalog\Helper\Product\ConfigurationPool">
10+
<arguments>
11+
<argument name="instancesByType" xsi:type="array">
12+
<item name="bundle" xsi:type="object">Magento\Bundle\Helper\Catalog\Product\Configuration</item>
13+
</argument>
14+
</arguments>
15+
</type>
16+
</config>
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?xml version="1.0"?>
2+
<!--
3+
/**
4+
* Copyright © 2015 Magento. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../lib/internal/Magento/Framework/ObjectManager/etc/config.xsd">
9+
<type name="Magento\Catalog\Helper\Product\ConfigurationPool">
10+
<arguments>
11+
<argument name="instancesByType" xsi:type="array">
12+
<item name="bundle" xsi:type="object">Magento\Bundle\Helper\Catalog\Product\Configuration</item>
13+
</argument>
14+
</arguments>
15+
</type>
16+
</config>

app/code/Magento/Captcha/Controller/Refresh/Index.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,17 @@ public function __construct(Context $context, \Magento\Captcha\Helper\Data $capt
3333
public function execute()
3434
{
3535
$formId = $this->_request->getPost('formId');
36+
if (null === $formId) {
37+
try {
38+
$params = \Zend_Json::decode($this->_request->getContent());
39+
$formId = isset($params['formId']) ? $params['formId'] : null;
40+
} catch (\Zend_Json_Exception $exception) {
41+
$formId = null;
42+
}
43+
}
3644
$captchaModel = $this->captchaHelper->getCaptcha($formId);
45+
$captchaModel->generate();
46+
3747
$block = $this->_view->getLayout()->createBlock($captchaModel->getBlockName());
3848
$block->setFormId($formId)->setIsAjax(true)->toHtml();
3949
$this->_response->representJson(json_encode(['imgSrc' => $captchaModel->getImgSrc()]));
Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
<?php
2+
/**
3+
* Copyright © 2015 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Captcha\Model\Checkout;
7+
8+
class ConfigProvider implements \Magento\Checkout\Model\ConfigProviderInterface
9+
{
10+
/**
11+
* @var \Magento\Store\Model\StoreManagerInterface
12+
*/
13+
protected $storeManager;
14+
15+
/**
16+
* @var \Magento\Captcha\Helper\Data
17+
*/
18+
protected $captchaData;
19+
20+
/**
21+
* @var array
22+
*/
23+
protected $formIds;
24+
25+
/**
26+
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
27+
* @param \Magento\Captcha\Helper\Data $captchaData
28+
* @param array $formIds
29+
*/
30+
public function __construct(
31+
\Magento\Store\Model\StoreManagerInterface $storeManager,
32+
\Magento\Captcha\Helper\Data $captchaData,
33+
array $formIds
34+
) {
35+
$this->storeManager = $storeManager;
36+
$this->captchaData = $captchaData;
37+
$this->formIds = $formIds;
38+
}
39+
40+
/**
41+
* {@inheritdoc}
42+
*/
43+
public function getConfig()
44+
{
45+
$config = [];
46+
foreach ($this->formIds as $formId) {
47+
$config['captcha'][$formId] = [
48+
'isCaseSensitive' => $this->isCaseSensitive($formId),
49+
'imageHeight' => $this->getImageHeight($formId),
50+
'imageSrc' => $this->getImageSrc($formId),
51+
'refreshUrl' => $this->getRefreshUrl(),
52+
'isRequired' => $this->isRequired($formId)
53+
];
54+
}
55+
return $config;
56+
}
57+
58+
/**
59+
* Returns is captcha case sensitive
60+
*
61+
* @param string $formId
62+
* @return bool
63+
*/
64+
protected function isCaseSensitive($formId)
65+
{
66+
return (boolean)$this->getCaptchaModel($formId)->isCaseSensitive();
67+
}
68+
69+
/**
70+
* Returns captcha image height
71+
*
72+
* @param string $formId
73+
* @return int
74+
*/
75+
protected function getImageHeight($formId)
76+
{
77+
return $this->getCaptchaModel($formId)->getHeight();
78+
}
79+
80+
/**
81+
* Returns captcha image source path
82+
*
83+
* @param string $formId
84+
* @return string
85+
*/
86+
protected function getImageSrc($formId)
87+
{
88+
if ($this->isRequired($formId)) {
89+
$captcha = $this->getCaptchaModel($formId);
90+
$captcha->generate();
91+
return $captcha->getImgSrc();
92+
}
93+
return '';
94+
}
95+
96+
/**
97+
* Returns URL to controller action which returns new captcha image
98+
*
99+
* @return string
100+
*/
101+
protected function getRefreshUrl()
102+
{
103+
$store = $this->storeManager->getStore();
104+
return $store->getUrl('captcha/refresh', ['_secure' => $store->isCurrentlySecure()]);
105+
}
106+
107+
/**
108+
* Whether captcha is required to be inserted to this form
109+
*
110+
* @param string $formId
111+
* @return bool
112+
*/
113+
protected function isRequired($formId)
114+
{
115+
return (boolean)$this->getCaptchaModel($formId)->isRequired();
116+
}
117+
118+
/**
119+
* Return captcha model for specified form
120+
*
121+
* @param string $formId
122+
* @return \Magento\Captcha\Model\ModelInterface
123+
*/
124+
protected function getCaptchaModel($formId)
125+
{
126+
return $this->captchaData->getCaptcha($formId);
127+
}
128+
}
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
<?php
2+
/**
3+
* Copyright © 2015 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Captcha\Model\Checkout\Plugin;
7+
8+
use Magento\Framework\Exception\NoSuchEntityException;
9+
use Magento\Framework\Exception\InputException;
10+
11+
class Validation
12+
{
13+
/**
14+
* @var \Magento\Captcha\Helper\Data
15+
*/
16+
protected $captchaHelper;
17+
18+
/**
19+
* @var array
20+
*/
21+
protected $formIds;
22+
23+
/**
24+
* @param \Magento\Captcha\Helper\Data $captchaHelper
25+
* @param array $formIds
26+
*/
27+
public function __construct(
28+
\Magento\Captcha\Helper\Data $captchaHelper,
29+
array $formIds
30+
) {
31+
$this->captchaHelper = $captchaHelper;
32+
$this->formIds = $formIds;
33+
}
34+
35+
/**
36+
* @param \Magento\Quote\Model\AddressAdditionalDataProcessor $subject
37+
* @param \Magento\Quote\Api\Data\AddressAdditionalDataInterface $additionalData
38+
* @throws \Magento\Framework\Exception\NoSuchEntityException
39+
* @throws \Magento\Framework\Exception\InputException
40+
* @return void
41+
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
42+
*/
43+
public function beforeProcess(
44+
\Magento\Quote\Model\AddressAdditionalDataProcessor $subject,
45+
\Magento\Quote\Api\Data\AddressAdditionalDataInterface $additionalData
46+
) {
47+
$formId = $additionalData->getExtensionAttributes()->getCaptchaFormId();
48+
$captchaText = $additionalData->getExtensionAttributes()->getCaptchaString();
49+
50+
if ($formId !== null && !in_array($formId, $this->formIds)) {
51+
throw new NoSuchEntityException(__('Provided form does not exist'));
52+
}
53+
$captchaModel = $this->captchaHelper->getCaptcha($formId);
54+
if ($captchaModel->isRequired()) {
55+
if (!$captchaModel->isCorrect($captchaText)) {
56+
throw new InputException(__('Incorrect CAPTCHA'));
57+
}
58+
}
59+
}
60+
}

0 commit comments

Comments
 (0)