Skip to content

Commit

Permalink
Merge branch '4.x' into develop
Browse files Browse the repository at this point in the history
# Conflicts:
#	CHANGELOG.md
#	src/helpers/DiagnosticsHelper.php
#	src/templates/_utilities/diagnostics/_components/elements.twig
  • Loading branch information
bencroker committed Jul 24, 2024
2 parents fd03b44 + ff3774d commit 61bde02
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 7 deletions.
19 changes: 19 additions & 0 deletions src/helpers/DiagnosticsHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@
use craft\db\Table;
use craft\elements\GlobalSet;
use craft\helpers\ArrayHelper;
use craft\helpers\Cp;
use craft\helpers\DateTimeHelper;
use craft\helpers\Db;
use craft\helpers\Json;
use craft\helpers\Template;
use craft\helpers\UrlHelper;
use DateTime;
use putyourlightson\blitz\Blitz;
Expand All @@ -30,6 +32,7 @@
use putyourlightson\blitz\records\ElementQueryRecord;
use putyourlightson\blitz\records\IncludeRecord;
use putyourlightson\blitz\services\CacheRequestService;
use Twig\Markup;
use yii\db\ActiveRecordInterface;
use yii\db\Expression;

Expand Down Expand Up @@ -316,6 +319,22 @@ public static function getElementsFromIds(int $siteId, string $elementType, arra
->all();
}

public static function getElementChip(Element $element, ?string $uri = null): Markup
{
$value = Cp::elementChipHtml($element);

if ($uri !== null) {
$url = UrlHelper::cpUrl($uri, [
'siteId' => $element->siteId,
'elementId' => $element->id,
'elementType' => $element::class,
]);
$value = str_replace($element->getCpEditUrl(), $url, $value);
}

return Template::raw($value);
}

public static function getPageTags(int $cacheId): array
{
$tags = CacheTagRecord::find()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,7 @@
{% if element %}
<tr>
<td>
{{ elementChip(element)|replace({
(element.cpEditUrl): url('blitz/diagnostics/elements/pages-includes', {
siteId: siteId,
elementId: element.id,
elementType: elementType,
})
})|raw }}
{{ craft.blitz.diagnostics.getElementChip(element, 'blitz/diagnostics/elements/pages-includes') }}
</td>
{% if cacheId is defined %}
<td>
Expand Down

0 comments on commit 61bde02

Please sign in to comment.