Skip to content

Commit a674d56

Browse files
authored
Merge pull request #68 from itk-dev/feature/show_advisories_on_site
Feature/show advisories on site
2 parents cbf3324 + a8a93f2 commit a674d56

4 files changed

Lines changed: 47 additions & 3 deletions

File tree

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
- [#68](https://github.com/itk-dev/devops_itksites/pull/68)
11+
6667: Update advisories on Detailed site display
12+
1013
## [1.9.2] - 2026-04-07
1114

1215
- [#67](https://github.com/itk-dev/devops_itksites/pull/67)

src/Admin/Field/AdvisoryCountField.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,6 @@ public static function new(string $propertyName, TranslatableInterface|string|bo
1919
->setLabel($label)
2020

2121
// this template is used in 'index' and 'detail' pages
22-
->setTemplatePath('EasyAdminBundle/Fields/advisory_count.html.twig');
22+
->setTemplatePath('EasyAdminBundle/Fields/advisories.html.twig');
2323
}
2424
}

src/Entity/Site.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,10 @@ public function setType(string $type): self
200200
return $this;
201201
}
202202

203-
public function getAdvisoryCount(): int
203+
/**
204+
* @return Collection<int, Advisory>
205+
*/
206+
public function getAdvisories(): Collection
204207
{
205208
$advisories = new ArrayCollection();
206209
foreach ($this->installation->getPackageVersions() as $packageVersion) {
@@ -209,6 +212,11 @@ public function getAdvisoryCount(): int
209212
}
210213
}
211214

212-
return $advisories->count();
215+
return $advisories;
216+
}
217+
218+
public function getAdvisoryCount(): int
219+
{
220+
return $this->getAdvisories()->count();
213221
}
214222
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{# @var ea \EasyCorp\Bundle\EasyAdminBundle\Context\AdminContext #}
2+
{# @var field \EasyCorp\Bundle\EasyAdminBundle\Dto\FieldDto #}
3+
{# @var entity \EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDto #}
4+
{% if ea().crud.currentAction == 'detail' %}
5+
{% set advisories = entity.instance.advisories %}
6+
{% if advisories|length > 0 %}
7+
<table class="table table-sm table-borderless">
8+
<thead>
9+
<tr>
10+
<th>Package</th>
11+
<th>CVE</th>
12+
<th>Title</th>
13+
</tr>
14+
</thead>
15+
<tbody>
16+
{% for advisory in advisories %}
17+
{% set url = ea_url()
18+
.unsetAll()
19+
.setController('App\\Controller\\Admin\\AdvisoryCrudController')
20+
.setAction('detail')
21+
.setEntityId(advisory.id) %}
22+
<tr>
23+
<td>{{ advisory.package }}</td>
24+
<td><a href="{{ url }}">{{ advisory.cve ?? advisory.advisoryId }}</a></td>
25+
<td>{{ advisory.title }}</td>
26+
</tr>
27+
{% endfor %}
28+
</tbody>
29+
</table>
30+
{% endif %}
31+
{% elseif field.formattedValue != 0 %}
32+
<span class="badge badge-danger">{{ field.formattedValue }}</span>
33+
{% endif %}

0 commit comments

Comments
 (0)