getShopwareVersion example



    /** * @throws Exception * * @return bool */
    public function download(DownloadRequest $request)
    {
        $metaRequest = new MetaRequest(
            $request->getTechnicalName(),
            $request->getShopwareVersion(),
            $request->getDomain(),
            $request->getToken()
        );

        $result = $this->getMetaInformation($metaRequest);

        $response = $this->httpClient->get($result->getUri());
        $file = $this->createDownloadZip($response->getBody());

        $this->extractPluginZip($file$metaRequest->getTechnicalName());
        unlink($file);

        
'source' => [
                'url' => 'https://example.com',
                'appVersion' => $webhookEntity->getApp()?->getVersion(),
                'shopId' => 'foobar',
                'action' => $event->getName(),
            ],
        ]$payload);

        static::assertEquals($message->getLanguageId(), Defaults::LANGUAGE_SYSTEM);
        static::assertEquals($message->getAppId()$webhookEntity->getApp()?->getId());
        static::assertEquals($message->getSecret()$webhookEntity->getApp()?->getAppSecret());
        static::assertEquals($message->getShopwareVersion(), '0.0.0');
        static::assertEquals($message->getUrl(), 'https://foo.bar');
        static::assertEquals($message->getWebhookId()$webhookEntity->getId());
    }

    private function getWebhookDispatcher(bool $isAdminWorkerEnabled): WebhookDispatcher
    {
        return new WebhookDispatcher(
            $this->dispatcher,
            $this->connection,
            $this->client,
            'https://example.com',
            
/** * @param PluginStruct[] $plugins * * @return PluginStruct[] */
    private function getAdditionallyStoreData($plugins, BaseRequest $context)
    {
        $names = array_keys($plugins);

        $storeContext = new PluginsByTechnicalNameRequest(
            $context->getLocale(),
            $context->getShopwareVersion(),
            $names
        );

        $store = $this->storePluginService->getPlugins($storeContext);

        $merged = [];
        foreach ($plugins as $plugin) {
            $key = strtolower($plugin->getTechnicalName());

            if (!\array_key_exists($key$store)) {
                $merged[$key] = $plugin;
                
/** * @return \Shopware\Components\HttpClient\Response */
    public function updateLicences(UpdateLicencesRequest $request)
    {
        $response = $this->storeClient->doAuthPostRequestRaw(
            $request->getToken(),
            '/licenseupgrades/simple',
            [
                'domain' => $request->getDomain(),
                'shopwareVersion' => $request->getShopwareVersion(),
                'locale' => $request->getLocale(),
            ]
        );

        return $response;
    }

    /** * function to get expired and soon expiring plugins * * @return PluginInformationStruct[] */
self::SHOPWARE_PLATFORM_TOKEN_HEADER => $this->getUserStoreToken($context),
            self::SHOPWARE_SHOP_SECRET_HEADER => $this->systemConfigService->getString(self::CONFIG_KEY_STORE_SHOP_SECRET),
        ]);
    }

    /** * @return array<string, string> */
    public function getDefaultQueryParameters(Context $context): array
    {
        return [
            'shopwareVersion' => $this->instanceService->getShopwareVersion(),
            'language' => $this->localeProvider->getLocaleFromContext($context),
            'domain' => $this->getLicenseDomain(),
        ];
    }

    private function getUserStoreToken(Context $context): ?string
    {
        try {
            return $this->getTokenFromAdmin($context);
        } catch (InvalidContextSourceException) {
            return $this->getTokenFromSystem($context);
        }
/** * @param mixed[] $additionalData * * @return array<string, mixed>|null */
    public function fireTrackingEvent(string $eventName, array $additionalData = []): ?array
    {
        if (!$this->instanceService->getInstanceId()) {
            return null;
        }

        $additionalData['shopwareVersion'] = $this->instanceService->getShopwareVersion();
        $payload = [
            'additionalData' => $additionalData,
            'instanceId' => $this->instanceService->getInstanceId(),
            'event' => $eventName,
        ];

        try {
            $response = $this->client->request('POST', '/swplatform/tracking/events', ['json' => $payload]);

            return json_decode($response->getBody()->getContents(), true, flags: \JSON_THROW_ON_ERROR);
        } catch (\Exception) {
        }
return json_decode($response->getBody()->getContents(), true, flags: \JSON_THROW_ON_ERROR);
    }

    public function checkVerificationSecret(string $domain, Context $context, bool $testEnvironment): void
    {
        $this->client->request(
            Request::METHOD_POST,
            '/swplatform/firstrunwizard/shops',
            [
                'json' => [
                    'domain' => $domain,
                    'shopwareVersion' => $this->instanceService->getShopwareVersion(),
                    'testEnvironment' => $testEnvironment,
                ],
                'headers' => $this->optionsProvider->getAuthenticationHeader($context),
            ]
        );
    }

    /** * @return array{content: string, fileName: string} */
    public function fetchVerificationInfo(string $domain, Context $context): array
    {
if ($path === false) {
            throw new \LogicException("could not locate filepath for class {$className}");
        }

        return $path;
    }

    private function getDeprecationTagTester(): AnnotationTagTester
    {
        if ($this->deprecationTagTester === null) {
            $this->deprecationTagTester = new AnnotationTagTester(
                $this->getShopwareVersion(),
                $this->getManifestVersion()
            );
        }

        return $this->deprecationTagTester;
    }

    /** * can be overwritten with env variable VERSION */
    private function getShopwareVersion(): string
    {
$endpoint = $this->container->getParameter('shopware.store.apiEndpoint');

        $fileSystem = new SwagUpdateFileSystem();
        $conn = $this->get(Connection::class);
        $checks = [
            new RegexCheck($userLang),
            new MySQLVersionCheck($namespace),
            new PHPVersionCheck($namespace),
            new EmotionTemplateCheck($conn$namespace),
            new PHPExtensionCheck($namespace),
            new WritableCheck($fileSystem$namespace),
            new LicenseCheck($conn$endpoint$this->getShopwareVersion()$namespace),
        ];
        $validation = new Validation($checks);

        $this->View()->assign([
            'success' => true,
            'data' => $validation->checkRequirements($data->checks),
        ]);
    }

    /** * @return void */
$bus = $this->createMock(MessageBusInterface::class);
        $bus->expects(static::once())
            ->method('dispatch')
            ->with(static::callback(function DWebhookEventMessage $message) use ($payload$appId$webhookId$shopwareVersion) {
                $actualPayload = $message->getPayload();
                static::assertArrayHasKey('eventId', $actualPayload['source']);
                unset($actualPayload['source']['eventId']);
                static::assertEquals($payload$actualPayload);
                static::assertEquals($appId$message->getAppId());
                static::assertEquals($webhookId$message->getWebhookId());
                static::assertEquals($shopwareVersion$message->getShopwareVersion());
                static::assertEquals('s3cr3t', $message->getSecret());
                static::assertEquals(Defaults::LANGUAGE_SYSTEM, $message->getLanguageId());
                static::assertEquals('en-GB', $message->getUserLocale());

                return true;
            }))
            ->willReturn(new Envelope(new WebhookEventMessage($webhookEventId$payload$appId$webhookId, '6.4', 'http://test.com', 's3cr3t', Defaults::LANGUAGE_SYSTEM, 'en-GB')));

        $webhookDispatcher = new WebhookDispatcher(
            $this->getContainer()->get('event_dispatcher'),
            $this->getContainer()->get(Connection::class),
            


    /** * @throws Exception * * @return ListingResultStruct */
    public function getListing(ListingRequest $context)
    {
        $params = [
            'locale' => $context->getLocale(),
            'shopwareVersion' => $context->getShopwareVersion(),
            'offset' => $context->getOffset(),
            'limit' => $context->getLimit(),
            'sort' => json_encode($context->getSortings()),
            'filter' => json_encode($context->getConditions()),
        ];

        $data = $this->storeClient->doGetRequest(
            '/pluginStore/plugins',
            $params
        );

        

    public function __construct(
        private readonly Client $client,
        private readonly EntityRepository $webhookRepository,
        private readonly EntityRepository $webhookEventLogRepository
    ) {
    }

    public function __invoke(WebhookEventMessage $message): void
    {
        $shopwareVersion = $message->getShopwareVersion();

        $payload = $message->getPayload();
        $url = $message->getUrl();

        $timestamp = time();
        $payload['timestamp'] = $timestamp;

        /** @var string $jsonPayload */
        $jsonPayload = json_encode($payload, \JSON_THROW_ON_ERROR);

        $headers = ['Content-Type' => 'application/json',
            

        $this->getRequestHandler()->append(new Response(200, [], '{"signature": "signed"}'));

        static::assertEquals('signed', $this->storeClient->signPayloadWithAppSecret('[this can be anything]', 'testApp'));

        $lastRequest = $this->getRequestHandler()->getLastRequest();
        static::assertInstanceOf(RequestInterface::class$lastRequest);

        static::assertEquals('/swplatform/generatesignature', $lastRequest->getUri()->getPath());

        static::assertEquals([
            'shopwareVersion' => $this->getShopwareVersion(),
            'language' => 'en-GB',
            'domain' => 'shopware-test',
        ], Query::parse($lastRequest->getUri()->getQuery()));

        static::assertEquals([
            'appName' => 'testApp',
            'payload' => '[this can be anything]',
        ], \json_decode($lastRequest->getBody()->getContents(), true, flags: \JSON_THROW_ON_ERROR));
    }

    public function testItUpdatesUserTokenAfterLogin(): void
    {
static::assertEquals('i-am-unique', $instanceService->getInstanceId());
    }

    public function testItReturnsSpecificShopwareVersion(): void
    {
        $instanceService = new InstanceService(
            '6.1.0.0',
            null
        );

        static::assertEquals('6.1.0.0', $instanceService->getShopwareVersion());
    }

    public function testItReturnsShopwareVersionStringIfVersionIsDeveloperVersion(): void
    {
        $instanceService = new InstanceService(
            Kernel::SHOPWARE_FALLBACK_VERSION,
            null
        );

        static::assertEquals('___VERSION___', $instanceService->getShopwareVersion());
    }
}
static::assertEquals(
            $this->getLanguageFromContext($this->storeContext),
            $queries['language']
        );
    }

    public function testGetDefaultQueriesReturnsShopwareVersion(): void
    {
        $queries = $this->storeRequestOptionsProvider->getDefaultQueryParameters($this->storeContext);

        static::assertArrayHasKey('shopwareVersion', $queries);
        static::assertEquals($this->getShopwareVersion()$queries['shopwareVersion']);
    }

    public function testGetDefaultQueriesDoesHaveDomainSetEvenIfLicenseDomainIsNull(): void
    {
        $this->setLicenseDomain(null);

        $queries = $this->storeRequestOptionsProvider->getDefaultQueryParameters($this->storeContext);

        static::assertArrayHasKey('domain', $queries);
        static::assertEquals('', $queries['domain']);
    }

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