mirror of
https://github.com/symfony/web-profiler-bundle.git
synced 2026-03-24 00:02:13 +01:00
[WebProfilerBundle] Use CPP
This commit is contained in:
@@ -25,13 +25,10 @@ use Symfony\Component\HttpKernel\Profiler\Profiler;
|
||||
*/
|
||||
class ExceptionPanelController
|
||||
{
|
||||
private HtmlErrorRenderer $errorRenderer;
|
||||
private ?Profiler $profiler;
|
||||
|
||||
public function __construct(HtmlErrorRenderer $errorRenderer, ?Profiler $profiler = null)
|
||||
{
|
||||
$this->errorRenderer = $errorRenderer;
|
||||
$this->profiler = $profiler;
|
||||
public function __construct(
|
||||
private HtmlErrorRenderer $errorRenderer,
|
||||
private ?Profiler $profiler = null,
|
||||
) {
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -34,21 +34,15 @@ use Twig\Environment;
|
||||
class ProfilerController
|
||||
{
|
||||
private TemplateManager $templateManager;
|
||||
private UrlGeneratorInterface $generator;
|
||||
private ?Profiler $profiler;
|
||||
private Environment $twig;
|
||||
private array $templates;
|
||||
private ?ContentSecurityPolicyHandler $cspHandler;
|
||||
private ?string $baseDir;
|
||||
|
||||
public function __construct(UrlGeneratorInterface $generator, ?Profiler $profiler, Environment $twig, array $templates, ?ContentSecurityPolicyHandler $cspHandler = null, ?string $baseDir = null)
|
||||
{
|
||||
$this->generator = $generator;
|
||||
$this->profiler = $profiler;
|
||||
$this->twig = $twig;
|
||||
$this->templates = $templates;
|
||||
$this->cspHandler = $cspHandler;
|
||||
$this->baseDir = $baseDir;
|
||||
public function __construct(
|
||||
private UrlGeneratorInterface $generator,
|
||||
private ?Profiler $profiler,
|
||||
private Environment $twig,
|
||||
private array $templates,
|
||||
private ?ContentSecurityPolicyHandler $cspHandler = null,
|
||||
private ?string $baseDir = null,
|
||||
) {
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -30,23 +30,19 @@ use Twig\Environment;
|
||||
*/
|
||||
class RouterController
|
||||
{
|
||||
private ?Profiler $profiler;
|
||||
private Environment $twig;
|
||||
private ?UrlMatcherInterface $matcher;
|
||||
private ?RouteCollection $routes;
|
||||
|
||||
/**
|
||||
* @var ExpressionFunctionProviderInterface[]
|
||||
* @param ExpressionFunctionProviderInterface[] $expressionLanguageProviders
|
||||
*/
|
||||
private iterable $expressionLanguageProviders;
|
||||
|
||||
public function __construct(?Profiler $profiler, Environment $twig, ?UrlMatcherInterface $matcher = null, ?RouteCollection $routes = null, iterable $expressionLanguageProviders = [])
|
||||
{
|
||||
$this->profiler = $profiler;
|
||||
$this->twig = $twig;
|
||||
$this->matcher = $matcher;
|
||||
$this->routes = (null === $routes && $matcher instanceof RouterInterface) ? $matcher->getRouteCollection() : $routes;
|
||||
$this->expressionLanguageProviders = $expressionLanguageProviders;
|
||||
public function __construct(
|
||||
private ?Profiler $profiler,
|
||||
private Environment $twig,
|
||||
private ?UrlMatcherInterface $matcher = null,
|
||||
private ?RouteCollection $routes = null,
|
||||
private iterable $expressionLanguageProviders = [],
|
||||
) {
|
||||
if ($this->matcher instanceof RouterInterface) {
|
||||
$this->routes ??= $this->matcher->getRouteCollection();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -23,12 +23,11 @@ use Symfony\Component\HttpFoundation\Response;
|
||||
*/
|
||||
class ContentSecurityPolicyHandler
|
||||
{
|
||||
private NonceGenerator $nonceGenerator;
|
||||
private bool $cspDisabled = false;
|
||||
|
||||
public function __construct(NonceGenerator $nonceGenerator)
|
||||
{
|
||||
$this->nonceGenerator = $nonceGenerator;
|
||||
public function __construct(
|
||||
private NonceGenerator $nonceGenerator,
|
||||
) {
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -124,10 +123,10 @@ class ContentSecurityPolicyHandler
|
||||
$headers = $this->getCspHeaders($response);
|
||||
|
||||
$types = [
|
||||
'script-src' => 'csp_script_nonce',
|
||||
'script-src-elem' => 'csp_script_nonce',
|
||||
'style-src' => 'csp_style_nonce',
|
||||
'style-src-elem' => 'csp_style_nonce',
|
||||
'script-src' => 'csp_script_nonce',
|
||||
'script-src-elem' => 'csp_script_nonce',
|
||||
'style-src' => 'csp_style_nonce',
|
||||
'style-src-elem' => 'csp_style_nonce',
|
||||
];
|
||||
|
||||
foreach ($headers as $header => $directives) {
|
||||
|
||||
@@ -40,23 +40,15 @@ class WebDebugToolbarListener implements EventSubscriberInterface
|
||||
public const DISABLED = 1;
|
||||
public const ENABLED = 2;
|
||||
|
||||
private Environment $twig;
|
||||
private ?UrlGeneratorInterface $urlGenerator;
|
||||
private bool $interceptRedirects;
|
||||
private int $mode;
|
||||
private string $excludedAjaxPaths;
|
||||
private ?ContentSecurityPolicyHandler $cspHandler;
|
||||
private ?DumpDataCollector $dumpDataCollector;
|
||||
|
||||
public function __construct(Environment $twig, bool $interceptRedirects = false, int $mode = self::ENABLED, ?UrlGeneratorInterface $urlGenerator = null, string $excludedAjaxPaths = '^/bundles|^/_wdt', ?ContentSecurityPolicyHandler $cspHandler = null, ?DumpDataCollector $dumpDataCollector = null)
|
||||
{
|
||||
$this->twig = $twig;
|
||||
$this->urlGenerator = $urlGenerator;
|
||||
$this->interceptRedirects = $interceptRedirects;
|
||||
$this->mode = $mode;
|
||||
$this->excludedAjaxPaths = $excludedAjaxPaths;
|
||||
$this->cspHandler = $cspHandler;
|
||||
$this->dumpDataCollector = $dumpDataCollector;
|
||||
public function __construct(
|
||||
private Environment $twig,
|
||||
private bool $interceptRedirects = false,
|
||||
private int $mode = self::ENABLED,
|
||||
private ?UrlGeneratorInterface $urlGenerator = null,
|
||||
private string $excludedAjaxPaths = '^/bundles|^/_wdt',
|
||||
private ?ContentSecurityPolicyHandler $cspHandler = null,
|
||||
private ?DumpDataCollector $dumpDataCollector = null,
|
||||
) {
|
||||
}
|
||||
|
||||
public function isEnabled(): bool
|
||||
|
||||
@@ -26,14 +26,14 @@ use Twig\TwigFilter;
|
||||
final class CodeExtension extends AbstractExtension
|
||||
{
|
||||
private string|FileLinkFormatter|array|false $fileLinkFormat;
|
||||
private string $charset;
|
||||
private string $projectDir;
|
||||
|
||||
public function __construct(string|FileLinkFormatter $fileLinkFormat, string $projectDir, string $charset)
|
||||
{
|
||||
public function __construct(
|
||||
string|FileLinkFormatter $fileLinkFormat,
|
||||
private string $projectDir,
|
||||
private string $charset,
|
||||
) {
|
||||
$this->fileLinkFormat = $fileLinkFormat ?: \ini_get('xdebug.file_link_format') ?: get_cfg_var('xdebug.file_link_format');
|
||||
$this->projectDir = str_replace('\\', '/', $projectDir).'/';
|
||||
$this->charset = $charset;
|
||||
}
|
||||
|
||||
public function getFilters(): array
|
||||
|
||||
@@ -24,15 +24,11 @@ use Twig\Environment;
|
||||
*/
|
||||
class TemplateManager
|
||||
{
|
||||
protected Environment $twig;
|
||||
protected array $templates;
|
||||
protected Profiler $profiler;
|
||||
|
||||
public function __construct(Profiler $profiler, Environment $twig, array $templates)
|
||||
{
|
||||
$this->profiler = $profiler;
|
||||
$this->twig = $twig;
|
||||
$this->templates = $templates;
|
||||
public function __construct(
|
||||
protected Profiler $profiler,
|
||||
protected Environment $twig,
|
||||
protected array $templates,
|
||||
) {
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -179,11 +179,11 @@ class WebProfilerExtensionTest extends TestCase
|
||||
public static function getInterceptRedirectsToolbarConfig()
|
||||
{
|
||||
return [
|
||||
[
|
||||
'toolbarEnabled' => false,
|
||||
'interceptRedirects' => true,
|
||||
'listenerInjected' => true,
|
||||
'listenerEnabled' => false,
|
||||
[
|
||||
'toolbarEnabled' => false,
|
||||
'interceptRedirects' => true,
|
||||
'listenerInjected' => true,
|
||||
'listenerEnabled' => false,
|
||||
],
|
||||
[
|
||||
'toolbarEnabled' => false,
|
||||
|
||||
Reference in New Issue
Block a user