Skip to content

Commit

Permalink
Fixed registration of the gateway test host
Browse files Browse the repository at this point in the history
Gateways registered as separate modules (vub-eplatby, slsp) didn't have
the test host available. Originally (during loadConfiguration()) the
system wasn't aware of this additional gateways and they were registered
later.

Moving the registration to the beforeCompile() makes sure, that all
dependency (and gateway) definitions are available and system can
correctly register the test host.

remp/crm#2751

(cherry picked from commit 2527699aad9e331112b1873a6a18d859d24fb9a5)
  • Loading branch information
rootpd committed Feb 8, 2023
1 parent 1be1ec2 commit 4e1d87d
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/DI/PaymentsModuleExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,10 @@ final class PaymentsModuleExtension extends CompilerExtension implements Transla
{
public function loadConfiguration()
{
$builder = $this->getContainerBuilder();
// load services from config and register them to Nette\DI Container
$this->compiler->loadDefinitionsFromConfig(
$this->loadFromFile(__DIR__.'/../config/config.neon')['services']
);

foreach ($builder->findByType(\Crm\PaymentsModule\Gateways\GatewayAbstract::class) as $definition) {
$definition->addSetup('setTestHost', [$this->config->gateway_test_host]);
}
}

public function getConfigSchema(): \Nette\Schema\Schema
Expand All @@ -34,6 +29,10 @@ public function beforeCompile()
// load presenters from extension to Nette
$builder->getDefinition($builder->getByType(\Nette\Application\IPresenterFactory::class))
->addSetup('setMapping', [['Payments' => 'Crm\PaymentsModule\Presenters\*Presenter']]);

foreach ($builder->findByType(\Crm\PaymentsModule\Gateways\GatewayAbstract::class) as $definition) {
$definition->addSetup('setTestHost', [$this->config->gateway_test_host]);
}
}

/**
Expand Down

0 comments on commit 4e1d87d

Please sign in to comment.