@@ -55,6 +55,57 @@ class GatewayConfig extends BaseGatewayConfig implements GatewayConfigInterface
55
55
$this->mollieGatewayConfig = new ArrayCollection();
56
56
}
57
57
}
58
+ ```
59
+ In case if you have installed Sylius version 1.13.x, use the following code instead
60
+ ``` php
61
+ <?php
62
+
63
+ declare(strict_types=1);
64
+
65
+ namespace App\Entity\Payment;
66
+
67
+ use Doctrine\ORM\Mapping as ORM;
68
+ use SyliusMolliePlugin\Entity\GatewayConfigInterface;
69
+ use SyliusMolliePlugin\Entity\GatewayConfigTrait;
70
+ use Doctrine\Common\Collections\ArrayCollection;
71
+ use Sylius\Bundle\PayumBundle\Model\GatewayConfig as BaseGatewayConfig;
72
+ use SyliusMolliePlugin\Entity\MollieGatewayConfig;
73
+
74
+ /**
75
+ * @ORM\Entity
76
+ * @ORM\Table(name="sylius_gateway_config")
77
+ */
78
+ #[ORM\Entity]
79
+ #[ORM\Table(name: 'sylius_gateway_config')]
80
+ class GatewayConfig extends BaseGatewayConfig implements GatewayConfigInterface
81
+ {
82
+ use GatewayConfigTrait;
83
+
84
+ /**
85
+ * @var ArrayCollection
86
+ * @ORM\OneToMany(
87
+ * targetEntity="SyliusMolliePlugin\Entity\MollieGatewayConfig",
88
+ * mappedBy="gateway",
89
+ * orphanRemoval=true,
90
+ * cascade={"all"}
91
+ * )
92
+ */
93
+ #[ORM\OneToMany(
94
+ mappedBy: "gateway",
95
+ targetEntity: MollieGatewayConfig::class,
96
+ cascade: ["all"],
97
+ orphanRemoval: true
98
+ )]
99
+ protected $mollieGatewayConfig;
100
+
101
+ public function __construct()
102
+ {
103
+ parent::__construct();
104
+
105
+ $this->mollieGatewayConfig = new ArrayCollection();
106
+ }
107
+ }
108
+
58
109
```
59
110
60
111
You can find more annotation examples under the [ tests/Application/src/Entity/* ] ( /tests/Application/src/Entity/ ) path.
@@ -109,6 +160,7 @@ use SyliusMolliePlugin\Entity\RecurringOrderTrait;
109
160
use Doctrine\Common\Collections\Collection;
110
161
use Sylius\Component\Core\Model\Order as BaseOrder;
111
162
use Sylius\Component\Core\Model\OrderItemInterface;
163
+ use Doctrine\ORM\Mapping as ORM;
112
164
113
165
/**
114
166
* @ORM\Entity
@@ -189,6 +241,114 @@ class Order extends BaseOrder implements OrderInterface
189
241
}
190
242
}
191
243
244
+ ```
245
+ In case if you have installed Sylius version 1.13.x, use the following code instead
246
+ ``` php
247
+ <?php
248
+
249
+ declare(strict_types=1);
250
+
251
+ namespace App\Entity\Order;
252
+
253
+ use SyliusMolliePlugin\Entity\MolliePaymentIdOrderTrait;
254
+ use SyliusMolliePlugin\Entity\OrderInterface;
255
+ use SyliusMolliePlugin\Entity\MollieSubscriptionInterface;
256
+ use SyliusMolliePlugin\Entity\AbandonedEmailOrderTrait;
257
+ use SyliusMolliePlugin\Entity\QRCodeOrderTrait;
258
+ use SyliusMolliePlugin\Entity\RecurringOrderTrait;
259
+ use Doctrine\Common\Collections\Collection;
260
+ use Sylius\Component\Core\Model\Order as BaseOrder;
261
+ use Sylius\Component\Core\Model\OrderItemInterface;
262
+ use Doctrine\ORM\Mapping as ORM;
263
+
264
+ /**
265
+ * @ORM\Entity
266
+ * @ORM\Table(name="sylius_order")
267
+ */
268
+ #[ORM\Entity]
269
+ #[ORM\Table(name: 'sylius_order')]
270
+ class Order extends BaseOrder implements OrderInterface
271
+ {
272
+ use AbandonedEmailOrderTrait;
273
+ use RecurringOrderTrait;
274
+ use QRCodeOrderTrait;
275
+ use MolliePaymentIdOrderTrait;
276
+
277
+ /**
278
+ * @var bool
279
+ * @ORM\Column(type="boolean", name="abandoned_email")
280
+ */
281
+ #[ORM\Column(name: "abandoned_email", type: "boolean")]
282
+ protected bool $abandonedEmail = false;
283
+
284
+ /**
285
+ * @var ?int
286
+ * @ORM\Column(type="integer", name="recurring_sequence_index", nullable=true)
287
+ */
288
+ #[ORM\Column(name: "recurring_sequence_index", type: "integer", nullable: true)]
289
+ protected ?int $recurringSequenceIndex = null;
290
+
291
+ /**
292
+ * @var string|null
293
+ * @ORM\Column(type="text", name="qr_code", nullable=true)
294
+ */
295
+ #[ORM\Column(name: "qr_code", type: "text", nullable: true)]
296
+ protected ?string $qrCode = null;
297
+
298
+ /**
299
+ * @var string|null
300
+ * @ORM\Column(type="text", name="mollie_payment_id", nullable=true)
301
+ */
302
+ #[ORM\Column(name: "mollie_payment_id", type: "text", nullable: true)]
303
+ protected ?string $molliePaymentId = null;
304
+
305
+ /**
306
+ * @var MollieSubscriptionInterface|null
307
+ * @ORM\ManyToOne(targetEntity="SyliusMolliePlugin\Entity\MollieSubscription")
308
+ * @ORM\JoinColumn(name="subscription_id", fieldName="subscription", onDelete="RESTRICT")
309
+ */
310
+ #[ORM\ManyToOne(targetEntity: MollieSubscription::class)]
311
+ #[ORM\JoinColumn(name: "subscription_id", onDelete: "RESTRICT")]
312
+ protected ?MollieSubscriptionInterface $subscription = null;
313
+
314
+ public function getRecurringItems(): Collection
315
+ {
316
+ return $this
317
+ ->items
318
+ ->filter(function (OrderItemInterface $orderItem) {
319
+ $variant = $orderItem->getVariant();
320
+
321
+ return $variant !== null
322
+ && true === $variant->isRecurring();
323
+ })
324
+ ;
325
+ }
326
+
327
+ public function getNonRecurringItems(): Collection
328
+ {
329
+ return $this
330
+ ->items
331
+ ->filter(function (OrderItemInterface $orderItem) {
332
+ $variant = $orderItem->getVariant();
333
+
334
+ return $variant !== null
335
+ && false === $variant->isRecurring();
336
+ })
337
+ ;
338
+ }
339
+
340
+ public function hasRecurringContents(): bool
341
+ {
342
+ return 0 < $this->getRecurringItems()->count();
343
+ }
344
+
345
+ public function hasNonRecurringContents(): bool
346
+ {
347
+ return 0 < $this->getNonRecurringItems()->count();
348
+ }
349
+ }
350
+
351
+
192
352
```
193
353
194
354
If you don't use annotations, you can also define new Entity mapping inside your ` src/Resources/config/doctrine ` directory.
@@ -247,6 +407,40 @@ class Product extends BaseProduct implements ProductInterface
247
407
*/
248
408
protected ?ProductType $productType = null;
249
409
}
410
+ ```
411
+ In case if you have installed Sylius version 1.13.x, use the following code instead
412
+ ``` php
413
+ <?php
414
+
415
+ declare(strict_types=1);
416
+
417
+ namespace App\Entity\Product;
418
+
419
+ use Doctrine\ORM\Mapping as ORM;
420
+ use SyliusMolliePlugin\Entity\ProductInterface;
421
+ use SyliusMolliePlugin\Entity\ProductTrait;
422
+ use Sylius\Component\Core\Model\Product as BaseProduct;
423
+ use SyliusMolliePlugin\Entity\ProductType;
424
+
425
+ /**
426
+ * @ORM\Entity
427
+ * @ORM\Table(name="sylius_product")
428
+ */
429
+ #[ORM\Entity]
430
+ #[ORM\Table(name: 'sylius_product')]
431
+ class Product extends BaseProduct implements ProductInterface
432
+ {
433
+ use ProductTrait;
434
+
435
+ /**
436
+ * @ORM\ManyToOne(targetEntity="SyliusMolliePlugin\Entity\ProductType")
437
+ * @ORM\JoinColumn(name="product_type_id", referencedColumnName="id", onDelete="SET NULL")
438
+ */
439
+ #[ORM\ManyToOne(targetEntity: ProductType::class)]
440
+ #[ORM\JoinColumn(name: "product_type_id", referencedColumnName: "id", onDelete: "SET NULL")]
441
+ protected ?ProductType $productType = null;
442
+ }
443
+
250
444
```
251
445
252
446
If you don't use annotations, you can also define new Entity mapping inside your ` src/Resources/config/doctrine ` directory.
@@ -379,6 +573,104 @@ trait RecurringProductVariantTrait
379
573
}
380
574
}
381
575
```
576
+ In case if you have installed Sylius version 1.13.x, use the following code instead
577
+ ``` php
578
+ <?php
579
+
580
+ declare(strict_types=1);
581
+
582
+ namespace App\Entity\Product;
583
+
584
+ use Doctrine\ORM\Mapping as ORM;
585
+ use Sylius\Component\Core\Model\ProductVariant as BaseProductVariant;
586
+ use Sylius\Component\Product\Model\ProductVariantTranslationInterface;
587
+
588
+ /**
589
+ * @ORM\Entity
590
+ * @ORM\Table(name="sylius_product_variant")
591
+ */
592
+ #[ORM\Entity]
593
+ #[ORM\Table(name: 'sylius_product_variant')]
594
+ class ProductVariant extends BaseProductVariant
595
+ {
596
+ use RecurringProductVariantTrait;
597
+
598
+ protected function createTranslation(): ProductVariantTranslationInterface
599
+ {
600
+ return new ProductVariantTranslation();
601
+ }
602
+
603
+ public function getName(): ?string
604
+ {
605
+ return parent::getName() ?: $this->getProduct()->getName();
606
+ }
607
+ }
608
+
609
+ ```
610
+ Add RecurringProductVariantTrait implementation:
611
+ ``` php
612
+ <?php
613
+
614
+ declare(strict_types=1);
615
+
616
+ namespace App\Entity\Product;
617
+
618
+ use Doctrine\ORM\Mapping as ORM;
619
+
620
+ trait RecurringProductVariantTrait
621
+ {
622
+ /**
623
+ * @var bool
624
+ * @ORM\Column(type="boolean", name="recurring", nullable="false", options={"default":0})
625
+ */
626
+ #[ORM\Column(name: "recurring", type: "boolean", nullable: false, options: ['default' => 0])]
627
+ private bool $recurring = false;
628
+
629
+ /**
630
+ * @var ?int
631
+ * @ORM\Column(type="integer", name="recurring_times", nullable="true")
632
+ */
633
+ #[ORM\Column(name: "recurring_times", type: "integer", nullable: true)]
634
+ private ?int $times = null;
635
+
636
+ /**
637
+ * @var ?string
638
+ * @ORM\Column(type="string", name="recurring_interval", nullable="true")
639
+ */
640
+ #[ORM\Column(name: "recurring_interval", type: "string", nullable: true)]
641
+ private ?string $interval = null;
642
+
643
+ public function isRecurring(): bool
644
+ {
645
+ return $this->recurring;
646
+ }
647
+
648
+ public function setRecurring(bool $recurring): void
649
+ {
650
+ $this->recurring = $recurring;
651
+ }
652
+
653
+ public function getTimes(): ?int
654
+ {
655
+ return $this->times;
656
+ }
657
+
658
+ public function setTimes(?int $times): void
659
+ {
660
+ $this->times = $times;
661
+ }
662
+
663
+ public function getInterval(): ?string
664
+ {
665
+ return $this->interval;
666
+ }
667
+
668
+ public function setInterval(?string $interval): void
669
+ {
670
+ $this->interval = $interval;
671
+ }
672
+ }
673
+ ```
382
674
383
675
If you don't use annotations, you can also define new Entity mapping inside your ` src/Resources/config/doctrine ` directory.
384
676
@@ -467,6 +759,9 @@ sylius_mollie_plugin:
467
759
468
760
# ### 12. Update your database
469
761
762
+ In case if you have installed Sylius 1.13.x version, you will need to first remove { resource : " @SyliusRefundPlugin/Resources/config/app/config.yml" }
763
+ from acme/config/packages/sylius_refund.yaml
764
+
470
765
Apply migration to your database : (this is for the plugin fresh installation only)
471
766
` ` `
472
767
bin/console doctrine:migrations:migrate
0 commit comments