File tree Expand file tree Collapse file tree
templates/EasyAdminBundle/Fields Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -10,6 +10,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1010- [ #68 ] ( https://github.com/itk-dev/devops_itksites/pull/68 )
1111 6667: Update advisories on Detailed site display
1212
13+ - [ #68 ] ( https://github.com/itk-dev/devops_itksites/pull/68 )
14+ 6667: Show sites affected on advisories.
15+
1316## [ 1.9.2] - 2026-04-07
1417
1518- [ #67 ] ( https://github.com/itk-dev/devops_itksites/pull/67 )
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ declare (strict_types=1 );
4+
5+ namespace App \Admin \Field ;
6+
7+ use EasyCorp \Bundle \EasyAdminBundle \Contracts \Field \FieldInterface ;
8+ use EasyCorp \Bundle \EasyAdminBundle \Field \FieldTrait ;
9+ use Symfony \Contracts \Translation \TranslatableInterface ;
10+
11+ class AffectedSitesField implements FieldInterface
12+ {
13+ use FieldTrait;
14+
15+ public static function new (string $ propertyName , TranslatableInterface |string |bool |null $ label = null ): self
16+ {
17+ return new self ()
18+ ->setProperty ($ propertyName )
19+ ->setLabel ($ label )
20+ ->setTemplatePath ('EasyAdminBundle/Fields/affected_sites.html.twig ' );
21+ }
22+ }
Original file line number Diff line number Diff line change 44
55namespace App \Controller \Admin ;
66
7+ use App \Admin \Field \AffectedSitesField ;
78use App \Admin \Field \SourcesField ;
89use App \Admin \Field \TextMonospaceField ;
910use App \Entity \Advisory ;
@@ -58,6 +59,7 @@ public function configureFields(string $pageName): iterable
5859 yield DateField::new ('reportedAt ' )->setColumns (6 )->onlyOnIndex ();
5960 yield DateTimeField::new ('reportedAt ' )->setColumns (6 )->onlyOnDetail ();
6061 yield SourcesField::new ('sourceLinks ' )->setColumns (6 )->onlyOnDetail ();
62+ yield AffectedSitesField::new ('sites ' )->setLabel ('Affected Sites ' );
6163 }
6264
6365 #[\Override]
Original file line number Diff line number Diff line change @@ -190,6 +190,23 @@ public function removePackageVersion(PackageVersion $packageVersion): self
190190 return $ this ;
191191 }
192192
193+ /**
194+ * @return Collection<int, Site>
195+ */
196+ public function getSites (): Collection
197+ {
198+ $ sites = [];
199+ foreach ($ this ->packageVersions as $ packageVersion ) {
200+ foreach ($ packageVersion ->getInstallations () as $ installation ) {
201+ foreach ($ installation ->getSites () as $ site ) {
202+ $ sites [$ site ->getId ()->toRfc4122 ()] = $ site ;
203+ }
204+ }
205+ }
206+
207+ return new ArrayCollection (array_values ($ sites ));
208+ }
209+
193210 public function getPackage (): ?Package
194211 {
195212 return $ this ->package ;
Original file line number Diff line number Diff line change 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+ {% set sites = entity .instance .sites %}
5+ {% if ea().crud.currentAction == ' detail' %}
6+ {% if sites | length > 0 %}
7+ <table class =" table table-sm table-borderless" >
8+ <thead >
9+ <tr >
10+ <th >Domain</th >
11+ <th >Server</th >
12+ </tr >
13+ </thead >
14+ <tbody >
15+ {% for site in sites %}
16+ {% set url = ea_url()
17+ .unsetAll()
18+ .setController(' App\\Controller\\Admin\\SiteCrudController' )
19+ .setAction(' detail' )
20+ .setEntityId(site .id ) %}
21+ <tr >
22+ <td ><a href =" {{ url }}" >{{ site .primaryDomain }}</a ></td >
23+ <td >{{ site .server }}</td >
24+ </tr >
25+ {% endfor %}
26+ </tbody >
27+ </table >
28+ {% else %}
29+ <span class =" text-muted" >None</span >
30+ {% endif %}
31+ {% else %}
32+ <span class =" badge badge-info" >{{ sites | length }}</span >
33+ {% endif %}
You can’t perform that action at this time.
0 commit comments