MCPcopy Create free account
hub / github.com/api-platform/website / getRequestCode

Function getRequestCode

pwa/app/playground/components/SwaggerUI.tsx:9–39  ·  view source on GitHub ↗
(url: URL, opts: any = {})

Source from the content-addressed store, hash-verified

7const STR = "string";
8
9const getRequestCode = (url: URL, opts: any = {}) => {
10 const method = opts.method || "GET";
11 let headers = "[]";
12
13 if (opts.headers instanceof Headers) {
14 const phpArray = [];
15 for (const pair of opts.headers.entries()) {
16 let key = pair[0].toLowerCase();
17 if (key !== "content_type") {
18 key = "http_" + key;
19 }
20
21 phpArray.push(`"${key}" => "${pair[1]}"`);
22 }
23
24 headers = `[${phpArray.join(", ")}]`;
25 }
26
27 return `(function() {
28 require './vendor/autoload.php';
29 if (!($guide = $_SERVER['APP_GUIDE'] ?? $_ENV['APP_GUIDE'] ?? null)) {
30 throw new \\RuntimeException('No guide.');
31 }
32 [$app, $args] = (new \\Symfony\\Component\\Runtime\\SymfonyRuntime(['disable_dotenv']))
33 ->getResolver(function (array $context) use ($guide) {
34 return new \\ApiPlatform\\Playground\\Kernel($context['APP_ENV'], (bool) $context['APP_DEBUG'], $guide);
35 })->resolve();
36 $app = $app(...$args);
37 return (string) $app->handle(\\Symfony\\Component\\HttpFoundation\\Request::create('${url.toString()}', '${method}', [], [], [], ${headers}));
38 })();`;
39};
40
41function phpFetch(url: URL, opts: any = {}) {
42 const spec = opts.ccall(

Callers 1

phpFetchFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected