Created
June 17, 2025 06:53
-
-
Save jmsche/cd2d12e044e681b9ef76b34f5a41ff1e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| {% extends '@WebProfiler/Profiler/layout.html.twig' %} | |
| {% block toolbar %} | |
| {% set icon %} | |
| {{ include('data_collector/icon.svg') }} | |
| <span class="sf-toolbar-value">{{ collector.gitBranch }}</span> | |
| {% endset %} | |
| {% set text %} | |
| <div class="sf-toolbar-info-piece"> | |
| <b>Last commit</b> | |
| <span>{{ collector.lastCommitDate }}</span> | |
| </div> | |
| <div class="sf-toolbar-info-piece"> | |
| <b>Author</b> | |
| <span>{{ collector.lastCommitAuthor }}</span> | |
| </div> | |
| <div class="sf-toolbar-info-piece"> | |
| <b>Message</b> | |
| <span style="text-overflow: ellipsis; line-height: 15px; max-width: 400px; overflow: hidden; vertical-align: bottom;">{{ collector.lastCommitMessage }}</span> | |
| </div> | |
| {% endset %} | |
| {{ include('@WebProfiler/Profiler/toolbar_item.html.twig', { link: false }) }} | |
| {% endblock %} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| declare(strict_types=1); | |
| namespace App\DataCollector; | |
| use App\Base\Core\Manager\GitManager; | |
| use Symfony\Component\DependencyInjection\Attribute\AutoconfigureTag; | |
| use Symfony\Component\HttpFoundation\Request; | |
| use Symfony\Component\HttpFoundation\Response; | |
| use Symfony\Component\HttpKernel\DataCollector\DataCollector; | |
| #[AutoconfigureTag('data_collector', ['template' => 'data_collector/git_data.html.twig', 'id' => 'app.git_data_collector'])] | |
| final class GitDataCollector extends DataCollector | |
| { | |
| public function __construct(private GitManager $gitManager) | |
| { | |
| } | |
| public function collect(Request $request, Response $response, \Throwable $exception = null): void | |
| { | |
| $this->data = [ | |
| 'git_branch' => $this->gitManager->getBranchName(), | |
| 'last_commit_message' => $this->gitManager->getLastCommitMessage(), | |
| 'logs' => $this->gitManager->getLastCommitDetail(), | |
| ]; | |
| } | |
| public function getName(): string | |
| { | |
| return 'app.git_data_collector'; | |
| } | |
| public function reset(): void | |
| { | |
| $this->data = []; | |
| } | |
| public function getGitBranch(): string | |
| { | |
| return $this->data['git_branch']; | |
| } | |
| public function getLastCommitMessage(): string | |
| { | |
| return $this->data['last_commit_message']; | |
| } | |
| public function getLastCommitAuthor(): string | |
| { | |
| return $this->data['logs']['author']; | |
| } | |
| public function getLastCommitDate(): string | |
| { | |
| return $this->data['logs']['date']; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment