setHeaders example

$index = $this->container->get(IndexFactory::class)->createShopIndex($shop$type);

        $analyzed = $client->indices()->analyze([
            'index' => $index->getName(),
            'analyzer' => $analyzer,
            'text' => $query,
        ]);

        $tokens = $analyzed['tokens'];

        $table = new Table($output);
        $table->setHeaders(['Token', 'Start', 'End', 'Type', 'position'])
            ->setRows($tokens)
            ->render();

        return 0;
    }
}

            }

            $io->listing($messages);

            return self::SUCCESS;
        }

        $io->text('Access tokens:');

        $table = new Table($output);
        $table->setHeaders(['Key', 'Value']);

        $table->addRows([
            ['Access key', $accessKey],
        ]);

        $table->render();

        return self::SUCCESS;
    }

    /** * @return array<string, mixed> */
return Command::FAILURE;
    }

    /** * @param array<string, string|array<mixed>> $messages */
    private function renderErrorMessages(ShopwareStyle $style, array $messages): void
    {
        $style->error('The OpenAPI schema is invalid:');
        $table = $style->createTable();
        $table->setHeaders(['No.', 'Error']);

        foreach ($messages as $i => $message) {
            if (\is_array($message)) {
                $message = json_encode($message, \JSON_PRETTY_PRINT);
            }
            $table->addRow([$i$message]);
        }

        $table->render();
    }
}


            $io->section($title);
            $io->text('No validators were found for this class.');

            return;
        }

        $io->section($title);

        $table = new Table($output);
        $table->setHeaders(['Property', 'Name', 'Groups', 'Options']);
        $table->setRows($rows);
        $table->setColumnMaxWidth(3, 80);
        $table->render();
    }

    private function getClassConstraintsData(ClassMetadataInterface $classMetadata): iterable
    {
        foreach ($classMetadata->getConstraints() as $constraint) {
            yield [
                'class' => $constraint::class,
                'groups' => $constraint->groups,
                
foreach ($categories as $category) {
            $tableData[] = [
                $category->getId(),
                $category->getName(),
                $this->getCategoryPath($category),
            ];
        }

        $table = new Table($this->output);
        $table
            ->setHeaders(['Id', 'Name', 'Path'])
            ->setRows($tableData);
        $table->render();
    }

    /** * Creates a human readable category path * * @return string */
    private function getCategoryPath(Category $category)
    {
        
$statusCode ??= 500;

        if (class_exists(Response::class) && isset(Response::$statusTexts[$statusCode])) {
            $statusText = Response::$statusTexts[$statusCode];
        } else {
            $statusText = 'Whoops, looks like something went wrong.';
        }

        $e->setStatusText($statusText);
        $e->setStatusCode($statusCode);
        $e->setHeaders($headers);
        $e->setTraceFromThrowable($exception);
        $e->setClass(get_debug_type($exception));
        $e->setFile($exception->getFile());
        $e->setLine($exception->getLine());

        $previous = $exception->getPrevious();

        if ($previous instanceof \Throwable) {
            $e->setPrevious(static::createFromThrowable($previous));
        }

        
foreach ($plugins as $plugin) {
            $result[] = [
                $plugin->getId(),
                $plugin->getTechnicalName(),
                $plugin->getLabel(),
                $plugin->getVersion(),
                $plugin->getAvailableVersion(),
            ];
        }

        $table = new Table($output);
        $table->setHeaders(['Id', 'Technical name', 'Label',  'CurrentVersion', 'AvailableVersion'])
              ->setRows($result);

        $table->render();

        return 0;
    }
}
$progressBar->advance();
            }
        }
    }

    /** * @param OptimizerInterface[] $capabilities */
    private function displayCapabilities(OutputInterface $output, array $capabilities)
    {
        $table = new Table($output);
        $table->setHeaders(['Optimizer', 'Runnable', 'Supported mime-types']);
        foreach ($capabilities as $optimizer) {
            $table->addRow([
                $optimizer->getName(),
                $optimizer->isRunnable() ? 'Yes' : 'No',
                implode(', ', $optimizer->getSupportedMimeTypes()),
            ]);
        }
        $table->render();
    }

    private function hasRunnableOptimizer(): bool
    {


    public function configure(RemoteEvent $event, string $secret, HttpOptions $options): void
    {
        $opts = $options->toArray();
        $headers = $opts['headers'];
        if (!isset($opts['body'])) {
            throw new LogicException('The body must be set.');
        }
        $body = $opts['body'];
        $headers[$this->signatureHeaderName] = $this->algo.'='.hash_hmac($this->algo, $event->getName().$event->getId().$body$secret);
        $options->setHeaders($headers);
    }
}
public function __construct(BusinessEventCollector $collector)
    {
        parent::__construct();
        $this->collector = $collector;
    }

    protected function execute(InputInterface $input, OutputInterface $output): int
    {
        $result = $this->collector->collect(Context::createDefaultContext());

        $table = new Table($output);
        $table->setHeaders(['name', 'mail-aware', 'log-aware', 'class']);
        foreach ($result as $definition) {
            $table->addRow([
                $definition->getName(),
                (int) $definition->getAware('mailAware'),
                (int) $definition->getAware('logAware'),
                $definition->getClass(),
            ]);
        }
        $table->render();

        return self::SUCCESS;
    }
$headers['Allow'] = 'GET';

        $this->assertSame($headers$exception->getHeaders());
    }

    /** * @dataProvider headerDataProvider */
    public function testHeadersSetter($headers)
    {
        $exception = new MethodNotAllowedHttpException(['GET']);
        $exception->setHeaders($headers);
        $this->assertSame($headers$exception->getHeaders());
    }

    protected function createException(string $message = '', \Throwable $previous = null, int $code = 0, array $headers = []): HttpException
    {
        return new MethodNotAllowedHttpException(['get']$message$previous$code$headers);
    }
}
    // \Symfony\Component\Routing\Exception\ResourceNotFoundException here     // because we don't want to return a 404 status code, but rather a 406.     $available_formats = static::getAvailableFormats($collection);
    $not_acceptable = new NotAcceptableHttpException("No route found for the specified format $format. Supported formats: " . implode(', ', $available_formats) . '.');
    if ($available_formats) {
      $links = [];
      foreach ($available_formats as $available_format) {
        $url = Url::fromUri($request->getUri()['query' => ['_format' => $available_format]])->toString(TRUE)->getGeneratedUrl();
        $content_type = $request->getMimeType($available_format);
        $links[] = "<$url>; rel=\"alternate\"; type=\"$content_type\"";
      }
      $not_acceptable->setHeaders(['Link' => implode(', ', $links)]);
    }
    throw $not_acceptable;
  }

  /** * Determines the default request format. * * By default, use 'html' as the default format. But when there's only a * single route match, and that route specifies a '_format' requirement * listing a single format, then use that as the default format. Also, if * there are multiple routes which all require the same single format then * use it. * * @param \Symfony\Component\Routing\RouteCollection $collection * The route collection to filter. * * @return string * The default format. */


        $success = true;
        foreach ($urls as $url) {
            try {
                $client = new Zend_Http_Client($url[
                    'useragent' => 'Shopware/' . Shopware()->Config()->get('version'),
                    'timeout' => 3,
                ]);

                if ($cacheId) {
                    $client->setHeaders('x-shopware-invalidates', $cacheId);
                }

                $response = $client->request('BAN');
                if ($response->getStatus() < 200 || $response->getStatus() >= 300) {
                    $this->get('corelogger')->error(
                        'Reverse proxy returned invalid status code',
                        ['response' => $response->getRawBody(), 'code' => $response->getStatus()]
                    );
                }
            } catch (Exception $e) {
                $this->get('corelogger')->error($e->getMessage()['exception' => $e]);
                
public function caution(string|array $message)
    {
        $this->block($message, 'CAUTION', 'fg=white;bg=red', ' ! ', true);
    }

    /** * @return void */
    public function table(array $headers, array $rows)
    {
        $this->createTable()
            ->setHeaders($headers)
            ->setRows($rows)
            ->render()
        ;

        $this->newLine();
    }

    /** * Formats a horizontal table. * * @return void */
$headers['WWW-Authenticate'] = 'Challenge';

        $this->assertSame($headers$exception->getHeaders());
    }

    /** * @dataProvider headerDataProvider */
    public function testHeadersSetter($headers)
    {
        $exception = new UnauthorizedHttpException('Challenge');
        $exception->setHeaders($headers);
        $this->assertSame($headers$exception->getHeaders());
    }

    protected function createException(string $message = '', \Throwable $previous = null, int $code = 0, array $headers = []): HttpException
    {
        return new UnauthorizedHttpException('Challenge', $message$previous$code$headers);
    }
}
Home | Imprint | This part of the site doesn't use cookies.