Skip to content

Commit

Permalink
fix: DebugBar initializes shared renderer instance
Browse files Browse the repository at this point in the history
A dev cannot create shared renderer instance.
  • Loading branch information
kenjis committed Jan 24, 2023
1 parent ad93e93 commit 0afa8a4
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions system/Debug/Toolbar/Collectors/Views.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ class Views extends BaseCollector
protected $title = 'Views';

/**
* Instance of the Renderer service
* Instance of the shared Renderer service
*
* @var RendererInterface
* @var RendererInterface|null
*/
protected $viewer;

Expand All @@ -73,12 +73,9 @@ class Views extends BaseCollector
*/
protected $views = [];

/**
* Constructor.
*/
public function __construct()
private function getViewer(): void
{
$this->viewer = Services::renderer();
$this->viewer ??= Services::renderer();
}

/**
Expand All @@ -87,6 +84,8 @@ public function __construct()
*/
protected function formatTimelineData(): array
{
$this->getViewer();

$data = [];

$rows = $this->viewer->getPerformanceData();
Expand Down Expand Up @@ -121,8 +120,9 @@ protected function formatTimelineData(): array
*/
public function getVarData(): array
{
return [
$this->getViewer();

return [
'View Data' => $this->viewer->getData(),
];
}
Expand All @@ -132,6 +132,8 @@ public function getVarData(): array
*/
public function getBadgeValue(): int
{
$this->getViewer();

return count($this->viewer->getPerformanceData());
}

Expand Down

0 comments on commit 0afa8a4

Please sign in to comment.