Skip to content

Commit 3606447

Browse files
committed
Merge remote-tracking branch 'mainline/develop' into BUGS
2 parents 1cf39d1 + c0fee4d commit 3606447

File tree

266 files changed

+24898
-1035
lines changed

Some content is hidden

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

266 files changed

+24898
-1035
lines changed
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
<?php
2+
/**
3+
* Copyright © 2015 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Braintree\Block\Adminhtml\Form\Field;
7+
8+
class Cctypes extends \Magento\Framework\View\Element\Html\Select
9+
{
10+
/**
11+
* All possible credit card types
12+
*
13+
* @var array
14+
*/
15+
protected $ccTypes = [];
16+
17+
/**
18+
* @var \Magento\Braintree\Model\Source\CcType
19+
*/
20+
protected $ccTypeSource;
21+
22+
/**
23+
* Constructor
24+
*
25+
* @param \Magento\Framework\View\Element\Context $context
26+
* @param \Magento\Braintree\Model\Source\CcType $ccTypeSource
27+
* @param array $data
28+
*/
29+
public function __construct(
30+
\Magento\Framework\View\Element\Context $context,
31+
\Magento\Braintree\Model\Source\CcType $ccTypeSource,
32+
array $data = []
33+
) {
34+
parent::__construct($context, $data);
35+
$this->ccTypeSource = $ccTypeSource;
36+
}
37+
38+
/**
39+
* Render block HTML
40+
*
41+
* @return string
42+
*/
43+
public function _toHtml()
44+
{
45+
if (!$this->getOptions()) {
46+
foreach ($this->_getCcTypes() as $country) {
47+
if (isset($country['value']) && $country['value'] && isset($country['label']) && $country['label']) {
48+
$this->addOption($country['value'], $country['label']);
49+
}
50+
}
51+
}
52+
$this->setExtraParams('multiple="multiple" style="height:80px;"');
53+
return parent::_toHtml();
54+
}
55+
56+
/**
57+
* All possible credit card types
58+
*
59+
* @return array
60+
*/
61+
protected function _getCcTypes()
62+
{
63+
if (!$this->ccTypes) {
64+
$this->ccTypes = $this->ccTypeSource->toOptionArray();
65+
}
66+
return $this->ccTypes;
67+
}
68+
69+
/**
70+
* Sets name for input element
71+
*
72+
* @param string $value
73+
* @return $this
74+
*/
75+
public function setInputName($value)
76+
{
77+
return $this->setName($value . '[]');
78+
}
79+
}
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
<?php
2+
/**
3+
* Copyright © 2015 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Braintree\Block\Adminhtml\Form\Field;
7+
8+
class Countries extends \Magento\Framework\View\Element\Html\Select
9+
{
10+
/**
11+
* Countries cache
12+
*
13+
* @var array
14+
*/
15+
protected $countries;
16+
17+
/**
18+
* @var \Magento\Braintree\Model\System\Config\Source\Country
19+
*/
20+
protected $countrySource;
21+
22+
/**
23+
* @var \Magento\Directory\Model\Resource\Country\CollectionFactory
24+
*/
25+
protected $countryCollectionFactory;
26+
27+
/**
28+
* Constructor
29+
*
30+
* @param \Magento\Framework\View\Element\Context $context
31+
* @param \Magento\Braintree\Model\System\Config\Source\Country $countrySource
32+
* @param \Magento\Directory\Model\Resource\Country\CollectionFactory $countryCollectionFactory
33+
* @param array $data
34+
*/
35+
public function __construct(
36+
\Magento\Framework\View\Element\Context $context,
37+
\Magento\Braintree\Model\System\Config\Source\Country $countrySource,
38+
\Magento\Directory\Model\Resource\Country\CollectionFactory $countryCollectionFactory,
39+
array $data = []
40+
) {
41+
parent::__construct($context, $data);
42+
$this->countrySource = $countrySource;
43+
$this->countryCollectionFactory = $countryCollectionFactory;
44+
}
45+
46+
/**
47+
* Returns countries array
48+
*
49+
* @return array
50+
*/
51+
protected function _getCountries()
52+
{
53+
if (!$this->countries) {
54+
$restrictedCountries = $this->countrySource->getRestrictedCountries();
55+
$this->countries = $this->countryCollectionFactory->create()
56+
->addFieldToFilter('country_id', ['nin' => $restrictedCountries])
57+
->loadData()
58+
->toOptionArray(false);
59+
}
60+
return $this->countries;
61+
}
62+
63+
/**
64+
* Render block HTML
65+
*
66+
* @return string
67+
*/
68+
public function _toHtml()
69+
{
70+
if (!$this->getOptions()) {
71+
foreach ($this->_getCountries() as $country) {
72+
if (isset($country['value']) && $country['value'] && isset($country['label']) && $country['label']) {
73+
$this->addOption($country['value'], $country['label']);
74+
}
75+
}
76+
}
77+
return parent::_toHtml();
78+
}
79+
80+
/**
81+
* Sets name for input element
82+
*
83+
* @param string $value
84+
* @return $this
85+
*/
86+
public function setInputName($value)
87+
{
88+
return $this->setName($value);
89+
}
90+
}
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
<?php
2+
/**
3+
* Copyright © 2015 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Braintree\Block\Adminhtml\Form\Field;
7+
8+
class Countrycreditcard extends \Magento\Config\Block\System\Config\Form\Field\FieldArray\AbstractFieldArray
9+
{
10+
/**
11+
* @var \Magento\Braintree\Block\Adminhtml\Form\Field\Countries
12+
*/
13+
protected $countryRenderer = null;
14+
15+
/**
16+
* @var \Magento\Braintree\Block\Adminhtml\Form\Field\CcTypes
17+
*/
18+
protected $ccTypesRenderer = null;
19+
20+
/**
21+
* Returns renderer for country element
22+
*
23+
* @return \Magento\Braintree\Block\Adminhtml\Form\Field\Countries
24+
*/
25+
protected function getCountryRenderer()
26+
{
27+
if (!$this->countryRenderer) {
28+
$this->countryRenderer = $this->getLayout()->createBlock(
29+
'\Magento\Braintree\Block\Adminhtml\Form\Field\Countries',
30+
'',
31+
['data' => ['is_render_to_js_template' => true]]
32+
);
33+
}
34+
return $this->countryRenderer;
35+
}
36+
37+
/**
38+
* Returns renderer for country element
39+
*
40+
* @return \Magento\Braintree\Block\Adminhtml\Form\Field\Cctypes
41+
*/
42+
protected function getCcTypesRenderer()
43+
{
44+
if (!$this->ccTypesRenderer) {
45+
$this->ccTypesRenderer = $this->getLayout()->createBlock(
46+
'\Magento\Braintree\Block\Adminhtml\Form\Field\Cctypes',
47+
'',
48+
['data' => ['is_render_to_js_template' => true]]
49+
);
50+
}
51+
return $this->ccTypesRenderer;
52+
}
53+
54+
/**
55+
* Prepare to render
56+
* @return void
57+
*/
58+
protected function _prepareToRender()
59+
{
60+
$this->addColumn(
61+
'country_id',
62+
[
63+
'label' => __('Country'),
64+
'renderer' => $this->getCountryRenderer(),
65+
]
66+
);
67+
$this->addColumn(
68+
'cc_types',
69+
[
70+
'label' => __('Allowed Credit Card Types'),
71+
'renderer' => $this->getCcTypesRenderer(),
72+
]
73+
);
74+
$this->_addAfter = false;
75+
$this->_addButtonLabel = __('Add Rule');
76+
}
77+
78+
/**
79+
* Prepare existing row data object
80+
*
81+
* @param \Magento\Framework\Object $row
82+
* @return void
83+
*/
84+
protected function _prepareArrayRow(\Magento\Framework\Object $row)
85+
{
86+
$country = $row->getCountryId();
87+
$options = [];
88+
if ($country) {
89+
$options['option_' . $this->getCountryRenderer()->calcOptionHash($country)]
90+
= 'selected="selected"';
91+
92+
$ccTypes = $row->getCcTypes();
93+
if (!is_array($ccTypes)) {
94+
$ccTypes = [$ccTypes];
95+
}
96+
foreach ($ccTypes as $cardType) {
97+
$options['option_' . $this->getCcTypesRenderer()->calcOptionHash($cardType)]
98+
= 'selected="selected"';
99+
}
100+
}
101+
$row->setData('option_extra_attrs', $options);
102+
return;
103+
}
104+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
/**
3+
* Copyright © 2015 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Braintree\Block\Checkout;
8+
9+
/**
10+
* Braintree PayPal shortcut checkout block
11+
*
12+
* @author Magento Core Team <[email protected]>
13+
*/
14+
class Review extends \Magento\Paypal\Block\Express\Review
15+
{
16+
/**
17+
* Controller path
18+
*
19+
* @var string
20+
*/
21+
protected $_controllerPath = 'braintree/paypal';
22+
23+
/**
24+
* Does not allow editing payment information as customer has gone through paypal flow already
25+
*
26+
* @return null
27+
* @codeCoverageIgnore
28+
*/
29+
public function getEditUrl()
30+
{
31+
return null;
32+
}
33+
}

0 commit comments

Comments
 (0)