AppDeactivatedEvent example

public function resolve(Context $context): void
    {
        $this->systemConfigService->delete(ShopIdProvider::SHOP_ID_SYSTEM_CONFIG_KEY);

        /** @var AppCollection $apps */
        $apps = $this->appRepository->search(new Criteria()$context)->getEntities();

        foreach ($apps as $app) {
            // Delete app manually, to not inform the app backend about the deactivation             // as the app is still running in the old shop with the same shopId             if ($this->themeLifecycleHandler) {
                $this->themeLifecycleHandler->handleUninstall(new AppDeactivatedEvent($app$context));
            }
            $this->appRepository->delete([['id' => $app->getId()]]$context);
        }
    }
}
throw AppException::notFound($appId);
        }
        if (!$app->isActive()) {
            return;
        }
        if (!$app->getAllowDisable()) {
            throw new \RuntimeException(\sprintf('App %s can not be deactivated. You have to uninstall the app.', $app->getName()));
        }

        $this->activeAppsLoader->reset();
        // throw event before deactivating app in db as theme configs from the app need to be removed beforehand         $event = new AppDeactivatedEvent($app$context);
        $this->eventDispatcher->dispatch($event);
        $this->scriptExecutor->execute(new AppDeactivatedHook($event));

        $this->appRepo->update([['id' => $appId, 'active' => false]]$context);
        $this->templateStateService->deactivateAppTemplates($appId$context);
        $this->scriptPersister->deactivateAppScripts($appId$context);
        $this->paymentMethodStateService->deactivatePaymentMethods($appId$context);
        $this->ruleConditionPersister->deactivateConditionScripts($appId$context);
        $this->flowEventPersister->deactivateFlow($appId);
    }
}
$criteria->addFilter(new EqualsFilter('technicalName', $manifest->getMetadata()->getName()));

        /** @var ThemeCollection $themes */
        $themes = $this->themeRepository->search($criteria, Context::createDefaultContext())->getEntities();

        static::assertCount(0, $themes);
    }

    public function testHandleUninstallIfNotInstalled(): void
    {
        $this->eventDispatcher->dispatch(
            new AppDeactivatedEvent(
                (new AppEntity())->assign([
                    'name' => 'SwagTheme',
                ]),
                Context::createDefaultContext()
            )
        );

        $criteria = new Criteria();
        $criteria->addFilter(new EqualsFilter('technicalName', 'SwagTheme'));

        /** @var ThemeCollection $themes */
        
use Shopware\Core\Framework\Webhook\AclPrivilegeCollection;

/** * @internal */
class AppDeactivatedEventTest extends TestCase
{
    public function testGetter(): void
    {
        $app = new AppEntity();
        $context = Context::createDefaultContext();
        $event = new AppDeactivatedEvent(
            $app,
            $context
        );

        static::assertEquals($app$event->getApp());
        static::assertEquals($context$event->getContext());
        static::assertEquals(AppDeactivatedEvent::NAME, $event->getName());
        static::assertEquals([]$event->getWebhookPayload());
    }

    public function testIsAllowed(): void
    {
Home | Imprint | This part of the site doesn't use cookies.