Skip to content

Commit

Permalink
Making configs movement as non-breaking change, cleaning up
Browse files Browse the repository at this point in the history
* All newly created mail configs now copy values from old mail
config so they don't stop working after the release.
* Configs were refactored to use common trait to maintain sorting
category, and default values.
* Some translations were not correct.

remp/crm#1061
  • Loading branch information
rootpd committed Feb 18, 2020
1 parent 7861be3 commit c8d0347
Show file tree
Hide file tree
Showing 2 changed files with 85 additions and 96 deletions.
10 changes: 5 additions & 5 deletions src/lang/slsp_sporopay.sk_SK.neon
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,17 @@ config:
name: SLSP zložka
description: "IMAP zložka do ktoreho sa presunie email po spracovani (napr. INBOX/processed) (<a href='https://github.com/remp2020/crm-slsp-sporopay-module#confirmation-e-mails' target='_blank'>info</a>)"
slsp_notification_confirmation_host:
name: SLSP notifikacia host
name: SLSP notifikácia host
description: "IMAP host pre pripojenie (napr. imap.gmail.com) (<a href='https://github.com/remp2020/crm-slsp-sporopay-module#confirmation-e-mails' target='_blank'>info</a>)"
slsp_notification_confirmation_port:
name: SLSP notifikacia port
name: SLSP notifikácia port
description: "IMAP port pre pripojenie (napr. 993) (<a href='https://github.com/remp2020/crm-slsp-sporopay-module#confirmation-e-mails' target='_blank'>info</a>)"
slsp_notification_confirmation_username:
name: SLSP notifikacia username
name: SLSP notifikácia username
description: "IMAP prihlasovacie meno pre pripojenie (napr. [email protected]) (<a href='https://github.com/remp2020/crm-slsp-sporopay-module#confirmation-e-mails' target='_blank'>info</a>)"
slsp_notification_confirmation_password:
name: SLSP notifikacia password
name: SLSP notifikácia password
description: "IMAP heslo pre pripojenie (napr. password) (<a href='https://github.com/remp2020/crm-slsp-sporopay-module#confirmation-e-mails' target='_blank'>info</a>)"
slsp_notification_confirmation_processed_folder:
name: SLSP notifikacia zložka
name: SLSP notifikácia zložka
description: "IMAP zložka do ktoreho sa presunie email po spracovani (napr. INBOX/processed) (<a href='https://github.com/remp2020/crm-slsp-sporopay-module#confirmation-e-mails' target='_blank'>info</a>)"
171 changes: 80 additions & 91 deletions src/seeders/ConfigsSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,14 @@
use Crm\ApplicationModule\Config\ApplicationConfig;
use Crm\ApplicationModule\Config\Repository\ConfigCategoriesRepository;
use Crm\ApplicationModule\Config\Repository\ConfigsRepository;
use Crm\ApplicationModule\Seeders\ConfigsTrait;
use Crm\ApplicationModule\Seeders\ISeeder;
use Symfony\Component\Console\Output\OutputInterface;

class ConfigsSeeder implements ISeeder
{
use ConfigsTrait;

private $configCategoriesRepository;

private $configsRepository;
Expand All @@ -30,193 +33,179 @@ public function __construct(
public function seed(OutputInterface $output)
{
$category = $this->configCategoriesRepository->findBy('name', 'payments.config.category');
$sorting = 1500;
$sorting = 1501;

$this->addPaymentConfig(
$this->addConfig(
$output,
$category,
'slsp_sporopay_sharedsecret',
ApplicationConfig::TYPE_STRING,
'slsp_sporopay.config.sharedsecret.name',
'slsp_sporopay.config.sharedsecret.description',
'Z3qY08EpvLlAAoMZdnyUdQ==',
$sorting++,
'slsp_sporopay.config.sharedsecret.description'
$sorting++
);
$this->addPaymentConfig(

$this->addConfig(
$output,
$category,
'slsp_sporopay_accountnumberprefix',
ApplicationConfig::TYPE_STRING,
'slsp_sporopay.config.accountnumberprefix.name',
'slsp_sporopay.config.accountnumberprefix.description',
'999999',
$sorting++,
'slsp_sporopay.config.accountnumberprefix.description'
$sorting++
);
$this->addPaymentConfig(

$this->addConfig(
$output,
$category,
'slsp_sporopay_accountnumber',
ApplicationConfig::TYPE_STRING,
'slsp_sporopay.config.accountnumber.name',
'slsp_sporopay.config.accountnumber.description',
'1111111111',
$sorting++,
'slsp_sporopay.config.accountnumber.description'
$sorting++
);
$this->addPaymentConfig(

$this->addConfig(
$output,
$category,
'slsp_sporopay_specificsymbol',
ApplicationConfig::TYPE_STRING,
'slsp_sporopay.config.specificsymbol.name',
'slsp_sporopay.config.specificsymbol.description',
'0000000000',
$sorting++,
'slsp_sporopay.config.specificsymbol.description'
$sorting++
);
$this->addPaymentConfig(

$this->addConfig(
$output,
$category,
'slsp_sporopay_mode',
ApplicationConfig::TYPE_STRING,
'slsp_sporopay.config.mode.name',
'slsp_sporopay.config.mode.description',
'test',
$sorting++,
'slsp_sporopay.config.mode.description'
$sorting++
);

$categoryName = 'payments.config.category_confirmation';
$category = $category = $this->configCategoriesRepository->loadByName($categoryName);
$category = $this->configCategoriesRepository->loadByName('payments.config.category_confirmation');
if (!$category) {
$category = $category = $this->configCategoriesRepository->add($categoryName, 'fa fa-check-double', 1600);
$category = $this->configCategoriesRepository->add('payments.config.category_confirmation', 'fa fa-check-double', 1600);
$output->writeln(' <comment>* config category <info>Potvrdzovacie e-maily</info> created</comment>');
} else {
$output->writeln(' * config category <info>Potvrdzovacie e-maily</info> exists');
}

$this->addPaymentConfig(
$this->addConfig(
$output,
$category,
'slsp_confirmation_host',
ApplicationConfig::TYPE_STRING,
'slsp_sporopay.config.slsp_confirmation_host.name',
'',
100,
'slsp_sporopay.config.slsp_confirmation_host.description'
'slsp_sporopay.config.slsp_confirmation_host.description',
null,
1101
);

$this->addPaymentConfig(
$this->addConfig(
$output,
$category,
'slsp_confirmation_port',
ApplicationConfig::TYPE_STRING,
'slsp_sporopay.config.slsp_confirmation_port.name',
'',
101,
'slsp_sporopay.config.slsp_confirmation_port.description'
'slsp_sporopay.config.slsp_confirmation_port.description',
null,
1102
);

$this->addPaymentConfig(
$this->addConfig(
$output,
$category,
'slsp_confirmation_username',
ApplicationConfig::TYPE_STRING,
'slsp_sporopay.config.slsp_confirmation_username.name',
'',
102,
'slsp_sporopay.config.slsp_confirmation_username.description'
'slsp_sporopay.config.slsp_confirmation_username.description',
null,
1103
);

$this->addPaymentConfig(
$this->addConfig(
$output,
$category,
'slsp_confirmation_password',
ApplicationConfig::TYPE_STRING,
'slsp_sporopay.config.slsp_confirmation_password.name',
'',
103,
'slsp_sporopay.config.slsp_confirmation_password.description'
'slsp_sporopay.config.slsp_confirmation_password.description',
null,
1104
);

$this->addPaymentConfig(
$this->addConfig(
$output,
$category,
'slsp_confirmation_processed_folder',
ApplicationConfig::TYPE_STRING,
'slsp_sporopay.config.slsp_confirmation_processed_folder.name',
'',
104,
'slsp_sporopay.config.slsp_confirmation_processed_folder.description'
'slsp_sporopay.config.slsp_confirmation_processed_folder.description',
null,
1105
);

$this->addPaymentConfig(
$this->addConfig(
$output,
$category,
'slsp_notification_confirmation_host',
ApplicationConfig::TYPE_STRING,
'slsp_sporopay.config.slsp_notification_confirmation_host.name',
'',
105,
'slsp_sporopay.config.slsp_notification_confirmation_host.description'
'slsp_sporopay.config.slsp_notification_confirmation_host.description',
null,
1201
);

$this->addPaymentConfig(
$this->addConfig(
$output,
$category,
'slsp_notification_confirmation_port',
ApplicationConfig::TYPE_STRING,
'slsp_sporopay.config.slsp_notification_confirmation_port.name',
'',
106,
'slsp_sporopay.config.slsp_notification_confirmation_port.description'
'slsp_sporopay.config.slsp_notification_confirmation_port.description',
null,
1202
);

$this->addPaymentConfig(
$this->addConfig(
$output,
$category,
'slsp_notification_confirmation_username',
ApplicationConfig::TYPE_STRING,
'slsp_sporopay.config.slsp_notification_confirmation_username.name',
'',
107,
'slsp_sporopay.config.slsp_notification_confirmation_username.description'
'slsp_sporopay.config.slsp_notification_confirmation_username.description',
null,
1203
);

$this->addPaymentConfig(
$this->addConfig(
$output,
$category,
'slsp_notification_confirmation_password',
ApplicationConfig::TYPE_STRING,
'slsp_sporopay.config.slsp_notification_confirmation_password.name',
'',
108,
'slsp_sporopay.config.slsp_notification_confirmation_password.description'
'slsp_sporopay.config.slsp_notification_confirmation_password.description',
null,
1204
);

$this->addPaymentConfig(
$this->addConfig(
$output,
$category,
'slsp_notification_confirmation_processed_folder',
ApplicationConfig::TYPE_STRING,
'slsp_sporopay.config.slsp_notification_confirmation_processed_folder.name',
'',
109,
'slsp_sporopay.config.slsp_notification_confirmation_processed_folder.description'
'slsp_sporopay.config.slsp_notification_confirmation_processed_folder.description',
null,
1205
);
}

private function addPaymentConfig(OutputInterface $output, $category, $name, $displayName, $value, $sorting, $description = null)
{
$config = $this->configsRepository->loadByName($name);
if (!$config) {
$this->configBuilder->createNew()
->setName($name)
->setDisplayName($displayName)
->setDescription($description)
->setValue($value)
->setType(ApplicationConfig::TYPE_STRING)
->setAutoload(true)
->setConfigCategory($category)
->setSorting($sorting)
->save();
$output->writeln(" <comment>* config item <info>$name</info> created</comment>");
} else {
$output->writeln(" * config item <info>$name</info> exists");

if ($config->has_default_value && $config->value !== $value) {
$this->configsRepository->update($config, ['value' => $value, 'has_default_value' => true]);
$output->writeln(" <comment>* config item <info>$name</info> updated</comment>");
}

if ($config->category->name != $category->name) {
$this->configsRepository->update($config, [
'config_category_id' => $category->id
]);
$output->writeln(" <comment>* config item <info>$name</info> updated</comment>");
}
}
}
}

0 comments on commit c8d0347

Please sign in to comment.