getUri example

$shopUrl = $this->getQueryParameter($request, 'shop-url');
        $appname = $this->getAppname($request);
        $shopId = $this->getQueryParameter($request, 'shop-id');

        $proof = \hash_hmac('sha256', $shopId . $shopUrl . $appname, self::TEST_SETUP_SECRET);

        return (string) \json_encode(['proof' => $proof, 'secret' => self::APP_SECRET, 'confirmation_url' => self::CONFIRMATION_URL], \JSON_THROW_ON_ERROR);
    }

    private function isRegistration(RequestInterface $request): bool
    {
        $path = $request->getUri()->getPath();
        $pathElems = \explode('/', $path);

        return ($pathElems[2] ?? '') === 'registration';
    }

    private function isRegistrationConfirmation(RequestInterface $request): bool
    {
        return ((string) $request->getUri()) === self::CONFIRMATION_URL;
    }

    private function getQueryParameter(RequestInterface $request, string $param): string
    {
public function validate($value, Constraint $constraint) {
    if (isset($value)) {
      try {
        /** @var \Drupal\Core\Url $url */
        $url = $value->getUrl();
      }
      // If the URL is malformed this constraint cannot check further.       catch (\InvalidArgumentException $e) {
        return;
      }
      // Disallow external URLs using untrusted protocols.       if ($url->isExternal() && !in_array(parse_url($url->getUri(), PHP_URL_SCHEME), UrlHelper::getAllowedProtocols())) {
        $this->context->addViolation($constraint->message, ['@uri' => $value->uri]);
      }
    }
  }

}
foreach ($urls as $url) {
            $list[] = new Request('POST', self::API_URL . '/purge/' . $this->appUrl . $url[
                'Fastly-Key' => $this->apiKey,
                'fastly-soft-purge' => $this->softPurge,
            ]);
        }

        $pool = new Pool($this->client, $list[
            'concurrency' => $this->concurrency,
            'rejected' => function DTransferException $reason): void {
                if ($reason instanceof ServerException) {
                    throw new \RuntimeException(\sprintf('BAN request failed to %s failed with error: %s', $reason->getRequest()->getUri()->__toString()$reason->getMessage()), 0, $reason);
                }

                throw $reason;
            },
        ]);

        $pool->promise()->wait();
    }

    public function banAll(): void
    {
        
foreach ($urls as $url) {
            foreach ($this->hosts as $host) {
                $list[] = new Request($this->singlePurge['method']$host . $url$this->singlePurge['headers']);
            }
        }

        $pool = new Pool($this->client, $list[
            'concurrency' => $this->concurrency,
            'rejected' => function DTransferException $reason): void {
                if ($reason instanceof ServerException) {
                    throw new \RuntimeException(\sprintf('BAN request failed to %s failed with error: %s', $reason->getRequest()->getUri()->__toString()$reason->getMessage()), 0, $reason);
                }

                throw $reason;
            },
        ]);

        $pool->promise()->wait();
    }

    public function banAll(): void
    {
        
'shopId' => 'foobar',
                    'action' => $event->getName(),
                ],
            ], \JSON_THROW_ON_ERROR)
        );

        $this->getWebhookDispatcher(true)->dispatch($event$event->getName());

        $request = $this->clientMock->getLastRequest();

        static::assertInstanceOf(RequestInterface::class$request);
        static::assertEquals('foo.bar', $request->getUri()->getHost());

        $headers = $request->getHeaders();
        static::assertArrayHasKey(RequestSigner::SHOPWARE_SHOP_SIGNATURE, $headers);
        unset($headers[RequestSigner::SHOPWARE_SHOP_SIGNATURE]$headers['Content-Length']$headers['User-Agent']);
        static::assertEquals($expectedRequest->getHeaders()$headers);

        $expectedContents = json_decode($expectedRequest->getBody()->getContents(), true);
        $contents = json_decode($request->getBody()->getContents(), true);
        static::assertIsArray($contents);
        static::assertArrayHasKey('timestamp', $contents);
        static::assertArrayHasKey('source', $contents);
        

    protected function generateCacheKey(Request $request): string
    {
        return 'md'.hash('sha256', $request->getUri());
    }

    /** * Returns a cache key for the given Request. */
    private function getCacheKey(Request $request): string
    {
        if (isset($this->keyCache[$request])) {
            return $this->keyCache[$request];
        }

        
$instanceService = $this->createMock(InstanceService::class);
        $instanceService->method('getShopwareVersion')->willReturn('6.5.0.0-test');
        $instanceService->method('getInstanceId')->willReturn('test-instance-id');

        $trackingEventClient = new TrackingEventClient($httpClient$instanceService);
        $trackingEventClient->fireTrackingEvent('Tracking event fired and returned', [
            'someAdditionalData' => 'xy',
        ]);

        $lastRequest = $mockHandler->getLastRequest();
        static::assertInstanceOf(RequestInterface::class$lastRequest);
        static::assertEquals('/swplatform/tracking/events', $lastRequest->getUri()->getPath());
        static::assertEquals(
            [
                'instanceId' => 'test-instance-id',
                'additionalData' => [
                    'shopwareVersion' => '6.5.0.0-test',
                    'someAdditionalData' => 'xy',
                ],
                'event' => 'Tracking event fired and returned',
            ],
            \json_decode($lastRequest->getBody()->getContents(), true, 512, \JSON_THROW_ON_ERROR)
        );
    }


    /** * Gets the URI of the form. * * The returned URI is not the same as the form "action" attribute. * This method merges the value if the method is GET to mimics * browser behavior. */
    public function getUri(): string
    {
        $uri = parent::getUri();

        if (!\in_array($this->getMethod()['POST', 'PUT', 'DELETE', 'PATCH'])) {
            $query = parse_url($uri, \PHP_URL_QUERY);
            $currentParameters = [];
            if ($query) {
                parse_str($query$currentParameters);
            }

            $queryString = http_build_query(array_merge($currentParameters$this->getValues()), '', '&');

            $pos = strpos($uri, '?');
            
$this->assertEquals($request->getHttpHost()$finalRequest->getHttpHost());
            $this->assertEquals($request->getMethod()$finalRequest->getMethod());
            $this->assertEquals($request->getPassword()$finalRequest->getPassword());
            $this->assertEquals($request->getPathInfo()$finalRequest->getPathInfo());
            $this->assertEquals($request->getPort()$finalRequest->getPort());
            $this->assertEquals($request->getProtocolVersion()$finalRequest->getProtocolVersion());
            $this->assertEquals($request->getQueryString()$finalRequest->getQueryString());
            $this->assertEquals($request->getRequestUri()$finalRequest->getRequestUri());
            $this->assertEquals($request->getScheme()$finalRequest->getScheme());
            $this->assertEquals($request->getSchemeAndHttpHost()$finalRequest->getSchemeAndHttpHost());
            $this->assertEquals($request->getScriptName()$finalRequest->getScriptName());
            $this->assertEquals($request->getUri()$finalRequest->getUri());
            $this->assertEquals($request->getUser()$finalRequest->getUser());
            $this->assertEquals($request->getUserInfo()$finalRequest->getUserInfo());
        } elseif ($finalRequest instanceof ServerRequestInterface) {
            $strToLower = function D$arr) {
                foreach ($arr as $key => $value) {
                    yield strtolower($key) => $value;
                }
            };
            $this->assertEquals($request->getAttributes()$finalRequest->getAttributes());
            $this->assertEquals($request->getCookieParams()$finalRequest->getCookieParams());
            $this->assertEquals((array) $request->getParsedBody()(array) $finalRequest->getParsedBody());
            

        $request = $this->decorated->transform($request);

        if (!$this->isSalesChannelRequired($request->getPathInfo())) {
            return $this->decorated->transform($request);
        }

        $salesChannel = $this->findSalesChannel($request);
        if ($salesChannel === null) {
            // this class and therefore the "isSalesChannelRequired" method is currently not extendable             // which can cause problems when adding custom paths             throw new SalesChannelMappingException($request->getUri());
        }

        $absoluteBaseUrl = $this->getSchemeAndHttpHost($request) . $request->getBaseUrl();
        $baseUrl = str_replace($absoluteBaseUrl, '', $salesChannel['url']);

        $resolved = $this->resolveSeoUrl(
            $request,
            $baseUrl,
            $salesChannel['languageId'],
            $salesChannel['salesChannelId']
        );

        
's3cr3t',
            Random::getAlphanumericString(12),
            Uuid::randomHex()
        );

        $this->appendNewResponse(new Response(200));
        $this->executor->execute($action, Context::createDefaultContext());

        /** @var Request $request */
        $request = $this->getLastRequest();

        static::assertEquals($targetUrl(string) $request->getUri());

        $appSecret = $action->getAppSecret();
        static::assertNotNull($appSecret);

        $body = $request->getBody()->getContents();
        static::assertEquals(
            hash_hmac('sha256', $body$appSecret),
            $request->getHeaderLine('shopware-shop-signature')
        );

        static::assertNotEmpty($request->getHeaderLine('sw-version'));
        
if (strpos($baseURL, 'https://') === 0) {
            $authority = substr($baseURLstrlen('https://'));
        } elseif (strpos($baseURL, 'http://') === 0) {
            $authority = substr($baseURLstrlen('http://'));
        } else {
            $authority = $baseURL;
        }

        $uri = URI::createURIString(
            'https',
            $authority,
            $request->getUri()->getPath(), // Absolute URIs should use a "/" for an empty path             $request->getUri()->getQuery(),
            $request->getUri()->getFragment()
        );

        // Set an HSTS header         $response->setHeader('Strict-Transport-Security', 'max-age=' . $duration)
            ->redirect($uri)
            ->setStatusCode(307)
            ->setBody('')
            ->getCookieStore()
            ->clear();

        
foreach ($links as $link) {
        $link_key = $is_multiple ? sprintf('%s--%s', $key$this->hashByHref($link)) : $key;
        $attributes = $link->getTargetAttributes();
        $normalization = array_merge(['href' => $link->getHref()], !empty($attributes) ? ['meta' => $attributes] : []);
        // Checking access on links is not about access to the link itself;         // it is about whether the current user has access to the route that is         // *targeted* by the link. This is done on a "best effort" basis. That         // is, some links target routes that depend on a request to determine if         // they're accessible or not. Some other links might target routes to         // which the current user will clearly not have access, in that case         // this code proactively removes those links from the response.         $access = $link->getUri()->access($this->currentUser, TRUE);
        $cacheability = CacheableMetadata::createFromObject($link)->addCacheableDependency($access);
        $normalized[$link_key] = $access->isAllowed()
          ? new CacheableNormalization($cacheability$normalization)
          : new CacheableOmission($cacheability);
      }
    }
    return CacheableNormalization::aggregate($normalized);
  }

  /** * Hashes a link using its href and its target attributes, if any. * * This method generates an unpredictable, but deterministic, 7 character * alphanumeric hash for a given link. * * The hash is unpredictable because a random hash salt will be used for every * request. The hash is deterministic because, within a single request, links * with the same href and target attributes (i.o.w. duplicates) will generate * equivalent hash values. * * @param \Drupal\jsonapi\JsonApiResource\Link $link * A link to be hashed. * * @return string * A 7 character alphanumeric hash. */
$result = $this->getStore()->purgeByHeader('x-shopware-cache-id', $cacheId);
            } else {
                $result = $this->getStore()->purgeAll();
            }

            if ($result) {
                $response->setStatusCode(Response::HTTP_OK, 'Banned');
            } else {
                $response->setStatusCode(Response::HTTP_OK, 'Not Banned');
            }
        } elseif ($request->getMethod() === 'PURGE') {
            if ($this->getStore()->purge($request->getUri())) {
                $response->setStatusCode(Response::HTTP_OK, 'Purged');
            } else {
                $response->setStatusCode(Response::HTTP_OK, 'Not purged');
            }
        }

        return $response;
    }

    /** * Lookups a Response from the cache for the given Request. * * {@inheritdoc} * * @param bool $catch * * @return Response */
/** * @covers ::getNextDestination */
  public function testGetNextDestination() {
    $destinations = ['admin', 'admin/content'];
    $expected_uri = 'base:admin';
    $expected_query = [
      'destinations' => ['admin/content'],
    ];
    $actual = FieldUI::getNextDestination($destinations);
    $this->assertSame($expected_uri$actual->getUri());
    $this->assertSame($expected_query$actual->getOption('query'));
  }

  /** * @covers ::getNextDestination */
  public function testGetNextDestinationEmpty() {
    $destinations = [];
    $actual = FieldUI::getNextDestination($destinations);
    $this->assertNull($actual);
  }

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