diff --git a/src/Symfony/Bundle/WebProfilerBundle/Resources/config/help.yml b/src/Symfony/Bundle/WebProfilerBundle/Resources/config/help.yml
new file mode 100644
index 0000000000000..c592aa7d4826b
--- /dev/null
+++ b/src/Symfony/Bundle/WebProfilerBundle/Resources/config/help.yml
@@ -0,0 +1,3 @@
+cookies:
+ Doc: 'https://symfony.com/doc/%s/components/http_foundation.html#setting-cookies'
+ API: 'http://api.symfony.com/%s/Symfony/Component/HttpFoundation/Cookie.html'
diff --git a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/request.html.twig b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/request.html.twig
index cdf2839c6dcd2..7a2bb9b4e5437 100644
--- a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/request.html.twig
+++ b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/request.html.twig
@@ -143,7 +143,7 @@
{{ include('@WebProfiler/Profiler/bag.html.twig', { bag: collector.requestattributes }, with_context = false) }}
{% endif %}
-
Cookies
+ Cookies
{% if collector.requestcookies.all is empty %}
diff --git a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/base_js.html.twig b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/base_js.html.twig
index ca69e371df281..0746d3e08e85b 100644
--- a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/base_js.html.twig
+++ b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/base_js.html.twig
@@ -491,6 +491,28 @@
toggle.innerHTML = currentContent !== altContent ? altContent : originalContent;
});
}
+ },
+
+ createHelp: function() {
+ var helps = document.querySelectorAll('[data-help]');
+
+ for (var i = 0; i < helps.length; i++) {
+ var root = document.createElement('div');
+ Sfjs.addClass(root, 'help');
+ var container = document.createElement('div');
+ root.appendChild(container);
+ helps[i].appendChild(root);
+
+ // Add links
+ var links = JSON.parse(helps[i].getAttribute('data-help'));
+ for (var key in links) {
+ var link = document.createElement('a');
+ link.textContent = key;
+ link.setAttribute('href', links[key]);
+ link.setAttribute('target', '_blank');
+ container.appendChild(link);
+ }
+ }
}
};
})();
@@ -499,6 +521,7 @@
Sfjs.createTabs();
Sfjs.createToggles();
Sfjs.renderAjaxRequests();
+ Sfjs.createHelp();
});
/*]]>*/
diff --git a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/profiler.css.twig b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/profiler.css.twig
index e3a0168553224..131d348f35fbf 100644
--- a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/profiler.css.twig
+++ b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/profiler.css.twig
@@ -994,3 +994,65 @@ table.logs .metadata {
margin-left: 2px;
}
}
+
+{# Help tooltip
+ ========================================================================= #}
+
+.help {
+ display: inline-block;
+ text-align: center;
+ background-color: #e0e0e0;
+ border-radius: 50%;
+ width: 21px;
+ height: 21px;
+ font-size: 13px;
+ line-height: 23px;
+ cursor: default;
+ margin: 0 5px;
+ vertical-align: middle;
+ border: 1px solid #c1c1c1;
+ text-shadow: 0 0 2px #444444;
+}
+
+.help:before {
+ content: '?';
+ font-weight: bold;
+ color: #fff;
+}
+
+.help:hover div {
+ display: block;
+}
+
+.help div {
+ display: none;
+ background-color: #e0e0e0;
+ padding: 8px;
+ width: auto;
+ position: absolute;
+ border-radius: 3px;
+ box-shadow: 1px 1px 1px rgba(0, 0, 0, 0.2);
+ border: 1px solid #444444;
+ color: #FFF;
+ font-size: 13px;
+ margin-top: 5px;
+ line-height: 1.4;
+}
+
+.help div:before {
+ position: absolute;
+ content: '';
+ width: 0;
+ height: 0;
+ border: 6px solid transparent;
+ border-bottom-color: #444444;
+ left: 4px;
+ top: -12px;
+}
+
+.help div a {
+ color: black;
+ padding: 0 5px;
+ text-shadow: none;
+ font-weight: bold;
+}
diff --git a/src/Symfony/Bundle/WebProfilerBundle/Twig/WebProfilerExtension.php b/src/Symfony/Bundle/WebProfilerBundle/Twig/WebProfilerExtension.php
index 032d6f08bbfb2..5656fdf734494 100644
--- a/src/Symfony/Bundle/WebProfilerBundle/Twig/WebProfilerExtension.php
+++ b/src/Symfony/Bundle/WebProfilerBundle/Twig/WebProfilerExtension.php
@@ -14,6 +14,8 @@
use Symfony\Component\HttpKernel\DataCollector\Util\ValueExporter;
use Symfony\Component\VarDumper\Cloner\Data;
use Symfony\Component\VarDumper\Dumper\HtmlDumper;
+use Symfony\Component\HttpKernel\Kernel;
+use Symfony\Component\Yaml\Yaml;
/**
* Twig extension for the profiler.
@@ -27,6 +29,11 @@ class WebProfilerExtension extends \Twig_Extension_Profiler
*/
private $valueExporter;
+ /**
+ * @var array
+ */
+ private $helpLinks;
+
/**
* @var HtmlDumper
*/
@@ -72,6 +79,7 @@ public function getFunctions()
return array(
new \Twig_SimpleFunction('profiler_dump', $profilerDump, array('is_safe' => array('html'), 'needs_environment' => true)),
new \Twig_SimpleFunction('profiler_dump_log', array($this, 'dumpLog'), array('is_safe' => array('html'), 'needs_environment' => true)),
+ new \Twig_SimpleFunction('help_attrs', array($this, 'help'), array('is_safe' => array('html'))),
);
}
@@ -120,6 +128,26 @@ public function dumpValue($value)
return $this->valueExporter->exportValue($value);
}
+ public function help($category)
+ {
+ if (!$this->helpLinks) {
+ $this->helpLinks = Yaml::parse(file_get_contents(__DIR__.'/../Resources/config/help.yml'));
+ }
+
+ if (!isset($this->helpLinks[$category])) {
+ throw new \Exception(sprintf('Help "%s" not found', $category));
+ }
+
+ $links = $this->helpLinks[$category];
+ array_walk($links, function (&$link) {
+ $link = sprintf($link, Kernel::MAJOR_VERSION.'.'.Kernel::MINOR_VERSION);
+ });
+
+ $html = 'data-help = "'.htmlspecialchars(json_encode($links, JSON_UNESCAPED_SLASHES)).'"';
+
+ return $html;
+ }
+
/**
* {@inheritdoc}
*/
diff --git a/src/Symfony/Bundle/WebProfilerBundle/composer.json b/src/Symfony/Bundle/WebProfilerBundle/composer.json
index 57656312bce8b..88eb63c5d299d 100644
--- a/src/Symfony/Bundle/WebProfilerBundle/composer.json
+++ b/src/Symfony/Bundle/WebProfilerBundle/composer.json
@@ -22,7 +22,8 @@
"symfony/routing": "~2.8|~3.0",
"symfony/twig-bridge": "~2.8|~3.0",
"twig/twig": "~1.28|~2.0",
- "symfony/var-dumper": "~3.2"
+ "symfony/var-dumper": "~3.2",
+ "symfony/yaml": "~2.8|~3.0"
},
"require-dev": {
"symfony/config": "~2.8|~3.0",