From 8fc71a9d95c8eca80436096bb255e59965b84271 Mon Sep 17 00:00:00 2001 From: Francis Hilaire Date: Fri, 21 Jun 2024 16:06:06 +0200 Subject: [PATCH 1/8] Convert Message entity from annotation to xml format --- src/Entity/Message.php | 84 ++----------------- src/Resources/config/doctrine/Message.orm.xml | 54 ++++++++++++ 2 files changed, 63 insertions(+), 75 deletions(-) create mode 100644 src/Resources/config/doctrine/Message.orm.xml diff --git a/src/Entity/Message.php b/src/Entity/Message.php index fcc0c4c..a3699fa 100644 --- a/src/Entity/Message.php +++ b/src/Entity/Message.php @@ -16,8 +16,6 @@ use DateTimeInterface; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; -use Doctrine\ORM\Mapping as ORM; -use Gedmo\Mapping\Annotation as Gedmo; use Gedmo\Timestampable\Timestampable; use Sylius\Component\Core\Model\ChannelInterface; use Sylius\Component\Resource\Model\ResourceInterface; @@ -28,10 +26,6 @@ use Sylius\Component\Resource\Model\TranslatableInterface; use Sylius\Component\Resource\Model\TranslatableTrait; -/** - * @ORM\Entity - * @ORM\Table(name="mbiz_alert_message") - */ class Message implements ResourceInterface, TimestampableInterface, ToggleableInterface, TranslatableInterface, Timestampable { use TimestampableTrait; @@ -44,81 +38,21 @@ class Message implements ResourceInterface, TimestampableInterface, ToggleableIn getTranslation as private doGetTranslation; } - /** - * @var int|null - * - * @ORM\Id - * @ORM\GeneratedValue - * @ORM\Column(type="integer") - */ - private $id; + protected ?int $id = null; + protected bool $customersOnly = false; - /** - * @var bool - * @ORM\Column(type="boolean", options={"default"=true}) - */ - protected $enabled = true; + protected ?string $name = null; - /** - * @var bool - * @ORM\Column(name="customers_only", type="boolean", options={"default"=false}) - */ - protected $customersOnly = false; + protected ?string $description = null; - /** - * @var string|null - * @ORM\Column(type="string") - */ - protected $name; + /** @var Collection */ + private Collection $channels; - /** - * @var string|null - * @ORM\Column(type="string", nullable=true) - */ - protected $description; + private ?string $templateHtml = null; - /** - * @var Collection - * @ORM\ManyToMany(targetEntity="\Sylius\Component\Core\Model\ChannelInterface") - * @ORM\JoinTable( - * name="mbiz_alert_message_channels", - * joinColumns={@ORM\JoinColumn(name="message_id", referencedColumnName="id")}, - * inverseJoinColumns={@ORM\JoinColumn(name="channel_id", referencedColumnName="id")} - * ) - */ - private $channels; + private ?DateTimeInterface $fromDate = null; - /** - * @var DateTimeInterface|null - * @ORM\Column(name="created_at", type="datetime_immutable") - * @Gedmo\Timestampable(on="create") - */ - protected $createdAt; - - /** - * @var DateTimeInterface|null - * @ORM\Column(name="updated_at", type="datetime") - * @Gedmo\Timestampable(on="update") - */ - protected $updatedAt; - - /** - * @var string|null - * @ORM\Column(name="template_html", type="text", nullable=true) - */ - private $templateHtml; - - /** - * @var DateTimeInterface|null - * @ORM\Column(name="from_date", type="datetime", nullable=true) - */ - private $fromDate; - - /** - * @var DateTimeInterface|null - * @ORM\Column(name="to_date", type="datetime", nullable=true) - */ - private $toDate; + private ?DateTimeInterface $toDate = null; /** * Message constructor. diff --git a/src/Resources/config/doctrine/Message.orm.xml b/src/Resources/config/doctrine/Message.orm.xml new file mode 100644 index 0000000..d3b845c --- /dev/null +++ b/src/Resources/config/doctrine/Message.orm.xml @@ -0,0 +1,54 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From 81bc19ac00e700d710d9831849e5d7695e245d64 Mon Sep 17 00:00:00 2001 From: Francis Hilaire Date: Fri, 21 Jun 2024 16:17:00 +0200 Subject: [PATCH 2/8] Convert MessageTranslation entity from annotation to xml format --- src/Entity/MessageTranslation.php | 29 +++---------------- .../doctrine/MessageTranslation.orm.xml | 19 ++++++++++++ 2 files changed, 23 insertions(+), 25 deletions(-) create mode 100644 src/Resources/config/doctrine/MessageTranslation.orm.xml diff --git a/src/Entity/MessageTranslation.php b/src/Entity/MessageTranslation.php index e64b96a..3b0efcd 100644 --- a/src/Entity/MessageTranslation.php +++ b/src/Entity/MessageTranslation.php @@ -13,37 +13,16 @@ namespace MonsieurBiz\SyliusAlertMessagePlugin\Entity; -use Doctrine\ORM\Mapping as ORM; use Sylius\Component\Resource\Model\AbstractTranslation; use Sylius\Component\Resource\Model\ResourceInterface; -use Sylius\Component\Resource\Model\TranslationInterface; -/** - * @ORM\Entity - * @ORM\Table(name="mbiz_alert_message_translation") - */ -class MessageTranslation extends AbstractTranslation implements TranslationInterface, ResourceInterface +class MessageTranslation extends AbstractTranslation implements ResourceInterface { - /** - * @var int|null - * - * @ORM\Id - * @ORM\Column(type="integer") - * @ORM\GeneratedValue - */ - private $id; + protected ?int $id = null; - /** - * @var string|null - * @ORM\Column(type="string", nullable=true) - */ - private $title; + private ?string $title = null; - /** - * @var string|null - * @ORM\Column(type="text") - */ - private $message; + private ?string $message = null; public function getId(): ?int { diff --git a/src/Resources/config/doctrine/MessageTranslation.orm.xml b/src/Resources/config/doctrine/MessageTranslation.orm.xml new file mode 100644 index 0000000..a2a51f2 --- /dev/null +++ b/src/Resources/config/doctrine/MessageTranslation.orm.xml @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + From f43bd952cc71040f968385ad12a7081b67a372fb Mon Sep 17 00:00:00 2001 From: Francis Hilaire Date: Fri, 21 Jun 2024 16:18:56 +0200 Subject: [PATCH 3/8] Make properties accessible from a possible parent class --- src/Entity/Message.php | 8 ++++---- src/Entity/MessageTranslation.php | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Entity/Message.php b/src/Entity/Message.php index a3699fa..7df3c72 100644 --- a/src/Entity/Message.php +++ b/src/Entity/Message.php @@ -46,13 +46,13 @@ class Message implements ResourceInterface, TimestampableInterface, ToggleableIn protected ?string $description = null; /** @var Collection */ - private Collection $channels; + protected Collection $channels; - private ?string $templateHtml = null; + protected ?string $templateHtml = null; - private ?DateTimeInterface $fromDate = null; + protected ?DateTimeInterface $fromDate = null; - private ?DateTimeInterface $toDate = null; + protected ?DateTimeInterface $toDate = null; /** * Message constructor. diff --git a/src/Entity/MessageTranslation.php b/src/Entity/MessageTranslation.php index 3b0efcd..d38ba6c 100644 --- a/src/Entity/MessageTranslation.php +++ b/src/Entity/MessageTranslation.php @@ -20,9 +20,9 @@ class MessageTranslation extends AbstractTranslation implements ResourceInterfac { protected ?int $id = null; - private ?string $title = null; + protected ?string $title = null; - private ?string $message = null; + protected ?string $message = null; public function getId(): ?int { From 3edfcfcef735100654bc5c20c09f93a7f33955af Mon Sep 17 00:00:00 2001 From: Francis Hilaire Date: Sat, 22 Jun 2024 01:08:42 +0200 Subject: [PATCH 4/8] remove useless backslash --- src/Resources/config/doctrine/Message.orm.xml | 2 +- src/Resources/config/doctrine/MessageTranslation.orm.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Resources/config/doctrine/Message.orm.xml b/src/Resources/config/doctrine/Message.orm.xml index d3b845c..e179205 100644 --- a/src/Resources/config/doctrine/Message.orm.xml +++ b/src/Resources/config/doctrine/Message.orm.xml @@ -8,7 +8,7 @@ http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd" > - + diff --git a/src/Resources/config/doctrine/MessageTranslation.orm.xml b/src/Resources/config/doctrine/MessageTranslation.orm.xml index a2a51f2..dac1985 100644 --- a/src/Resources/config/doctrine/MessageTranslation.orm.xml +++ b/src/Resources/config/doctrine/MessageTranslation.orm.xml @@ -7,7 +7,7 @@ http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd" > - + From 6e5248819e11a9c511da8e66cf26c95bfe6afb5c Mon Sep 17 00:00:00 2001 From: Francis Hilaire Date: Mon, 24 Jun 2024 12:49:14 +0200 Subject: [PATCH 5/8] Fix PHPCS --- src/Entity/Message.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Entity/Message.php b/src/Entity/Message.php index 7df3c72..d4db0f0 100644 --- a/src/Entity/Message.php +++ b/src/Entity/Message.php @@ -39,6 +39,7 @@ class Message implements ResourceInterface, TimestampableInterface, ToggleableIn } protected ?int $id = null; + protected bool $customersOnly = false; protected ?string $name = null; From 975dc27ddfa8deeab625569b7fe7b99fccfeebce Mon Sep 17 00:00:00 2001 From: Francis Hilaire Date: Mon, 24 Jun 2024 15:13:10 +0200 Subject: [PATCH 6/8] Fix wrong default value --- composer.json | 3 ++- src/Resources/config/doctrine/Message.orm.xml | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/composer.json b/composer.json index 82b2114..59ce39e 100644 --- a/composer.json +++ b/composer.json @@ -42,7 +42,8 @@ "symfony/dotenv": "^4.4", "symfony/flex": "^1.7", "symfony/web-profiler-bundle": "^4.4", - "phpmd/phpmd": "@stable" + "phpmd/phpmd": "@stable", + "http-interop/http-factory-guzzle": "^1.2" }, "prefer-stable": true, "autoload": { diff --git a/src/Resources/config/doctrine/Message.orm.xml b/src/Resources/config/doctrine/Message.orm.xml index e179205..863e394 100644 --- a/src/Resources/config/doctrine/Message.orm.xml +++ b/src/Resources/config/doctrine/Message.orm.xml @@ -14,13 +14,13 @@ - + - + From c050e5f80f9494b0c2fed1b94a423c224bd50060 Mon Sep 17 00:00:00 2001 From: Francis Hilaire Date: Mon, 24 Jun 2024 16:11:13 +0200 Subject: [PATCH 7/8] Fix wrong types --- src/Resources/config/doctrine/Message.orm.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Resources/config/doctrine/Message.orm.xml b/src/Resources/config/doctrine/Message.orm.xml index 863e394..95e271a 100644 --- a/src/Resources/config/doctrine/Message.orm.xml +++ b/src/Resources/config/doctrine/Message.orm.xml @@ -38,15 +38,15 @@ - + - + - + From 905ddc83b1c3c09dc61e0b86975b82e7acf01153 Mon Sep 17 00:00:00 2001 From: Francis Hilaire Date: Mon, 24 Jun 2024 17:43:15 +0200 Subject: [PATCH 8/8] Fix immutable --- src/Resources/config/doctrine/Message.orm.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Resources/config/doctrine/Message.orm.xml b/src/Resources/config/doctrine/Message.orm.xml index 95e271a..99c9dea 100644 --- a/src/Resources/config/doctrine/Message.orm.xml +++ b/src/Resources/config/doctrine/Message.orm.xml @@ -42,7 +42,7 @@ - +