Skip to content

Commit cb2090e

Browse files
committed
Add extension to slugify client name for selectors
Update Changelog Rename extension from slugify to httplug_slugify Rename extension from slugify to httplug_slugify Rename extension from slugify to httplug_slugify
1 parent 852f7f9 commit cb2090e

File tree

4 files changed

+51
-5
lines changed

4 files changed

+51
-5
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33
The change log describes what is "Added", "Removed", "Changed" or "Fixed" between each release.
44

5+
## 1.14.1
6+
7+
### Fixed
8+
9+
- Profiler does not display stack when client name contains dots
10+
511
## 1.14.0
612

713
### Added
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?php
2+
3+
namespace Http\HttplugBundle\Collector\Twig;
4+
5+
/**
6+
* @author Ibrahima SOW <[email protected]>
7+
*/
8+
class HttpPlugSlugifyExtension extends \Twig_Extension
9+
{
10+
/**
11+
* {@inheritdoc}
12+
*
13+
* @return array
14+
*/
15+
public function getFilters()
16+
{
17+
return [
18+
new \Twig_SimpleFilter('httplug_slugify', [$this, 'slugify'], ['is_safe' => ['html']]),
19+
];
20+
}
21+
22+
/**
23+
* @param $string
24+
*
25+
* @return string
26+
*/
27+
public function slugify($string)
28+
{
29+
return preg_replace('/[^a-zA-Z0-9_-]/u', '_', $string);
30+
}
31+
32+
public function getName()
33+
{
34+
return 'httplug_slugify';
35+
}
36+
}

Resources/config/data-collector.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@
2626
<tag name="twig.extension" />
2727
</service>
2828

29+
<service id="httplug.collector.twig.httplug_slugify" class="Http\HttplugBundle\Collector\Twig\HttpPlugSlugifyExtension" public="false">
30+
<tag name="twig.extension" />
31+
</service>
32+
2933
<!-- Discovered clients -->
3034
<service id="httplug.collector.auto_discovered_client" class="Http\HttplugBundle\Collector\ProfileClient" decorates="httplug.auto_discovery.auto_discovered_client" public="false">
3135
<argument type="service" id="httplug.collector.auto_discovered_client.inner"/>

Resources/views/stack.html.twig

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<div class="httplug-stack-header httplug-toggle" data-toggle="#httplug-{{ client }}-{{ id }}-details">
1+
<div class="httplug-stack-header httplug-toggle" data-toggle="#httplug-{{ client|httplug_slugify }}-{{ id }}-details">
22
<div>
33
{% if stack.failed %}
44
<span class="httplug-stack-failed">✘</span>
@@ -23,14 +23,14 @@
2323
{% endif %}
2424
</div>
2525
</div>
26-
<div id="httplug-{{ client }}-{{ id }}-details" class="httplug-hidden">
26+
<div id="httplug-{{ client|httplug_slugify }}-{{ id }}-details" class="httplug-hidden">
2727
<div class="httplug-toolbar">
2828
<div class="httplug-copy-as-curl">
2929
<input readonly="readonly" type="text" value="{{ stack.curlCommand }}" />
3030
<button class="btn tooltip-toggle" aria-label="Copy to clipboard">Copy to clipboard</button>
3131
</div>
32-
<button data-toggle="#httplug-{{ client }}-{{ id }}-stack" class="httplug-toggle btn" >Toggle plugin stack</button>
33-
<button data-toggle="#httplug-{{ client }}-{{ id }}-details .httplug-http-body" class="httplug-toggle btn">Toggle body</button>
32+
<button data-toggle="#httplug-{{ client|httplug_slugify }}-{{ id }}-stack" class="httplug-toggle btn" >Toggle plugin stack</button>
33+
<button data-toggle="#httplug-{{ client|httplug_slugify }}-{{ id }}-details .httplug-http-body" class="httplug-toggle btn">Toggle body</button>
3434
</div>
3535
<div class="httplug-messages">
3636
<div class="httplug-message card">
@@ -43,7 +43,7 @@
4343
</div>
4444
</div>
4545
{% if stack.profiles %}
46-
<div id="httplug-{{ client }}-{{ id }}-stack" class="httplug-hidden card">
46+
<div id="httplug-{{ client|httplug_slugify }}-{{ id }}-stack" class="httplug-hidden card">
4747
{% for profile in stack.profiles %}
4848
<h3 class="httplug-plugin-name">{{ profile.plugin }}</h3>
4949
<div class="httplug-messages">

0 commit comments

Comments
 (0)