Skip to content

Commit cd06194

Browse files
committed
Merge pull request #6 from Rafaelgfirmino/embedIcon
Embedded Git Icon
2 parents dda8493 + 4b47496 commit cd06194

File tree

7 files changed

+41
-5
lines changed

7 files changed

+41
-5
lines changed

DataCollector/GitDataCollector.php

+27-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
<?php
2-
32
namespace Kendrick\SymfonyDebugToolbarGit\DataCollector;
43

54
use Symfony\Component\HttpKernel\DataCollector\DataCollector;
@@ -19,9 +18,7 @@ class GitDataCollector extends DataCollector
1918
*/
2019
public function __construct($repositoryCommitUrl)
2120
{
22-
2321
$this->data['repositoryCommitUrl'] = $repositoryCommitUrl;
24-
2522
}
2623

2724
/**
@@ -300,4 +297,31 @@ public function getName()
300297

301298
}
302299

300+
/**
301+
* change the icon color depending on the kernel version
302+
*
303+
* #3f3f3f < 2.8
304+
* #AAAAAA >= 2.8
305+
*
306+
* @return string
307+
*/
308+
public final function getIconColor()
309+
{
310+
if ((float)$this->getSymfonyVersion() >= 2.8) {
311+
return $this->data['iconColor'] = '#AAAAAA';
312+
}
313+
return $this->data['iconColor'] = '#3F3F3F';
314+
}
315+
316+
/**
317+
* @return string
318+
*/
319+
private function getSymfonyVersion()
320+
{
321+
$symfonyVersion = \Symfony\Component\HttpKernel\Kernel::VERSION;
322+
$symfonyVersion = explode('.', $symfonyVersion, -1);
323+
$symfonyMajorMinorVersion = implode('.', $symfonyVersion);
324+
return $symfonyMajorMinorVersion;
325+
}
326+
303327
}

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ And visualize quickly the latest commit into your repository by clicking on the
1919

2020
Since release 1.4 : no icon (better integration for Symfony 2.8)
2121

22-
![SymfonyDebugToolbarGit2.8](symfony_toolbar_2-8.jpg "SymfonyDebugToolbarGit2.8")
22+
![SymfonyDebugToolbarGit2.8](symfony_toolbar_2-8.png "SymfonyDebugToolbarGit2.8")
2323

2424
Information displayed :
2525

Resources/views/Collector/git.html.twig

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<div class="sf-toolbar-icon">
88
<a href="#">
99
{# style needs this img #}
10-
<img width="0" height="28" style="width:0px;padding-top:0px;padding-bottom:0px;" src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7">
10+
{{ include("@SymfonyDebugToolbarGit/Icons/git.svg.twig") }}
1111
<span class="sf-toolbar-status sf-toolbar-status-green">{{ collector.branch }}</span>
1212
<span class="sf-toolbar-status sf-toolbar-status{%
1313
if collector.timeCommitIntervalMinutes <= 30%}-green{% elseif collector.timeCommitIntervalMinutes > 60 %}-red{% endif

Resources/views/Icons/git.svg.twig

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
2+
width="24px" height="28px" viewBox="0 0 97 97" enable-background="new 0 0 24 28" xml:space="preserve">
3+
<g>
4+
<path fill="{{ collector.iconColor }}" d="M92.71,44.408L52.591,4.291c-2.31-2.311-6.057-2.311-8.369,0l-8.33,8.332L46.459,23.19
5+
c2.456-0.83,5.272-0.273,7.229,1.685c1.969,1.97,2.521,4.81,1.67,7.275l10.186,10.185c2.465-0.85,5.307-0.3,7.275,1.671
6+
c2.75,2.75,2.75,7.206,0,9.958c-2.752,2.751-7.208,2.751-9.961,0c-2.068-2.07-2.58-5.11-1.531-7.658l-9.5-9.499v24.997
7+
c0.67,0.332,1.303,0.774,1.861,1.332c2.75,2.75,2.75,7.206,0,9.959c-2.75,2.749-7.209,2.749-9.957,0c-2.75-2.754-2.75-7.21,0-9.959
8+
c0.68-0.679,1.467-1.193,2.307-1.537V36.369c-0.84-0.344-1.625-0.853-2.307-1.537c-2.083-2.082-2.584-5.14-1.516-7.698
9+
L31.798,16.715L4.288,44.222c-2.311,2.313-2.311,6.06,0,8.371l40.121,40.118c2.31,2.311,6.056,2.311,8.369,0L92.71,52.779
10+
C95.021,50.468,95.021,46.719,92.71,44.408z"/>
11+
</g>
12+
</svg>

SymfonyDebugToolbarGit.png

7.09 KB
Loading

symfony_toolbar_2-8.jpg

-19.7 KB
Binary file not shown.

symfony_toolbar_2-8.png

11.5 KB
Loading

0 commit comments

Comments
 (0)