Skip to content

Commit

Permalink
removed Engine::$probe
Browse files Browse the repository at this point in the history
  • Loading branch information
dg committed Nov 4, 2022
1 parent 5df5d1d commit 38039d8
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 10 deletions.
16 changes: 13 additions & 3 deletions src/Bridges/Tracy/LattePanel.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
namespace Latte\Bridges\Tracy;

use Latte\Engine;
use Latte\Extension;
use Latte\Runtime\Template;
use Tracy;

Expand Down Expand Up @@ -37,9 +38,18 @@ public static function initialize(Engine $latte, ?string $name = null, ?Tracy\Ba
public function __construct(Engine $latte, ?string $name = null)
{
$this->name = $name;
$latte->probe = function (Template $template): void {
$this->templates[] = $template;
};
$latte->addExtension(new class ($this->templates) extends Extension {
public function __construct(
private array &$templates,
) {
}


public function beforeRender(Template $template): void
{
$this->templates[] = $template;
}
});
}


Expand Down
6 changes: 0 additions & 6 deletions src/Latte/Engine.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,6 @@ class Engine
CONTENT_ICAL = ContentType::ICal,
CONTENT_TEXT = ContentType::Text;

/** @internal */
public $probe;

private ?Loader $loader = null;
private Runtime\FilterExecutor $filters;
private \stdClass $functions;
Expand All @@ -54,7 +51,6 @@ public function __construct()
$this->filters = new Runtime\FilterExecutor;
$this->functions = new \stdClass;
$this->providers = new \stdClass;
$this->probe = function () {};
$this->addExtension(new Essential\CoreExtension);
$this->addExtension(new Sandbox\SandboxExtension);
}
Expand All @@ -68,7 +64,6 @@ public function render(string $name, object|array $params = [], ?string $block =
{
$template = $this->createTemplate($name, $this->processParams($params));
$template->global->coreCaptured = false;
($this->probe)($template);
$template->render($block);
}

Expand All @@ -81,7 +76,6 @@ public function renderToString(string $name, object|array $params = [], ?string
{
$template = $this->createTemplate($name, $this->processParams($params));
$template->global->coreCaptured = true;
($this->probe)($template);
return $template->capture(fn() => $template->render($block));
}

Expand Down
1 change: 0 additions & 1 deletion src/Latte/Runtime/Template.php
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,6 @@ public function createTemplate(string $name, array $params, string $referenceTyp
$referred->blocks[self::LayerSnippet] = &$this->blocks[self::LayerSnippet];
}

($this->engine->probe)($referred);
return $referred;
}

Expand Down

0 comments on commit 38039d8

Please sign in to comment.