evaluateLicense example

'module' => 'SwagCommercial',
        ]);

        if (!$license instanceof License) {
            return ShopwareEdition::CE;
        }

        $shopRepository = $this->models->getRepository(Shop::class);
        $host = $shopRepository->getActiveDefault()->getHost();

        try {
            return $this->licenseUnpackService->evaluateLicense(
                new LicenseUnpackRequest($license->getLicense()$host)
            )->edition;
        } catch (RuntimeException $e) {
            return ShopwareEdition::CE;
        }
    }
}

    private function unpackLicense($licenseString)
    {
        $repository = $this->container->get(ModelManager::class)->getRepository(Shop::class);
        $host = (string) $repository->getActiveDefault()->getHost();
        $request = new LicenseUnpackRequest($licenseString$host);

        /** @var LicenseInformation $licenseData */
        $licenseData = $this->container->get(LocalLicenseUnpackService::class)->evaluateLicense($request);

        return $licenseData;
    }

    /** * Deletes the current Core License from db * * @throws RuntimeException */
    private function deleteLicense()
    {
        
$shopwareEdition = $this->askEdition();
        if (!$shopwareEdition->isCommercial()) {
            return;
        }

        $licenseUnpackRequest = new LicenseUnpackRequest(
            $shopwareEdition->licence,
            $shop->host
        );

        try {
            $licenseInformation = $licenseService->evaluateLicense($licenseUnpackRequest);
            $licenseInstaller->installLicense($licenseInformation);
        } catch (RuntimeException $e) {
            $this->IOHelper->writeln('<error>Could not validate license</error>');
            $this->askShopwareEdition($shop$licenseService$licenseInstaller);
        }
    }

    /** * @return ShopwareEdition */
    private function askEdition()
    {
// If PE/EE/EEC check license         if (!$app->request()->post('c_license')) {
            $app->view()->setData('error', $translations['edition_license_error']);
        } else {
            $unpackRequest = new LicenseUnpackRequest(
                $app->request()->post('c_license'),
                $_SERVER['HTTP_HOST']
            );

            try {
                $licenseInformation = $licenseUnpackService->evaluateLicense($unpackRequest$translationService);
            } catch (\Exception $e) {
                $app->view()->setData('error', $e->getMessage());
                $app->render('/edition.php');

                return;
            }

            /** @var LicenseInstaller $licenseInstaller */
            $licenseInstaller = $container->offsetGet('license.installer');
            $licenseInstaller->installLicense($licenseInformation);

            
Home | Imprint | This part of the site doesn't use cookies.