-
Notifications
You must be signed in to change notification settings - Fork 14
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 #54 from JerrySmidt/3.1.7
3.1.7
- Loading branch information
Showing
47 changed files
with
999 additions
and
1,294 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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,91 @@ | ||
<?php | ||
|
||
namespace Flekto\Postcode\Block\System\Config; | ||
|
||
use Flekto\Postcode\Helper\StoreConfigHelper; | ||
use Magento\Backend\Block\Template; | ||
use Magento\Framework\Data\Form\Element\AbstractElement; | ||
use Magento\Framework\Data\Form\Element\Renderer\RendererInterface; | ||
|
||
use Magento\Framework\App\Config\ConfigResource\ConfigInterface; | ||
|
||
class Status extends Template implements RendererInterface | ||
{ | ||
protected $_template = 'Flekto_Postcode::system/config/status.phtml'; | ||
protected $_scopeConfig; | ||
protected $_storeConfigHelper; | ||
protected $_resourceConfig; | ||
|
||
/** | ||
* @param Template\Context $context | ||
* @param StoreConfigHelper $storeConfigHelper | ||
* @param ConfigInterface $resourceConfig | ||
* @param array $data | ||
*/ | ||
public function __construct( | ||
Template\Context $context, | ||
StoreConfigHelper $storeConfigHelper, | ||
ConfigInterface $resourceConfig, | ||
array $data = [] | ||
) { | ||
$this->_scopeConfig = $context->getScopeConfig(); | ||
$this->_storeConfigHelper = $storeConfigHelper; | ||
$this->_resourceConfig = $resourceConfig; | ||
parent::__construct($context, $data); | ||
} | ||
|
||
/** | ||
* @param AbstractElement $element | ||
* | ||
* @return string | ||
*/ | ||
public function render(AbstractElement $element): string | ||
{ | ||
/** @noinspection PhpUndefinedMethodInspection */ | ||
$this->setElement($element); | ||
|
||
return $this->toHtml(); | ||
} | ||
|
||
/** | ||
* Get config to be used in the status template. | ||
* | ||
* @return array | ||
*/ | ||
public function getConfig(): array | ||
{ | ||
return [ | ||
'enabled' => $this->_storeConfigHelper->isSetFlag(StoreConfigHelper::PATH['enabled']), | ||
'module_version' => $this->_storeConfigHelper->getValue(StoreConfigHelper::PATH['module_version']), | ||
'supported_countries' => $this->_storeConfigHelper->getSupportedCountries(), | ||
'account_name' => $this->_storeConfigHelper->getValue(StoreConfigHelper::PATH['account_name']), | ||
'account_status' => $this->_storeConfigHelper->getValue(StoreConfigHelper::PATH['account_status']), // Defaults to "new", see etc/config.xml. | ||
'has_credentials' => $this->_storeConfigHelper->hasCredentials(), | ||
]; | ||
} | ||
|
||
/** | ||
* Get short description of API status. | ||
* | ||
* @return string | ||
*/ | ||
public function getApiStatusDescription(): string | ||
{ | ||
$status = $this->_storeConfigHelper->getValue(StoreConfigHelper::PATH['account_status']); | ||
|
||
switch ($status) | ||
{ | ||
case \Flekto\Postcode\Helper\ApiClientHelper::API_ACCOUNT_STATUS_NEW: | ||
return __('not connected'); | ||
case \Flekto\Postcode\Helper\ApiClientHelper::API_ACCOUNT_STATUS_ACTIVE: | ||
return __('active'); | ||
case \Flekto\Postcode\Helper\ApiClientHelper::API_ACCOUNT_STATUS_INVALID_CREDENTIALS: | ||
return __('invalid key and/or secret'); | ||
case \Flekto\Postcode\Helper\ApiClientHelper::API_ACCOUNT_STATUS_INACTIVE: | ||
return __('inactive'); | ||
default: | ||
throw new \Exception('Invalid account status value.'); | ||
} | ||
} | ||
|
||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.