refs #1951. Added isDefault in PxeTemplate entity
testing/ogcore-api/pipeline/head There was a failure building this commit Details

pull/30/head
Manuel Aranda Rosales 2025-05-07 16:57:55 +02:00
parent 410b287d05
commit 53a8c04e76
5 changed files with 59 additions and 1 deletions

View File

@ -213,7 +213,7 @@ services:
api_platform.filter.pxe_template.boolean:
parent: 'api_platform.doctrine.orm.boolean_filter'
arguments: [ { 'synchronized': ~ } ]
arguments: [ { 'synchronized': ~, 'isDefault': ~ } ]
tags: [ 'api_platform.filter' ]
api_platform.filter.remote_calendar.order:

View File

@ -0,0 +1,33 @@
<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20250506141057 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE client DROP FOREIGN KEY FK_C74404555DA0FB8');
$this->addSql('ALTER TABLE client ADD CONSTRAINT FK_C74404555DA0FB8 FOREIGN KEY (template_id) REFERENCES pxe_template (id) ON DELETE SET NULL');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE client DROP FOREIGN KEY FK_C74404555DA0FB8');
$this->addSql('ALTER TABLE client ADD CONSTRAINT FK_C74404555DA0FB8 FOREIGN KEY (template_id) REFERENCES pxe_template (id)');
}
}

View File

@ -18,6 +18,10 @@ final class PxeTemplateInput
#[ApiProperty(description: 'The content of the pxeTemplate', example: "content of the pxeTemplate 1")]
public ?string $templateContent = null;
#[Groups(['pxe-template:write'])]
#[ApiProperty(description: 'The default pxeTemplate', example: "true")]
public ?bool $isDefault = null;
public function __construct(?PxeTemplate $pxeTemplate = null)
{
if (!$pxeTemplate) {
@ -26,6 +30,7 @@ final class PxeTemplateInput
$this->name = $pxeTemplate->getName();
$this->templateContent = $pxeTemplate->getTemplateContent();
$this->isDefault = $pxeTemplate->isDefault();
}
public function createOrUpdateEntity(?PxeTemplate $pxeTemplate = null): PxeTemplate
@ -36,6 +41,7 @@ final class PxeTemplateInput
$pxeTemplate->setName($this->name);
$pxeTemplate->setTemplateContent($this->templateContent);
$pxeTemplate->setDefault($this->isDefault);
return $pxeTemplate;
}

View File

@ -20,6 +20,9 @@ final class PxeTemplateOutput extends AbstractOutput
#[Groups(['pxe-template:read'])]
public ?string $templateContent = '';
#[Groups(['pxe-template:read'])]
public ?bool $isDefault = null;
#[Groups(['pxe-template:read'])]
public ?int $clientsLength = 0;
@ -37,6 +40,7 @@ final class PxeTemplateOutput extends AbstractOutput
$this->synchronized = $pxeTemplate->isSynchronized();
$this->templateContent = $pxeTemplate->getTemplateContent();
$this->clientsLength = $pxeTemplate->getClients()->count();
$this->isDefault = $pxeTemplate->isDefault();
$this->createdAt = $pxeTemplate->getCreatedAt();
$this->createdBy = $pxeTemplate->getCreatedBy();
}

View File

@ -26,6 +26,9 @@ class PxeTemplate extends AbstractEntity
#[ORM\OneToMany(mappedBy: 'template', targetEntity: Client::class)]
private Collection $clients;
#[ORM\Column(nullable: true)]
private ?bool $isDefault = null;
public function __construct()
{
parent::__construct();
@ -82,4 +85,16 @@ class PxeTemplate extends AbstractEntity
return $this;
}
public function isDefault(): ?bool
{
return $this->isDefault;
}
public function setDefault(?bool $isDefault): static
{
$this->isDefault = $isDefault;
return $this;
}
}