notFound example



    public function testNotCompatible(): void
    {
        $e = AppException::notCompatible('IncompatibleApp');

        static::assertEquals(AppException::NOT_COMPATIBLE, $e->getErrorCode());
    }

    public function testNotFound(): void
    {
        $e = AppException::notFound('NonExistingApp');

        static::assertInstanceOf(AppNotFoundException::class$e);
        static::assertEquals(AppException::NOT_FOUND, $e->getErrorCode());
    }

    public function testAlreadyInstalled(): void
    {
        $e = AppException::alreadyInstalled('AlreadyInstalledApp');

        static::assertInstanceOf(AppAlreadyInstalledException::class$e);
        static::assertEquals(AppException::ALREADY_INSTALLED, $e->getErrorCode());
    }
private readonly RuleConditionPersister $ruleConditionPersister,
        private readonly FlowEventPersister $flowEventPersister
    ) {
    }

    public function activateApp(string $appId, Context $context): void
    {
        /** @var AppEntity|null $app */
        $app = $this->appRepo->search(new Criteria([$appId])$context)->first();

        if (!$app) {
            throw AppException::notFound($appId);
        }
        if ($app->isActive()) {
            return;
        }

        $this->appRepo->update([['id' => $appId, 'active' => true]]$context);
        $this->templateStateService->activateAppTemplates($appId$context);
        $this->scriptPersister->activateAppScripts($appId$context);
        $this->paymentMethodStateService->activatePaymentMethods($appId$context);
        $this->ruleConditionPersister->activateConditionScripts($appId$context);
        $this->activeAppsLoader->reset();
        

        /** @var array{app_secret: non-empty-string, privileges: string} $row */
        $row = $this->connection->fetchAssociative('SELECT `app`.app_secret, `acl_role`.privileges FROM `app` LEFT JOIN acl_role ON app.acl_role_id = acl_role.id WHERE `app`.name = ? AND active = 1', [$name]);

        if (empty($row)) {
            throw AppException::notFound($name);
        }

        $row['privileges'] = json_decode($row['privileges'], true, 512, \JSON_THROW_ON_ERROR);

        return $row;
    }
}
Home | Imprint | This part of the site doesn't use cookies.