From ab6c2172fc860c0d6d295d215d523802171bb4d3 Mon Sep 17 00:00:00 2001 From: Mathieu De Keyzer Date: Sun, 7 Apr 2024 18:22:07 +0200 Subject: [PATCH 1/2] fix(core): reordered entity services (#865) --- .../src/Resources/config/services.xml | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/EMS/core-bundle/src/Resources/config/services.xml b/EMS/core-bundle/src/Resources/config/services.xml index 2f58e9617..d67823a02 100644 --- a/EMS/core-bundle/src/Resources/config/services.xml +++ b/EMS/core-bundle/src/Resources/config/services.xml @@ -37,7 +37,7 @@ - + @@ -46,12 +46,12 @@ - + - + @@ -108,7 +108,7 @@ - + @@ -202,7 +202,7 @@ - + @@ -226,11 +226,11 @@ - + - + @@ -332,7 +332,7 @@ %ems_core.instance_id% - + @@ -345,7 +345,7 @@ %ems_core.circles_object% - + @@ -359,7 +359,7 @@ - + @@ -379,7 +379,7 @@ - + @@ -417,7 +417,7 @@ - + @@ -505,7 +505,7 @@ %ems_core.instance_id% - + From 9de994f2a048f4693c203c5f7078b0db5f222110 Mon Sep 17 00:00:00 2001 From: David mattei Date: Tue, 9 Apr 2024 15:14:41 +0200 Subject: [PATCH 2/2] fix(submission): change expire_date from date to date time (#867) --- .../bootstrap5/revision/task/columns.twig | 2 +- .../Type/FormSubmissionDataTableType.php | 3 +- .../pdo_mysql/Version20240409120638.php | 37 +++++++++++++++++++ .../pdo_pgsql/Version20240409120406.php | 37 +++++++++++++++++++ .../views/revision/task/columns.twig | 2 +- .../src/Entity/FormSubmission.php | 9 +++-- .../src/Entity/FormSubmissionFile.php | 8 ++++ .../src/Request/DatabaseRequest.php | 2 +- .../pdo_mysql/Version20240226165436.php | 1 + .../pdo_mysql/Version20240409121627.php | 37 +++++++++++++++++++ .../pdo_pgsql/Version20240409121450.php | 37 +++++++++++++++++++ 11 files changed, 166 insertions(+), 9 deletions(-) create mode 100644 EMS/core-bundle/src/Resources/DoctrineMigrations/pdo_mysql/Version20240409120638.php create mode 100644 EMS/core-bundle/src/Resources/DoctrineMigrations/pdo_pgsql/Version20240409120406.php create mode 100644 elasticms-web/migrations/pdo_mysql/Version20240409121627.php create mode 100644 elasticms-web/migrations/pdo_pgsql/Version20240409121450.php diff --git a/EMS/admin-ui-bundle/src/Resources/views/bootstrap5/revision/task/columns.twig b/EMS/admin-ui-bundle/src/Resources/views/bootstrap5/revision/task/columns.twig index aef4bdaa6..2431ce431 100644 --- a/EMS/admin-ui-bundle/src/Resources/views/bootstrap5/revision/task/columns.twig +++ b/EMS/admin-ui-bundle/src/Resources/views/bootstrap5/revision/task/columns.twig @@ -41,7 +41,7 @@ {% endif %} {%- endblock -%} -{%- block modified -%}{{ data.task_modified -}}{%- endblock -%} +{%- block modified -%}{{ data.task_modified|date(date_time_format) -}}{%- endblock -%} {%- block actions -%}
diff --git a/EMS/core-bundle/src/DataTable/Type/FormSubmissionDataTableType.php b/EMS/core-bundle/src/DataTable/Type/FormSubmissionDataTableType.php index 8f372893a..163fc906a 100644 --- a/EMS/core-bundle/src/DataTable/Type/FormSubmissionDataTableType.php +++ b/EMS/core-bundle/src/DataTable/Type/FormSubmissionDataTableType.php @@ -5,7 +5,6 @@ namespace EMS\CoreBundle\DataTable\Type; use EMS\CoreBundle\Core\DataTable\Type\AbstractEntityTableType; -use EMS\CoreBundle\Form\Data\DateTableColumn; use EMS\CoreBundle\Form\Data\DatetimeTableColumn; use EMS\CoreBundle\Form\Data\EntityTable; use EMS\CoreBundle\Form\Data\TableAbstract; @@ -27,7 +26,7 @@ public function build(EntityTable $table): void $table->addColumn('form-submission.index.column.form', 'name'); $table->addColumn('form-submission.index.column.locale', 'locale'); $table->addColumnDefinition(new DatetimeTableColumn('form-submission.index.column.created', 'created')); - $table->addColumnDefinition(new DateTableColumn('form-submission.index.column.expire_date', 'expireDate')); + $table->addColumnDefinition(new DatetimeTableColumn('form-submission.index.column.expire_date', 'expireDate')); $table->addItemGetAction('form.submissions.download', 'form-submission.form-submissions.download', 'download'); $table->addItemPostAction('form.submissions.process', 'form-submission.form-submissions.process', 'check', 'form-submission.form-submissions.confirm'); diff --git a/EMS/core-bundle/src/Resources/DoctrineMigrations/pdo_mysql/Version20240409120638.php b/EMS/core-bundle/src/Resources/DoctrineMigrations/pdo_mysql/Version20240409120638.php new file mode 100644 index 000000000..51061885c --- /dev/null +++ b/EMS/core-bundle/src/Resources/DoctrineMigrations/pdo_mysql/Version20240409120638.php @@ -0,0 +1,37 @@ +abortIf( + !$this->connection->getDatabasePlatform() instanceof MySQLPlatform, + "Migration can only be executed safely on '\Doctrine\DBAL\Platforms\MySQLPlatform'." + ); + + $this->addSql('ALTER TABLE form_submission CHANGE expire_date expire_date DATETIME DEFAULT NULL'); + } + + public function down(Schema $schema): void + { + $this->abortIf( + !$this->connection->getDatabasePlatform() instanceof MySQLPlatform, + "Migration can only be executed safely on '\Doctrine\DBAL\Platforms\MySQLPlatform'." + ); + + $this->addSql('ALTER TABLE form_submission CHANGE expire_date expire_date DATE DEFAULT NULL'); + } +} diff --git a/EMS/core-bundle/src/Resources/DoctrineMigrations/pdo_pgsql/Version20240409120406.php b/EMS/core-bundle/src/Resources/DoctrineMigrations/pdo_pgsql/Version20240409120406.php new file mode 100644 index 000000000..64b713b10 --- /dev/null +++ b/EMS/core-bundle/src/Resources/DoctrineMigrations/pdo_pgsql/Version20240409120406.php @@ -0,0 +1,37 @@ +abortIf( + !$this->connection->getDatabasePlatform() instanceof PostgreSQLPlatform, + "Migration can only be executed safely on '\Doctrine\DBAL\Platforms\PostgreSQLPlatform'." + ); + + $this->addSql('ALTER TABLE form_submission ALTER expire_date TYPE TIMESTAMP(0) WITHOUT TIME ZONE'); + } + + public function down(Schema $schema): void + { + $this->abortIf( + !$this->connection->getDatabasePlatform() instanceof PostgreSQLPlatform, + "Migration can only be executed safely on '\Doctrine\DBAL\Platforms\PostgreSQLPlatform'." + ); + + $this->addSql('ALTER TABLE form_submission ALTER expire_date TYPE DATE'); + } +} diff --git a/EMS/core-bundle/src/Resources/views/revision/task/columns.twig b/EMS/core-bundle/src/Resources/views/revision/task/columns.twig index aef4bdaa6..2431ce431 100644 --- a/EMS/core-bundle/src/Resources/views/revision/task/columns.twig +++ b/EMS/core-bundle/src/Resources/views/revision/task/columns.twig @@ -41,7 +41,7 @@ {% endif %} {%- endblock -%} -{%- block modified -%}{{ data.task_modified -}}{%- endblock -%} +{%- block modified -%}{{ data.task_modified|date(date_time_format) -}}{%- endblock -%} {%- block actions -%}
diff --git a/EMS/submission-bundle/src/Entity/FormSubmission.php b/EMS/submission-bundle/src/Entity/FormSubmission.php index a82bab173..97aa3c585 100644 --- a/EMS/submission-bundle/src/Entity/FormSubmission.php +++ b/EMS/submission-bundle/src/Entity/FormSubmission.php @@ -73,9 +73,9 @@ class FormSubmission implements EntityInterface, \JsonSerializable protected $files; /** - * @ORM\Column(name="expire_date", type="date", nullable=true) + * @ORM\Column(name="expire_date", type="datetime", nullable=true) */ - private ?\DateTime $expireDate; + private ?\DateTimeInterface $expireDate; /** * @ORM\Column(name="label", type="string", length=255) @@ -144,7 +144,8 @@ public function toArray(): array } if ($this->files->count() > 0) { - $data['files'] = $this->files->toArray(); + $files = $this->files->toArray(); + $data['files'] = \array_map(static fn (FormSubmissionFile $f) => $f->toArray(), $files); } else { unset($data['files']); } @@ -203,7 +204,7 @@ public function getLabel(): ?string return $this->label; } - public function getExpireDate(): ?\DateTime + public function getExpireDate(): ?\DateTimeInterface { return $this->expireDate; } diff --git a/EMS/submission-bundle/src/Entity/FormSubmissionFile.php b/EMS/submission-bundle/src/Entity/FormSubmissionFile.php index 13a599a3b..4f189b594 100644 --- a/EMS/submission-bundle/src/Entity/FormSubmissionFile.php +++ b/EMS/submission-bundle/src/Entity/FormSubmissionFile.php @@ -93,6 +93,14 @@ public function __construct(/** * @return array */ public function jsonSerialize(): array + { + return $this->toArray(); + } + + /** + * @return array + */ + public function toArray(): array { return [ 'id' => $this->id->toString(), diff --git a/EMS/submission-bundle/src/Request/DatabaseRequest.php b/EMS/submission-bundle/src/Request/DatabaseRequest.php index 5d3da244b..631b2d138 100644 --- a/EMS/submission-bundle/src/Request/DatabaseRequest.php +++ b/EMS/submission-bundle/src/Request/DatabaseRequest.php @@ -72,7 +72,7 @@ public function getLabel(): string return $this->label; } - public function getExpireDate(): ?\DateTime + public function getExpireDate(): ?\DateTimeInterface { return $this->expireDate ? \DateTime::createFromImmutable($this->expireDate) : null; } diff --git a/elasticms-web/migrations/pdo_mysql/Version20240226165436.php b/elasticms-web/migrations/pdo_mysql/Version20240226165436.php index b57f063b9..f35009002 100644 --- a/elasticms-web/migrations/pdo_mysql/Version20240226165436.php +++ b/elasticms-web/migrations/pdo_mysql/Version20240226165436.php @@ -4,6 +4,7 @@ namespace Application\Migrations; +use Doctrine\DBAL\Platforms\MySQLPlatform; use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; diff --git a/elasticms-web/migrations/pdo_mysql/Version20240409121627.php b/elasticms-web/migrations/pdo_mysql/Version20240409121627.php new file mode 100644 index 000000000..51c6a7f9a --- /dev/null +++ b/elasticms-web/migrations/pdo_mysql/Version20240409121627.php @@ -0,0 +1,37 @@ +abortIf( + !$this->connection->getDatabasePlatform() instanceof MySQLPlatform, + "Migration can only be executed safely on '\Doctrine\DBAL\Platforms\MySQLPlatform'." + ); + + $this->addSql('ALTER TABLE form_submission CHANGE expire_date expire_date DATETIME DEFAULT NULL'); + } + + public function down(Schema $schema): void + { + $this->abortIf( + !$this->connection->getDatabasePlatform() instanceof MySQLPlatform, + "Migration can only be executed safely on '\Doctrine\DBAL\Platforms\MySQLPlatform'." + ); + + $this->addSql('ALTER TABLE form_submission CHANGE expire_date expire_date DATE DEFAULT NULL'); + } +} diff --git a/elasticms-web/migrations/pdo_pgsql/Version20240409121450.php b/elasticms-web/migrations/pdo_pgsql/Version20240409121450.php new file mode 100644 index 000000000..5d6a069f2 --- /dev/null +++ b/elasticms-web/migrations/pdo_pgsql/Version20240409121450.php @@ -0,0 +1,37 @@ +abortIf( + !$this->connection->getDatabasePlatform() instanceof PostgreSQLPlatform, + "Migration can only be executed safely on '\Doctrine\DBAL\Platforms\PostgreSQLPlatform'." + ); + + $this->addSql('ALTER TABLE form_submission ALTER expire_date TYPE TIMESTAMP(0) WITHOUT TIME ZONE'); + } + + public function down(Schema $schema): void + { + $this->abortIf( + !$this->connection->getDatabasePlatform() instanceof PostgreSQLPlatform, + "Migration can only be executed safely on '\Doctrine\DBAL\Platforms\PostgreSQLPlatform'." + ); + + $this->addSql('ALTER TABLE form_submission ALTER expire_date TYPE DATE'); + } +}