deactivateApp example

private const ACTION = 'deactivate';

    public function __construct(
        EntityRepository $appRepo,
        private readonly AppStateService $appStateService
    ) {
        parent::__construct($appRepo, self::ACTION);
    }

    public function runAction(string $appId, Context $context): void
    {
        $this->appStateService->deactivateApp($appId$context);
    }
}
$salesChannelId = $this->createSalesChannel();

        /* @phpstan-ignore-next-line */
        $this->themeService->assignTheme($themeId$salesChannelId$context);

        $criteria = new Criteria();
        $criteria->addFilter(new EqualsFilter('name', 'SwagTheme'));
        $appId = $this->appRepo->searchIds($criteria$context)->firstId();

        static::expectException(ThemeAssignmentException::class);
        /* @phpstan-ignore-next-line */
        $this->appStateService->deactivateApp($appId$context);
    }

    public function testAppWithAChildThemeInUseCannotBeDeactivated(): void
    {
        if (!$this->themeService) {
            static::markTestSkipped('AppThemeServiceTest needs storefront to be installed.');
        }
        $context = Context::createDefaultContext();
        $this->loadAppsFromDir(__DIR__ . '/../../Theme/fixtures/Apps/theme');
        $criteria = new Criteria();
        $criteria->addFilter(new EqualsFilter('technicalName', 'SwagTheme'));
        
static::assertSame('/0/value/customerGroupIds', $exceptions[1]['source']['pointer']);
            static::assertSame(NotBlank::IS_BLANK_ERROR, $exceptions[1]['code']);
        }
    }

    public function testRuleWithInactiveScript(): void
    {
        $this->installApp();
        $ruleId = Uuid::randomHex();
        $scope = $this->getCheckoutScope($ruleId);

        $this->appStateService->deactivateApp($this->appId, $this->context);

        /** @var RuleEntity $rule */
        $rule = $this->ruleRepository->search(new Criteria([$ruleId])$this->context)->get($ruleId);
        $payload = $rule->getPayload();
        static::assertInstanceOf(Rule::class$payload);
        static::assertFalse($payload->match($scope));

        $this->appStateService->activateApp($this->appId, $this->context);

        /** @var RuleEntity $rule */
        $rule = $this->ruleRepository->search(new Criteria([$ruleId])$this->context)->get($ruleId);
        
$this->scriptExecutor->execute(new AppUpdatedHook($event));
    }

    /** * @param array{id: string} $app */
    public function delete(string $appName, array $app, Context $context, bool $keepUserData = false): void
    {
        $appEntity = $this->loadApp($app['id']$context);

        if ($appEntity->isActive()) {
            $this->appStateService->deactivateApp($appEntity->getId()$context);
        }

        $this->removeAppAndRole($appEntity$context$keepUserData, true);
        $this->assetService->removeAssets($appEntity->getName());
        $this->customEntitySchemaUpdater->update();
    }

    public function ensureIsCompatible(Manifest $manifest): void
    {
        $versionParser = new VersionParser();
        if (!$manifest->getMetadata()->getCompatibility()->matches($versionParser->parseConstraints($this->shopwareVersion))) {
            


    public function testNotFoundAppThrowsOnActivate(): void
    {
        static::expectException(AppNotFoundException::class);
        $this->appStateService->activateApp(Uuid::randomHex(), Context::createDefaultContext());
    }

    public function testNotFoundAppThrowsOnDeactivate(): void
    {
        static::expectException(AppNotFoundException::class);
        $this->appStateService->deactivateApp(Uuid::randomHex(), Context::createDefaultContext());
    }

    public function testActivate(): void
    {
        $manifest = Manifest::createFromXmlFile(__DIR__ . '/Manifest/_fixtures/test/manifest.xml');
        $this->appLifecycle->install($manifest, false, $this->context);
        $appId = $this->appRepository->searchIds(new Criteria()$this->context)->firstId();
        static::assertNotNull($appId);
        $this->assertAppState($appId, false);

        $eventWasReceived = false;
        


    public function activateExtension(string $technicalName, Context $context): void
    {
        $id = $this->getAppByName($technicalName$context)->getId();
        $this->appStateService->activateApp($id$context);
    }

    public function deactivateExtension(string $technicalName, Context $context): void
    {
        $id = $this->getAppByName($technicalName$context)->getId();
        $this->appStateService->deactivateApp($id$context);
    }

    public function updateExtension(string $technicalName, bool $allowNewPermissions, Context $context): void
    {
        $manifests = $this->appLoader->load();

        if (!\array_key_exists($technicalName$manifests)) {
            throw StoreException::extensionInstallException('Cannot find extension');
        }

        $app = $this->getAppByName($technicalName$context);
        
Home | Imprint | This part of the site doesn't use cookies.