Skip to content

Commit

Permalink
Lazy-load internal stripe dependencies to avoid missing service error
Browse files Browse the repository at this point in the history
This presenter is scanned event when extension is not enabled. The initialization
of presenter fails because of missing dependencies. The best approach for now
is to load the dependency lazily.

remp/crm#2129
  • Loading branch information
rootpd committed Nov 18, 2021
1 parent 9cf8699 commit 9e2d8a7
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/presenters/StripeWalletPresenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,17 @@ class StripeWalletPresenter extends FrontendPresenter
/** @var CountriesRepository @inject */
public CountriesRepository $countriesRepository;

/** @var StripeWalletClient @inject */
public StripeWalletClient $stripeWalletClient;

public function startup()
{
parent::startup();

// Requiring this dependency on the fly, since we scan this presenter even when module is not enabled
// and attempt to pass it in construct fails because service would not be registered on some installations.
$this->stripeWalletClient = $this->context->getByType(StripeWalletClient::class);
}

public function renderDefault($id)
{
$payment = $this->getPayment($id);
Expand Down

0 comments on commit 9e2d8a7

Please sign in to comment.