Skip to content

Commit

Permalink
feat!: configure module via config file
Browse files Browse the repository at this point in the history
  • Loading branch information
BernhardBaumrock committed Jul 1, 2024
1 parent 4e0360b commit daeea19
Showing 1 changed file with 5 additions and 42 deletions.
47 changes: 5 additions & 42 deletions RockMollie.module.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,7 @@ public function api(): MollieApiClient
{
require_once("vendor/autoload.php");
$api = new \Mollie\Api\MollieApiClient();

if (getenv('DDEV_HOSTNAME') || !$this->live) {
// use the test api key
$api->setApiKey($this->testapikey);
} else {
// we are live
if (!$this->liveapikey) throw new WireException("No Live API kay found for RockMollie");
$api->setApiKey($this->liveapikey);
}
$api->setApiKey($this->wire->config->mollieApiKey);
return $api;
}

Expand All @@ -70,39 +62,10 @@ public function getModuleConfigInputfields($inputfields)
]);

$inputfields->add([
'type' => 'toggle',
'label' => 'API Mode',
'name' => 'live',
'value' => $this->live ?: false,
'notes' => 'Selected item is gray',
'labelType' => InputfieldToggle::labelTypeCustom,
'yesLabel' => 'LIVE',
'noLabel' => 'TEST',
'columnWidth' => 33,
]);

$inputfields->add([
'type' => 'text',
'label' => 'TEST API Key',
'name' => 'testapikey',
'value' => $this->testapikey,
'prependMarkup' => '<style>#Inputfield_testapikey:not(:focus) {
color: transparent;
text-shadow: 0 0 10px rgba(0,0,0,0.5);
}</style>',
'columnWidth' => 33,
]);

$inputfields->add([
'type' => 'text',
'label' => 'LIVE API Key',
'name' => 'liveapikey',
'value' => $this->liveapikey,
'prependMarkup' => '<style>#Inputfield_liveapikey:not(:focus) {
color: transparent;
text-shadow: 0 0 10px rgba(0,0,0,0.5);
}</style>',
'columnWidth' => 33,
'type' => 'markup',
'label' => 'Setup',
'icon' => 'code',
'value' => 'Set $config->mollieApiKey = ... in your site config.php',
]);

return $inputfields;
Expand Down

0 comments on commit daeea19

Please sign in to comment.