Skip to content

Commit 072186c

Browse files
authored
Merge pull request #58 from itk-dev/feature/5002-export-everything
5002: Added export to everything
2 parents 1655711 + 82ec7b3 commit 072186c

10 files changed

Lines changed: 75 additions & 1 deletion

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+
- [#58](https://github.com/itk-dev/devops_itksites/pull/58)
11+
5002: Added export to everything
12+
1013
## [1.8.10] - 2025-07-02
1114

1215
- Fix deprecation warning for "erase credentials"

src/Controller/Admin/DomainCrudController.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use App\Admin\Field\ServerTypeField;
99
use App\Admin\Field\SiteTypeField;
1010
use App\Entity\Domain;
11+
use App\Trait\ExportCrudControllerTrait;
1112
use EasyCorp\Bundle\EasyAdminBundle\Config\Action;
1213
use EasyCorp\Bundle\EasyAdminBundle\Config\Actions;
1314
use EasyCorp\Bundle\EasyAdminBundle\Config\Crud;
@@ -18,6 +19,8 @@
1819

1920
class DomainCrudController extends AbstractCrudController
2021
{
22+
use ExportCrudControllerTrait;
23+
2124
public static function getEntityFqcn(): string
2225
{
2326
return Domain::class;
@@ -34,6 +37,7 @@ public function configureActions(Actions $actions): Actions
3437
{
3538
return $actions
3639
->add(Crud::PAGE_INDEX, Action::DETAIL)
40+
->add(Crud::PAGE_INDEX, $this->createExportAction())
3741
->remove(Crud::PAGE_INDEX, Action::NEW)
3842
->remove(Crud::PAGE_INDEX, Action::EDIT)
3943
->remove(Crud::PAGE_INDEX, Action::DELETE)

src/Controller/Admin/InstallationCrudController.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
use App\Admin\Field\VersionField;
1212
use App\Entity\Installation;
1313
use App\Form\Type\Admin\FrameworkFilter;
14-
use App\Form\Type\Admin\SystemFilter;
14+
use App\Trait\ExportCrudControllerTrait;
1515
use EasyCorp\Bundle\EasyAdminBundle\Config\Action;
1616
use EasyCorp\Bundle\EasyAdminBundle\Config\Actions;
1717
use EasyCorp\Bundle\EasyAdminBundle\Config\Crud;
@@ -24,6 +24,8 @@
2424

2525
class InstallationCrudController extends AbstractCrudController
2626
{
27+
use ExportCrudControllerTrait;
28+
2729
public static function getEntityFqcn(): string
2830
{
2931
return Installation::class;
@@ -40,6 +42,7 @@ public function configureActions(Actions $actions): Actions
4042
{
4143
return $actions
4244
->add(Crud::PAGE_INDEX, Action::DETAIL)
45+
->add(Crud::PAGE_INDEX, $this->createExportAction())
4346
->remove(Crud::PAGE_INDEX, Action::NEW)
4447
->remove(Crud::PAGE_INDEX, Action::EDIT)
4548
->remove(Crud::PAGE_INDEX, Action::DELETE)

src/Controller/Admin/ServiceCertificateCrudController.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use App\Entity\ServiceCertificate;
88
use App\Form\Type\ServiceCertificate\ServiceType;
99
use App\Repository\SiteRepository;
10+
use App\Trait\ExportCrudControllerTrait;
1011
use EasyCorp\Bundle\EasyAdminBundle\Config\Action;
1112
use EasyCorp\Bundle\EasyAdminBundle\Config\Actions;
1213
use EasyCorp\Bundle\EasyAdminBundle\Config\Assets;
@@ -22,6 +23,8 @@
2223

2324
class ServiceCertificateCrudController extends AbstractCrudController
2425
{
26+
use ExportCrudControllerTrait;
27+
2528
public function __construct(private readonly SiteRepository $siteRepository)
2629
{
2730
}
@@ -48,6 +51,7 @@ public function configureActions(Actions $actions): Actions
4851
{
4952
return $actions
5053
->add(Crud::PAGE_INDEX, Action::DETAIL)
54+
->add(Crud::PAGE_INDEX, $this->createExportAction())
5155
->remove(Crud::PAGE_INDEX, Action::DELETE);
5256
}
5357

src/Entity/AbstractHandlerResult.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
class AbstractHandlerResult extends AbstractBaseEntity
1313
{
1414
#[ORM\Column(type: 'string', length: 255)]
15+
#[Groups(['export'])]
1516
private string $rootDir;
1617

1718
#[ORM\ManyToOne(targetEntity: Server::class)]

src/Entity/Domain.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
use App\Repository\DomainRepository;
88
use Doctrine\ORM\Mapping as ORM;
9+
use Symfony\Component\Serializer\Annotation\Groups;
910
use Symfony\Component\Validator\Constraints as Assert;
1011

1112
#[ORM\Entity(repositoryClass: DomainRepository::class)]
@@ -19,10 +20,12 @@ class Domain extends AbstractHandlerResult implements \Stringable
1920
minMessage: 'Your address must be longer than {{ limit }} characters',
2021
maxMessage: 'Your address cannot be longer than {{ limit }} characters',
2122
)]
23+
#[Groups(['export'])]
2224
private string $address;
2325

2426
#[ORM\ManyToOne(targetEntity: Site::class, inversedBy: 'domains')]
2527
#[ORM\JoinColumn(nullable: false, onDelete: 'CASCADE')]
28+
#[Groups(['export'])]
2629
private Site $site;
2730

2831
#[\Override]

src/Entity/Installation.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
use Doctrine\Common\Collections\ArrayCollection;
1010
use Doctrine\Common\Collections\Collection;
1111
use Doctrine\ORM\Mapping as ORM;
12+
use Symfony\Component\Serializer\Annotation\Groups;
1213

1314
#[ORM\Entity(repositoryClass: InstallationRepository::class)]
1415
#[ORM\AssociationOverrides([
@@ -26,21 +27,27 @@ class Installation extends AbstractHandlerResult implements \Stringable
2627
private Collection $sites;
2728

2829
#[ORM\Column(type: 'string', length: 10, nullable: true)]
30+
#[Groups(['export'])]
2931
private ?string $type = 'unknown';
3032

3133
#[ORM\Column(type: 'string', length: 10, nullable: true)]
34+
#[Groups(['export'])]
3235
private ?string $phpVersion = 'unknown';
3336

3437
#[ORM\Column(type: 'string', length: 10, nullable: true)]
38+
#[Groups(['export'])]
3539
private ?string $composerVersion = 'unknown';
3640

3741
#[ORM\Column(type: 'string', length: 10, nullable: true)]
42+
#[Groups(['export'])]
3843
private ?string $frameworkVersion = FrameworkTypes::UNKNOWN;
3944

4045
#[ORM\Column(type: 'boolean')]
46+
#[Groups(['export'])]
4147
private bool $lts = false;
4248

4349
#[ORM\Column(type: 'string', length: 30)]
50+
#[Groups(['export'])]
4451
private string $eol = '';
4552

4653
#[ORM\Column(type: 'text')]

src/Entity/ServiceCertificate.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,40 +10,48 @@
1010
use Doctrine\Common\Collections\Collection;
1111
use Doctrine\DBAL\Types\Types;
1212
use Doctrine\ORM\Mapping as ORM;
13+
use Symfony\Component\Serializer\Annotation\Groups;
1314
use Symfony\Component\Validator\Constraints as Assert;
1415

1516
#[ORM\Entity(repositoryClass: ServiceCertificateRepository::class)]
1617
class ServiceCertificate extends AbstractBaseEntity implements \Stringable
1718
{
1819
#[ORM\Column(length: 255)]
1920
#[Assert\NotBlank]
21+
#[Groups(['export'])]
2022
private ?string $domain = null;
2123

2224
#[ORM\Column(length: 255)]
2325
#[Assert\NotBlank]
26+
#[Groups(['export'])]
2427
private ?string $name = null;
2528

2629
#[ORM\Column(type: Types::TEXT)]
2730
#[Assert\NotBlank]
31+
#[Groups(['export'])]
2832
private ?string $description = null;
2933

3034
#[ORM\Column(length: 255)]
3135
#[Assert\NotBlank]
3236
#[Assert\Url]
37+
#[Groups(['export'])]
3338
private ?string $onePasswordUrl = null;
3439

3540
#[ORM\Column(type: Types::DATETIME_MUTABLE)]
3641
#[Assert\NotNull]
42+
#[Groups(['export'])]
3743
private ?\DateTimeInterface $expirationTime = null;
3844

3945
#[ORM\Column(length: 255)]
4046
#[Assert\NotBlank]
4147
#[Assert\Url]
48+
#[Groups(['export'])]
4249
private ?string $usageDocumentationUrl = null;
4350

4451
#[ORM\OneToMany(targetEntity: Service::class, mappedBy: 'certificate', cascade: ['persist'], orphanRemoval: true)]
4552
#[ORM\OrderBy(['type' => 'ASC'])]
4653
#[Assert\Valid]
54+
#[Groups(['export'])]
4755
private Collection $services;
4856

4957
public function __construct()

src/Entity/ServiceCertificate/Service.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use App\Entity\ServiceCertificate;
99
use App\Repository\ServiceCertificate\ServiceRepository;
1010
use Doctrine\ORM\Mapping as ORM;
11+
use Symfony\Component\Serializer\Annotation\Groups;
1112
use Symfony\Component\Validator\Constraints as Assert;
1213

1314
#[ORM\Entity(repositoryClass: ServiceRepository::class)]
@@ -20,6 +21,7 @@ class Service extends AbstractBaseEntity implements \Stringable
2021

2122
#[ORM\Column(length: 255)]
2223
#[Assert\NotBlank]
24+
#[Groups(['export'])]
2325
private ?string $type = null;
2426

2527
#[ORM\Column(length: 255)]
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace App\Serializer\Normalizer;
6+
7+
use App\Entity\ServiceCertificate;
8+
use Symfony\Component\DependencyInjection\Attribute\Autowire;
9+
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
10+
11+
class CustomNormalizer implements NormalizerInterface
12+
{
13+
public function __construct(
14+
#[Autowire(service: 'serializer.normalizer.object')]
15+
private NormalizerInterface $normalizer,
16+
) {
17+
}
18+
19+
public function normalize($data, ?string $format = null, array $context = []): array
20+
{
21+
$normalized = $this->normalizer->normalize($data, $format, $context);
22+
23+
if (isset($normalized['services']) && is_array($normalized['services'])) {
24+
$normalized['services'] = implode(',', array_column($normalized['services'], 'type'));
25+
}
26+
27+
return $normalized;
28+
}
29+
30+
public function supportsNormalization($data, ?string $format = null, array $context = []): bool
31+
{
32+
return $data instanceof ServiceCertificate;
33+
}
34+
35+
public function getSupportedTypes(?string $format): array
36+
{
37+
return [ServiceCertificate::class => true];
38+
}
39+
}

0 commit comments

Comments
 (0)