Skip to content

Commit

Permalink
Make ok() usage use Templating with BC.
Browse files Browse the repository at this point in the history
  • Loading branch information
dereuromark committed Mar 11, 2024
1 parent 0ee9d56 commit 6081db1
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 2 deletions.
4 changes: 4 additions & 0 deletions src/Controller/Admin/LoadHelperTrait.php
Expand Up @@ -5,6 +5,7 @@

use Templating\View\Helper\IconHelper;
use Templating\View\Helper\IconSnippetHelper;
use Templating\View\Helper\TemplatingHelper;

trait LoadHelperTrait {

Expand All @@ -22,6 +23,9 @@ class_exists(IconHelper::class) ? 'Templating.Icon' : 'Tools.Icon',
if (class_exists(IconSnippetHelper::class)) {
$helpers[] = 'Templating.IconSnippet';
}
if (class_exists(TemplatingHelper::class)) {
$helpers[] = 'Templating.Templating';
}

$this->viewBuilder()->addHelpers($helpers);
}
Expand Down
2 changes: 1 addition & 1 deletion templates/Admin/QueuedJobs/index.php
Expand Up @@ -98,7 +98,7 @@
</div>
<?php } ?>
</td>
<td><?= $this->Format->ok($this->Queue->attempts($queuedJob), $queuedJob->completed || $queuedJob->attempts < 1); ?></td>
<td><?= $this->element('Queue.ok', ['value' => $this->Queue->attempts($queuedJob), 'ok' => $queuedJob->completed || $queuedJob->attempts < 1]); ?></td>
<td>
<?= h($queuedJob->status) ?>
<?php if (!$queuedJob->completed && $queuedJob->fetched) { ?>
Expand Down
2 changes: 1 addition & 1 deletion templates/Admin/QueuedJobs/view.php
Expand Up @@ -99,7 +99,7 @@
<tr>
<th><?= __d('queue', 'Attempts') ?></th>
<td>
<?= $queuedJob->attempts ? $this->Format->ok($this->Queue->attempts($queuedJob), $queuedJob->completed || $queuedJob->attempts < 1) : '' ?>
<?= $queuedJob->attempts ? $this->element('Queue.ok', ['value' => $this->Queue->attempts($queuedJob), 'ok' => $queuedJob->completed || $queuedJob->attempts < 1]) : '' ?>
<?php
if ($this->Queue->hasFailed($queuedJob)) {
echo ' ' . $this->Form->postLink(__d('queue', 'Soft reset'), ['controller' => 'Queue', 'action' => 'resetJob', $queuedJob->id], ['confirm' => 'Sure?', 'class' => 'button button-primary btn margin btn-primary']);
Expand Down
18 changes: 18 additions & 0 deletions templates/element/ok.php
@@ -0,0 +1,18 @@
<?php
/**
* Overwrite this element snippet locally to customize if needed.
*
* @var \App\View\AppView $this
* @var string $value
* @var bool $ok
*/
?>
<?php
if ($this->helpers()->has('Templating')) {
echo $this->Templating->ok($value, $ok);
} elseif ($this->helpers()->has('Format')) {
echo $this->Format->ok($value, $ok);
} else {
echo $ok ? '<span class="yes-no yes-no-yes">' . h($value) . '</span>' : '<span class="yes-no yes-no-no">' . h($value) . '</span>';
}
?>

0 comments on commit 6081db1

Please sign in to comment.