Skip to content

Commit 59c15fd

Browse files
committed
Rename tpl method
1 parent d07dfc3 commit 59c15fd

4 files changed

Lines changed: 8 additions & 9 deletions

File tree

index.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212

1313
use RobiNN\Pca\Admin;
1414
use RobiNN\Pca\Config;
15-
use RobiNN\Pca\Helpers;
1615
use RobiNN\Pca\Http;
1716
use RobiNN\Pca\Template;
1817

@@ -54,8 +53,8 @@
5453
$dashboard = $admin->getDashboard($current);
5554
$info = $dashboard->getDashboardInfo();
5655

57-
$tpl->addTplGlobal('current', $current);
58-
$tpl->addTplGlobal('color', $info['color']);
56+
$tpl->addGlobal('current', $current);
57+
$tpl->addGlobal('color', $info['color']);
5958

6059
if (isset($_GET['ajax'])) {
6160
echo $dashboard->ajax();

src/Dashboards/Redis/RedisTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ private function getAllKeys(Redis $redis): array {
213213
$filter = Http::get('s');
214214
$filter = !empty($filter) ? $filter : '*';
215215

216-
$this->template->addTplGlobal('search_value', $filter);
216+
$this->template->addGlobal('search_value', $filter);
217217

218218
foreach ($redis->keys($filter) as $key) {
219219
$type = $this->getType($redis->type($key));

src/Helpers.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ public static function svg(string $icon, ?int $size = 16, ?string $class = null)
202202
* @return void
203203
*/
204204
public static function alert(Template $template, string $message, ?string $color = null): void {
205-
$template->addTplGlobal('alerts', $template->render('components/alert', [
205+
$template->addGlobal('alerts', $template->render('components/alert', [
206206
'message' => $message,
207207
'alert_color' => $color,
208208
]));

src/Template.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class Template {
2323
/**
2424
* @var array<string, mixed>
2525
*/
26-
private array $tpl_globals = [];
26+
private array $globals = [];
2727

2828
/**
2929
* Add global template variable.
@@ -33,8 +33,8 @@ class Template {
3333
*
3434
* @return void
3535
*/
36-
public function addTplGlobal(string $name, $value): void {
37-
$this->tpl_globals[$name] = $value;
36+
public function addGlobal(string $name, $value): void {
37+
$this->globals[$name] = $value;
3838
}
3939

4040
/**
@@ -61,7 +61,7 @@ public function render(string $tpl, array $data = []): string {
6161

6262
$twig->addFilter(new TwigFilter('space', fn (?string $value): string => !empty($value) ? ' '.$value : '', ['is_safe' => ['html']]));
6363

64-
foreach ($this->tpl_globals as $name => $value) {
64+
foreach ($this->globals as $name => $value) {
6565
$twig->addGlobal($name, $value);
6666
}
6767

0 commit comments

Comments
 (0)