Skip to content

Commit

Permalink
bundle-file: add not-null-check for container-variable (symfony 6.4)
Browse files Browse the repository at this point in the history
  • Loading branch information
rommelfreddy committed Sep 29, 2023
1 parent e38e3aa commit 967657d
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/PayonePayment.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
use Shopware\Core\System\SystemConfig\SystemConfigService;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;

class PayonePayment extends Plugin
Expand Down Expand Up @@ -73,6 +74,11 @@ public function deactivate(DeactivateContext $deactivateContext): void

public function uninstall(UninstallContext $uninstallContext): void
{
if (!$this->container instanceof ContainerInterface) {
// symfony 6.4: variable has been set to ContainerInterface|null.
throw new \RuntimeException('container instance missing.');
}

$this->getConfigInstaller()->uninstall($uninstallContext);
$this->getCustomFieldInstaller()->uninstall($uninstallContext);
$this->getPaymentMethodInstaller()->uninstall($uninstallContext);
Expand Down Expand Up @@ -100,6 +106,11 @@ public function executeComposerCommands(): bool

private function getRuleInstallerSecureInvoice(): RuleInstallerSecureInvoice
{
if (!$this->container instanceof ContainerInterface) {
// symfony 6.4: variable has been set to ContainerInterface|null.
throw new \RuntimeException('container instance missing.');
}

/** @var EntityRepository $ruleRepository */
$ruleRepository = $this->container->get('rule.repository');
/** @var EntityRepository $countryRepository */
Expand All @@ -119,6 +130,11 @@ private function getRuleInstallerSecureInvoice(): RuleInstallerSecureInvoice

private function getConfigInstaller(): ConfigInstaller
{
if (!$this->container instanceof ContainerInterface) {
// symfony 6.4: variable has been set to ContainerInterface|null.
throw new \RuntimeException('container instance missing.');
}

/** @var SystemConfigService $systemConfigService */
$systemConfigService = $this->container->get(SystemConfigService::class);

Expand All @@ -127,6 +143,11 @@ private function getConfigInstaller(): ConfigInstaller

private function getPaymentMethodInstaller(): PaymentMethodInstaller
{
if (!$this->container instanceof ContainerInterface) {
// symfony 6.4: variable has been set to ContainerInterface|null.
throw new \RuntimeException('container instance missing.');
}

/** @var PluginIdProvider $pluginIdProvider */
$pluginIdProvider = $this->container->get(PluginIdProvider::class);
/** @var EntityRepository $paymentMethodRepository */
Expand All @@ -149,6 +170,11 @@ private function getPaymentMethodInstaller(): PaymentMethodInstaller

private function getCustomFieldInstaller(): CustomFieldInstaller
{
if (!$this->container instanceof ContainerInterface) {
// symfony 6.4: variable has been set to ContainerInterface|null.
throw new \RuntimeException('container instance missing.');
}

/** @var EntityRepository $customFieldSetRepository */
$customFieldSetRepository = $this->container->get('custom_field_set.repository');
/** @var EntityRepository $customFieldRepository */
Expand Down

0 comments on commit 967657d

Please sign in to comment.