Skip to content

Commit

Permalink
Extension Update
Browse files Browse the repository at this point in the history
  • Loading branch information
nealz committed Apr 20, 2018
1 parent 038a471 commit 615b111
Show file tree
Hide file tree
Showing 12 changed files with 134 additions and 607 deletions.
11 changes: 7 additions & 4 deletions Block/Checkout/LayoutOSCProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class LayoutOSCProcessor extends AbstractBlock implements LayoutProcessorInterfa
/**
* @var \Wezz\Postcode\Helper\Config
*/
protected $helperConfig;
private $helperConfig;

/**
* LayoutProcessor constructor.
Expand Down Expand Up @@ -122,14 +122,17 @@ public function getBillingFormFields($result)
$paymentMethodCode = str_replace('-form', '', $paymentMethodForm);

if (!isset($result['components']['checkout']['children']['paymentMethod']['children']
['billingAddress']['children']['billing-address-fieldset']['children'][$paymentMethodCode . '-form'])) {
['billingAddress']['children']['billing-address-fieldset']['children']
[$paymentMethodCode . '-form'])) {
continue;
}

$billingFields = $result['components']['checkout']['children']['paymentMethod']['children']
['billingAddress']['children']['billing-address-fieldset']['children'][$paymentMethodCode . '-form']['children']['form-fields']['children'];
['billingAddress']['children']['billing-address-fieldset']['children']
[$paymentMethodCode . '-form']['children']['form-fields']['children'];

$billingFields['postcode_fieldset'] = $this->getFieldArray('billingAddress' . $paymentMethodCode, 'billing');
$billingFields['postcode_fieldset'] =
$this->getFieldArray('billingAddress' . $paymentMethodCode, 'billing');

$result['components']['checkout']['children']['paymentMethod']['children']
['billingAddress']['children']['billing-address-fieldset']['children'][$paymentMethodCode . '-form']
Expand Down
33 changes: 23 additions & 10 deletions Block/Checkout/LayoutProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,27 @@ class LayoutProcessor extends AbstractBlock implements LayoutProcessorInterface
/**
* @var \Wezz\Postcode\Helper\Config
*/
protected $helperConfig;
private $helperConfig;

/**
* @var \Wezz\Postcode\Model\Api\ClientApi
*/
private $clientApi;

/**
* LayoutProcessor constructor.
* @param \Magento\Framework\View\Element\Template\Context $context
* @param \Wezz\Postcode\Model\Api\ClientApi $clientApi,
* @param array $data
*/
public function __construct(
\Wezz\Postcode\Helper\Config $helperConfig,
\Magento\Framework\View\Element\Template\Context $context,
\Wezz\Postcode\Model\Api\ClientApi $clientApi,
array $data = []
) {
$this->helperConfig = $helperConfig;
$this->clientApi = $clientApi;
parent::__construct($context, $data);
}

Expand All @@ -48,10 +56,17 @@ private function checkPostcode($result)
['children']
['shippingAddress']
['children']
['shipping-address-fieldset']
)
['shipping-address-fieldset'])
) {
return true;

$testConnection = $this->clientApi->testConnection();

if (isset($testConnection['status']) && $testConnection['status'] == 'success') {
return true;
}

return false;

} else {
return false;
}
Expand All @@ -71,16 +86,15 @@ public function process($result)
['shipping-step']['children']['shippingAddress']['children']
['shipping-address-fieldset']['children'];

$shippingFields['postcode_fieldset'] = $this->getFieldArray('shippingAddress', 'shipping');
$shippingFields['postcode_fieldset'] =
$this->getFieldArray('shippingAddress', 'shipping');

$shippingFields = $this->changeFieldPosition($shippingFields);

$result['components']['checkout']['children']['steps']['children']
['shipping-step']['children']['shippingAddress']['children']
['shipping-address-fieldset']['children'] = $shippingFields;



$result = $this->getBillingFormFields($result);

return $result;
Expand All @@ -94,7 +108,6 @@ public function process($result)
*/
public function changeFieldPosition($addressFields)
{

if (isset($addressFields['street'])) {
$addressFields['street']['sortOrder'] = '910';
}
Expand Down Expand Up @@ -171,11 +184,11 @@ public function getBillingFormFields($result)
['billing-step']['children']['payment']['children']
['payments-list']['children'][$paymentMethodCode . '-form']['children']['form-fields']['children'];

$billingFields['postcode_fieldset'] = $this->getFieldArray('billingAddress' . $paymentMethodCode, 'billing');
$billingFields['postcode_fieldset'] = $this->getFieldArray('billingAddress' .
$paymentMethodCode, 'billing');

$billingFields = $this->changeFieldPosition($billingFields);


$result['components']['checkout']['children']['steps']['children']['billing-step']
['children']['payment']['children']['payments-list']['children'][$paymentMethodCode . '-form']
['children']['form-fields']['children'] = $billingFields;
Expand Down
28 changes: 15 additions & 13 deletions Helper/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,26 @@

namespace Wezz\Postcode\Helper;

use Magento\Framework\App\Helper\AbstractHelper;

/**
* Class Data
* @package Wezz\Postcode\Helper
*/
class Config extends AbstractHelper
class Config
{
/**
* @var \Magento\Framework\App\Config\ScopeConfigInterface
*/
protected $scopeConfig;
private $scopeConfig;

/**
* @var string
*/
protected $scopeStore;
private $scopeStore = \Magento\Store\Model\ScopeInterface::SCOPE_STORE;

/**
* @var \Magento\Developer\Helper\Data
*/
protected $developerHelper;
private $developerHelper;

/**
* Config constructor.
Expand All @@ -35,7 +33,6 @@ public function __construct(
\Magento\Developer\Helper\Data $developerHelper
) {
$this->scopeConfig = $scopeConfig;
$this->scopeStore = \Magento\Store\Model\ScopeInterface::SCOPE_STORE;
$this->developerHelper = $developerHelper;
}

Expand Down Expand Up @@ -130,14 +127,13 @@ public function getAdminValidationEnabled()
/**
* Get api_showcase configuration
*
* Not used now;
*
* @return mixed
*/
public function getApiShowcase()
{
return $this->scopeConfig->getValue(
'postcodenl_api/development_config/api_showcase',
$this->scopeStore
);
return false;
}

/**
Expand Down Expand Up @@ -197,7 +193,10 @@ public function getSettingsSet()
'countryCode' => 'NL',
'translations' => [
'defaultError' => __('Unknown postcode + housenumber combination.'),
'fillOut' => __('<h3>Address validation</h3>Fill out your postcode and housenumber to auto-complete your address.'),
'fillOut' => __(
'<h3>Address validation</h3>
Fill out your postcode and housenumber to auto-complete your address.'
),
'select' => __('Select...'),
'validatedAddress' => __('Validated address'),
'yourAddress' => __('Your address:')
Expand Down Expand Up @@ -242,7 +241,10 @@ public function checkBasicApiSettings()
$result = [];

if (!$this->getApiUrl() || !$this->getApiKey() || !$this->getApiSecret()) {
$result = ['message' => __('Postcode.nl API not configured.'), 'info' => [__('Configure your `API key` and `API secret`.')]];
$result = [
'message' => __('Postcode.nl API not configured.'),
'info' => [__('Configure your `API key` and `API secret`.')]
];
}

return $result;
Expand Down
21 changes: 13 additions & 8 deletions Helper/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,17 @@ class Data extends AbstractHelper
/**
* @var ProductMetadataInterface
*/
protected $productMetadataInterface;
private $productMetadataInterface;

/**
* @var ModuleListInterface
*/
protected $moduleList;
private $moduleList;

/**
* @var null
*/
protected $modules = null;
private $modules = null;

/**
* Data constructor.
Expand Down Expand Up @@ -58,7 +58,8 @@ public function getExtensionVersion()
{
$extensionInfo = $this->getModuleInfo('PostcodeNl_Api');

$extensionVersion = ($extensionInfo && isset($extensionInfo['version'])) ? (string) $extensionInfo['version'] : 'unknown';
$extensionVersion = ($extensionInfo && isset($extensionInfo['version']))
? (string) $extensionInfo['version'] : 'unknown';

return $extensionVersion;
}
Expand All @@ -85,7 +86,7 @@ public function getMagentoVersion()
* @param $moduleName
* @return null
*/
protected function getModuleInfo($moduleName)
private function getModuleInfo($moduleName)
{
$modules = $this->getMagentoModules();

Expand Down Expand Up @@ -126,7 +127,7 @@ public function getMagentoModules()
*
* @return int
*/
protected function getEnrichType()
private function getEnrichType()
{
return 0;
}
Expand All @@ -135,9 +136,11 @@ protected function getEnrichType()
* Method to check for SSL support in CURL
* @return int
*/
protected function curlHasSsl()
private function curlHasSsl()
{
// @codingStandardsIgnoreStart
$curlVersion = curl_version();
// @codingStandardsIgnoreEnd

return $curlVersion['features'] & CURL_VERSION_SSL;
}
Expand All @@ -153,7 +156,9 @@ public function checkCapabilities()

if (!$this->curlHasSsl()) {
$result = [
'message' => $this->__('Cannot connect to Postcode.nl API: Server is missing SSL (https) support for CURL.')];
'message' =>
$this->__('Cannot connect to Postcode.nl API: Server is missing SSL (https) support for CURL.')
];
}

return $result;
Expand Down
2 changes: 1 addition & 1 deletion Model/Address.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class Address
/**
* @var \Wezz\Postcode\Api\ClientApi
*/
protected $clientApi;
private $clientApi;

/**
* Address constructor.
Expand Down
Loading

0 comments on commit 615b111

Please sign in to comment.