-
Notifications
You must be signed in to change notification settings - Fork 9.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #299 from magento-folks/checkout
[Folks+South+Troll]Checkou UI rendering
- Loading branch information
Showing
418 changed files
with
14,495 additions
and
3,621 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?xml version="1.0"?> | ||
<!-- | ||
/** | ||
* Copyright © 2015 Magento. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
--> | ||
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../lib/internal/Magento/Framework/ObjectManager/etc/config.xsd"> | ||
<type name="Magento\Catalog\Helper\Product\ConfigurationPool"> | ||
<arguments> | ||
<argument name="instancesByType" xsi:type="array"> | ||
<item name="bundle" xsi:type="object">Magento\Bundle\Helper\Catalog\Product\Configuration</item> | ||
</argument> | ||
</arguments> | ||
</type> | ||
</config> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?xml version="1.0"?> | ||
<!-- | ||
/** | ||
* Copyright © 2015 Magento. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
--> | ||
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../lib/internal/Magento/Framework/ObjectManager/etc/config.xsd"> | ||
<type name="Magento\Catalog\Helper\Product\ConfigurationPool"> | ||
<arguments> | ||
<argument name="instancesByType" xsi:type="array"> | ||
<item name="bundle" xsi:type="object">Magento\Bundle\Helper\Catalog\Product\Configuration</item> | ||
</argument> | ||
</arguments> | ||
</type> | ||
</config> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
128 changes: 128 additions & 0 deletions
128
app/code/Magento/Captcha/Model/Checkout/ConfigProvider.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
<?php | ||
/** | ||
* Copyright © 2015 Magento. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
namespace Magento\Captcha\Model\Checkout; | ||
|
||
class ConfigProvider implements \Magento\Checkout\Model\ConfigProviderInterface | ||
{ | ||
/** | ||
* @var \Magento\Store\Model\StoreManagerInterface | ||
*/ | ||
protected $storeManager; | ||
|
||
/** | ||
* @var \Magento\Captcha\Helper\Data | ||
*/ | ||
protected $captchaData; | ||
|
||
/** | ||
* @var array | ||
*/ | ||
protected $formIds; | ||
|
||
/** | ||
* @param \Magento\Store\Model\StoreManagerInterface $storeManager | ||
* @param \Magento\Captcha\Helper\Data $captchaData | ||
* @param array $formIds | ||
*/ | ||
public function __construct( | ||
\Magento\Store\Model\StoreManagerInterface $storeManager, | ||
\Magento\Captcha\Helper\Data $captchaData, | ||
array $formIds | ||
) { | ||
$this->storeManager = $storeManager; | ||
$this->captchaData = $captchaData; | ||
$this->formIds = $formIds; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function getConfig() | ||
{ | ||
$config = []; | ||
foreach ($this->formIds as $formId) { | ||
$config['captcha'][$formId] = [ | ||
'isCaseSensitive' => $this->isCaseSensitive($formId), | ||
'imageHeight' => $this->getImageHeight($formId), | ||
'imageSrc' => $this->getImageSrc($formId), | ||
'refreshUrl' => $this->getRefreshUrl(), | ||
'isRequired' => $this->isRequired($formId) | ||
]; | ||
} | ||
return $config; | ||
} | ||
|
||
/** | ||
* Returns is captcha case sensitive | ||
* | ||
* @param string $formId | ||
* @return bool | ||
*/ | ||
protected function isCaseSensitive($formId) | ||
{ | ||
return (boolean)$this->getCaptchaModel($formId)->isCaseSensitive(); | ||
} | ||
|
||
/** | ||
* Returns captcha image height | ||
* | ||
* @param string $formId | ||
* @return int | ||
*/ | ||
protected function getImageHeight($formId) | ||
{ | ||
return $this->getCaptchaModel($formId)->getHeight(); | ||
} | ||
|
||
/** | ||
* Returns captcha image source path | ||
* | ||
* @param string $formId | ||
* @return string | ||
*/ | ||
protected function getImageSrc($formId) | ||
{ | ||
if ($this->isRequired($formId)) { | ||
$captcha = $this->getCaptchaModel($formId); | ||
$captcha->generate(); | ||
return $captcha->getImgSrc(); | ||
} | ||
return ''; | ||
} | ||
|
||
/** | ||
* Returns URL to controller action which returns new captcha image | ||
* | ||
* @return string | ||
*/ | ||
protected function getRefreshUrl() | ||
{ | ||
$store = $this->storeManager->getStore(); | ||
return $store->getUrl('captcha/refresh', ['_secure' => $store->isCurrentlySecure()]); | ||
} | ||
|
||
/** | ||
* Whether captcha is required to be inserted to this form | ||
* | ||
* @param string $formId | ||
* @return bool | ||
*/ | ||
protected function isRequired($formId) | ||
{ | ||
return (boolean)$this->getCaptchaModel($formId)->isRequired(); | ||
} | ||
|
||
/** | ||
* Return captcha model for specified form | ||
* | ||
* @param string $formId | ||
* @return \Magento\Captcha\Model\ModelInterface | ||
*/ | ||
protected function getCaptchaModel($formId) | ||
{ | ||
return $this->captchaData->getCaptcha($formId); | ||
} | ||
} |
60 changes: 60 additions & 0 deletions
60
app/code/Magento/Captcha/Model/Checkout/Plugin/Validation.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
<?php | ||
/** | ||
* Copyright © 2015 Magento. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
namespace Magento\Captcha\Model\Checkout\Plugin; | ||
|
||
use Magento\Framework\Exception\NoSuchEntityException; | ||
use Magento\Framework\Exception\InputException; | ||
|
||
class Validation | ||
{ | ||
/** | ||
* @var \Magento\Captcha\Helper\Data | ||
*/ | ||
protected $captchaHelper; | ||
|
||
/** | ||
* @var array | ||
*/ | ||
protected $formIds; | ||
|
||
/** | ||
* @param \Magento\Captcha\Helper\Data $captchaHelper | ||
* @param array $formIds | ||
*/ | ||
public function __construct( | ||
\Magento\Captcha\Helper\Data $captchaHelper, | ||
array $formIds | ||
) { | ||
$this->captchaHelper = $captchaHelper; | ||
$this->formIds = $formIds; | ||
} | ||
|
||
/** | ||
* @param \Magento\Quote\Model\AddressAdditionalDataProcessor $subject | ||
* @param \Magento\Quote\Api\Data\AddressAdditionalDataInterface $additionalData | ||
* @throws \Magento\Framework\Exception\NoSuchEntityException | ||
* @throws \Magento\Framework\Exception\InputException | ||
* @return void | ||
* @SuppressWarnings(PHPMD.UnusedFormalParameter) | ||
*/ | ||
public function beforeProcess( | ||
\Magento\Quote\Model\AddressAdditionalDataProcessor $subject, | ||
\Magento\Quote\Api\Data\AddressAdditionalDataInterface $additionalData | ||
) { | ||
$formId = $additionalData->getExtensionAttributes()->getCaptchaFormId(); | ||
$captchaText = $additionalData->getExtensionAttributes()->getCaptchaString(); | ||
|
||
if ($formId !== null && !in_array($formId, $this->formIds)) { | ||
throw new NoSuchEntityException(__('Provided form does not exist')); | ||
} | ||
$captchaModel = $this->captchaHelper->getCaptcha($formId); | ||
if ($captchaModel->isRequired()) { | ||
if (!$captchaModel->isCorrect($captchaText)) { | ||
throw new InputException(__('Incorrect CAPTCHA')); | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.