Skip to content

Commit

Permalink
Minor enhancement to components tab
Browse files Browse the repository at this point in the history
Refs #48
  • Loading branch information
daftspunk committed Dec 15, 2021
1 parent 703f376 commit c692d4e
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 5 deletions.
4 changes: 3 additions & 1 deletion datacollectors/OctoberBackendCollector.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@ class OctoberBackendCollector extends DataCollector implements Renderable
{
/** @var Controller */
protected $controller;

/** @var string */
protected $action;
/** @var array */

/** @var array */
protected $params;

public function __construct(Controller $controller, $action, array $params = [])
Expand Down
4 changes: 3 additions & 1 deletion datacollectors/OctoberCmsCollector.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@ class OctoberCmsCollector extends DataCollector implements Renderable
{
/** @var Controller */
protected $controller;

/** @var string */
protected $url;
/** @var array */

/** @var Page */
protected $page;

public function __construct(Controller $controller, $url, Page $page)
Expand Down
17 changes: 14 additions & 3 deletions datacollectors/OctoberComponentsCollector.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,27 @@ public function collect()
$components = [];

foreach ($this->layout->components as $alias => $componentObj) {
$components[$alias] = get_class($componentObj);
$components[$alias] = $this->formatVar($this->makeComponentDetails($componentObj));
}

foreach ($this->page->components as $alias => $componentObj) {
$components[$alias] = get_class($componentObj);
$components[$alias] = $this->formatVar($this->makeComponentDetails($componentObj));
}

return $components;
}

/**
* makeComponentDetails builds a useful array to describe a component
*/
protected function makeComponentDetails($componentObj): array
{
return [
'class' => get_class($componentObj),
'props' => $componentObj->getProperties()
];
}

/**
* {@inheritDoc}
*/
Expand All @@ -61,7 +72,7 @@ public function getWidgets()
{
return [
"components" => [
"icon" => "blocks",
"icon" => "puzzle-piece",
"widget" => "PhpDebugBar.Widgets.VariableListWidget",
"map" => "components",
"default" => "{}"
Expand Down

0 comments on commit c692d4e

Please sign in to comment.