Skip to content

Commit

Permalink
feature #608 Improved the Profiler Panel contents (javiereguiluz)
Browse files Browse the repository at this point in the history
This PR was squashed before being merged into the master branch (closes #608).

Discussion
----------

Improved the Profiler Panel contents

### Before

![before](https://cloud.githubusercontent.com/assets/73419/11458946/3db75cf6-96cb-11e5-9ab4-afe1642b7c91.png)

### After

![after_1](https://cloud.githubusercontent.com/assets/73419/11458947/414199d6-96cb-11e5-8638-f2c4d3e73b77.png)

![after_2](https://cloud.githubusercontent.com/assets/73419/11458948/4389d15e-96cb-11e5-8550-9d483a451432.png)

Commits
-------

902f25a Improved the Profiler Panel contents
  • Loading branch information
javiereguiluz committed Nov 29, 2015
2 parents e8f1f60 + 902f25a commit df17628
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 4 deletions.
37 changes: 33 additions & 4 deletions Resources/views/data_collector/easyadmin.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,11 @@

{% endif %}

<div class="tabs">
<div class="sf-tabs">
<div class="tab">
<h3 class="tab-title">Entity Configuration</h3>
<h3 class="tab-title">Current Entity Configuration</h3>
<div class="tab-content">
<pre class="sf-dump" style="{{ profiler_markup_version == 1 ? '' : 'color: #E0E0E0"' }}">{{ collector.currentEntityConfiguration|yaml_dump(3, false)|replace({ '%array% ' : '' }) }}</pre>
{{ easyadmin_dump(collector.currentEntityConfiguration) }}
</div>

<br>
Expand All @@ -84,7 +84,36 @@
<div class="tab">
<h3 class="tab-title">Full Backend Configuration</h3>
<div class="tab-content">
<pre class="sf-dump" style="{{ profiler_markup_version == 1 ? '' : 'color: #E0E0E0"' }}">{{ collector.backendConfiguration|yaml_dump(5, false)|replace({ '%array% ' : '' }) }}</pre>

<h4>Basic Configuration</h4>
{{ easyadmin_dump({
'site_name': collector.backendConfiguration['site_name'],
'formats': collector.backendConfiguration['formats']
}) }}

<h4>Design Configuration</h4>
{{ easyadmin_dump({
'design': collector.backendConfiguration['design']
}) }}

<h4>Actions Configuration</h4>
{{ easyadmin_dump({
'disabled_actions': collector.backendConfiguration['disabled_actions'],
'list': collector.backendConfiguration['list'],
'edit': collector.backendConfiguration['edit'],
'new': collector.backendConfiguration['new'],
'show': collector.backendConfiguration['show'],
}) }}

<h4>Entities Configuration</h4>
{{ easyadmin_dump({
'entities': collector.backendConfiguration['entities']
}) }}

<h4>Full Backend Configuration</h4>
{{ easyadmin_dump({
'easy_admin': collector.backendConfiguration
}) }}
</div>
</div>
</div>
Expand Down
28 changes: 28 additions & 0 deletions Twig/EasyAdminTwigExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@

use Doctrine\ORM\PersistentCollection;
use JavierEguiluz\Bundle\EasyAdminBundle\Configuration\Configurator;
use Symfony\Component\VarDumper\Cloner\VarCloner;
use Symfony\Component\VarDumper\Dumper\HtmlDumper;
use Symfony\Component\Yaml\Yaml;

/**
* Defines the filters and functions used to render the bundle's templates.
Expand All @@ -39,6 +42,7 @@ public function getFunctions()
new \Twig_SimpleFunction('easyadmin_action_is_enabled_for_*_view', array($this, 'isActionEnabled')),
new \Twig_SimpleFunction('easyadmin_get_action_for_*_view', array($this, 'getActionConfiguration')),
new \Twig_SimpleFunction('easyadmin_get_actions_for_*_item', array($this, 'getActionsForItem')),
new \Twig_SimpleFunction('easyadmin_dump', array($this, 'dump'), array('is_safe' => array('html'))),
);
}

Expand Down Expand Up @@ -247,6 +251,30 @@ public function getActionsForItem($view, $entityName)
});
}

/**
* It dumps the contents of the given variable using the VarDumper component
* (this avoids requiring the DebugBundle which defines the dump() Twig function).
* It fallbacks to Yaml dumper or var_export() if VarDumper component is not
* available.
*
* @param mixed $variable
*
* @return string
*/
public function dump($variable)
{
if (class_exists('Symfony\Component\VarDumper\Dumper\HtmlDumper')) {
$cloner = new VarCloner();
$dumper = new HtmlDumper();

return $dumper->dump($cloner->cloneVar($variable));
} elseif (class_exists('Symfony\Component\Yaml\Yaml')) {
return sprintf('<pre class="sf-dump">%s</pre>', Yaml::dump((array) $variable, 1024));
} else {
return sprintf('<pre class="sf-dump">%s</pre>', var_export($variable, true));
}
}

/*
* Copied from the official Text Twig extension.
*
Expand Down

0 comments on commit df17628

Please sign in to comment.