diff --git a/README.md b/README.md
index 06640650..31fc876d 100644
--- a/README.md
+++ b/README.md
@@ -120,8 +120,9 @@ class OrderItem extends BaseOrderItem implements OrderItemInterface
bin/console sylius:fixtures:load
```
-* Finally, update the database and update the translations:
+* Finally, generate migrations, update the database and update the translations:
```bash
+bin/console doctrine:migrations:diff
bin/console doctrine:migrations:migrate
bin/console translation:update
```
diff --git a/UPGRADE-4.md b/UPGRADE-4.md
new file mode 100644
index 00000000..d6cd53f9
--- /dev/null
+++ b/UPGRADE-4.md
@@ -0,0 +1,4 @@
+# Upgrade to 4
+
+- Doctrine entities have been updated to use Attributes instead of XML mappings.
+- The bundle no longer includes migrations. These should be generated in your project.
diff --git a/src/DependencyInjection/Brille24SyliusCustomerOptionsExtension.php b/src/DependencyInjection/Brille24SyliusCustomerOptionsExtension.php
index a5bd1386..f4481be8 100644
--- a/src/DependencyInjection/Brille24SyliusCustomerOptionsExtension.php
+++ b/src/DependencyInjection/Brille24SyliusCustomerOptionsExtension.php
@@ -19,7 +19,7 @@
use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface;
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
-final class Brille24SyliusCustomerOptionsExtension extends Extension implements PrependExtensionInterface
+final class Brille24SyliusCustomerOptionsExtension extends Extension
{
/**
* @inheritdoc
@@ -34,25 +34,6 @@ public function load(array $config, ContainerBuilder $container): void
new YamlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config/app'));
}
- public function prepend(ContainerBuilder $container): void
- {
- if (!$container->hasExtension('doctrine_migrations') || !$container->hasExtension('sylius_labs_doctrine_migrations_extra')) {
- return;
- }
-
- $container->prependExtensionConfig('doctrine_migrations', [
- 'migrations_paths' => [
- 'Brille24\SyliusCustomerOptionsPlugin\Migrations' => '@Brille24SyliusCustomerOptionsPlugin/Migrations',
- ],
- ]);
-
- $container->prependExtensionConfig('sylius_labs_doctrine_migrations_extra', [
- 'migrations' => [
- 'Brille24\SyliusCustomerOptionsPlugin\Migrations' => ['Sylius\Bundle\CoreBundle\Migrations'],
- ],
- ]);
- }
-
public function getConfiguration(array $config, ContainerBuilder $container): ConfigurationInterface
{
return new Configuration();
diff --git a/src/Entity/CustomerOptions/CustomerOption.php b/src/Entity/CustomerOptions/CustomerOption.php
index d045a166..343ab26e 100644
--- a/src/Entity/CustomerOptions/CustomerOption.php
+++ b/src/Entity/CustomerOptions/CustomerOption.php
@@ -14,11 +14,16 @@
use Brille24\SyliusCustomerOptionsPlugin\Entity\OrderItemOptionInterface;
use Brille24\SyliusCustomerOptionsPlugin\Enumerations\CustomerOptionTypeEnum;
+use Brille24\SyliusCustomerOptionsPlugin\Repository\CustomerOptionRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
+use Doctrine\DBAL\Types\JsonType;
+use Doctrine\ORM\Mapping as ORM;
use Sylius\Component\Resource\Model\TranslatableTrait;
use Sylius\Component\Resource\Model\TranslationInterface;
+#[ORM\Entity(repositoryClass: CustomerOptionRepository::class)]
+#[ORM\Table(name: 'brille24_customer_option')]
class CustomerOption implements CustomerOptionInterface
{
use TranslatableTrait {
@@ -26,22 +31,35 @@ class CustomerOption implements CustomerOptionInterface
getTranslation as private doGetTranslation;
}
+ #[ORM\Id]
+ #[ORM\GeneratedValue(strategy: 'AUTO')]
+ #[ORM\Column(type: 'integer')]
protected ?int $id = null;
+ #[ORM\Column(type: 'string', nullable: false)]
protected string $type = CustomerOptionTypeEnum::SELECT;
+ #[ORM\Column(type: 'string', unique: true, nullable: false)]
protected ?string $code = '';
+ #[ORM\Column(type: 'boolean')]
protected bool $required = false;
/** @var Collection|CustomerOptionValueInterface[] */
+ #[ORM\OneToMany(targetEntity: CustomerOptionValueInterface::class, mappedBy: 'customerOption', orphanRemoval: true, cascade: ['persist', 'remove'])]
+ #[ORM\OrderBy(['id' => 'ASC'])]
protected Collection $values;
+ #[ORM\Column(type: 'json')]
protected array $configuration = [];
+ /** @var Collection|CustomerOptionAssociationInterface[] */
+ #[ORM\OneToMany(targetEntity: CustomerOptionAssociationInterface::class, mappedBy: 'option', orphanRemoval: true, cascade: ['persist'])]
+ #[ORM\OrderBy(['position' => 'ASC'])]
protected Collection $groupAssociations;
/** @var Collection|OrderItemOptionInterface[] */
+ #[ORM\OneToMany(targetEntity: OrderItemOptionInterface::class, mappedBy: 'customerOption')]
protected Collection $orders;
public function __construct()
diff --git a/src/Entity/CustomerOptions/CustomerOptionAssociation.php b/src/Entity/CustomerOptions/CustomerOptionAssociation.php
index 281f3060..d0519669 100644
--- a/src/Entity/CustomerOptions/CustomerOptionAssociation.php
+++ b/src/Entity/CustomerOptions/CustomerOptionAssociation.php
@@ -12,6 +12,8 @@
namespace Brille24\SyliusCustomerOptionsPlugin\Entity\CustomerOptions;
+use Doctrine\ORM\Mapping as ORM;
+
/**
* Class CustomerOptionAssociation
* This class is used as an association between the Customer Option Group and the customer option ordering them by
@@ -20,17 +22,26 @@
* @see CustomerOption
* @see CustomerOptionGroup
*/
+#[ORM\Entity]
+#[ORM\Table(name: 'brille24_customer_option_association')]
+#[ORM\UniqueConstraint(name: 'option_group_unique', columns: ['option_id', 'group_id'])]
class CustomerOptionAssociation implements CustomerOptionAssociationInterface
{
+ #[ORM\Id]
+ #[ORM\GeneratedValue(strategy: 'AUTO')]
+ #[ORM\Column(type: 'integer')]
protected ?int $id = null;
+ #[ORM\ManyToOne(targetEntity: CustomerOptionGroupInterface::class, cascade: ['persist'], inversedBy: 'optionAssociations')]
+ #[ORM\JoinColumn(nullable: false, onDelete: 'CASCADE')]
protected ?CustomerOptionGroupInterface $group = null;
+ #[ORM\ManyToOne(targetEntity: CustomerOptionInterface::class, cascade: ['persist'], inversedBy: 'groupAssociations')]
+ #[ORM\JoinColumn(nullable: false, onDelete: 'CASCADE')]
protected ?CustomerOptionInterface $option = null;
- public function __construct(protected int $position = 0)
- {
- }
+ #[ORM\Column(type: 'integer')]
+ protected int $position = 0;
/**
* @inheritdoc
diff --git a/src/Entity/CustomerOptions/CustomerOptionGroup.php b/src/Entity/CustomerOptions/CustomerOptionGroup.php
index c982da1c..7ade5213 100644
--- a/src/Entity/CustomerOptions/CustomerOptionGroup.php
+++ b/src/Entity/CustomerOptions/CustomerOptionGroup.php
@@ -14,11 +14,15 @@
use Brille24\SyliusCustomerOptionsPlugin\Entity\CustomerOptions\Validator\ValidatorInterface;
use Brille24\SyliusCustomerOptionsPlugin\Entity\ProductInterface;
+use Brille24\SyliusCustomerOptionsPlugin\Repository\CustomerOptionGroupRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Sylius\Component\Resource\Model\TranslatableTrait;
use Sylius\Component\Resource\Model\TranslationInterface;
+use Doctrine\ORM\Mapping as ORM;
+#[ORM\Entity(repositoryClass: CustomerOptionGroupRepository::class)]
+#[ORM\Table(name: 'brille24_customer_option_group')]
class CustomerOptionGroup implements CustomerOptionGroupInterface, \Stringable
{
use TranslatableTrait {
@@ -27,18 +31,26 @@ class CustomerOptionGroup implements CustomerOptionGroupInterface, \Stringable
}
/** @var int */
+ #[ORM\Id]
+ #[ORM\GeneratedValue(strategy: 'AUTO')]
+ #[ORM\Column(type: 'integer')]
protected $id;
/** @var string|null */
+ #[ORM\Column(type: 'string', nullable: true)]
protected $code;
/** @var Collection */
+ #[ORM\OneToMany(mappedBy: 'group', targetEntity: CustomerOptionAssociationInterface::class, cascade: ['persist', 'remove'], orphanRemoval: true)]
+ #[ORM\OrderBy(['position' => 'ASC'])]
protected $optionAssociations;
/** @var ArrayCollection */
+ #[ORM\OneToMany(mappedBy: 'customerOptionGroup', targetEntity: ProductInterface::class)]
protected $products;
/** @var ArrayCollection */
+ #[ORM\OneToMany(mappedBy: 'customerOptionGroup', targetEntity: ValidatorInterface::class, cascade: ['persist', 'remove'])]
protected $validators;
public function __construct()
diff --git a/src/Entity/CustomerOptions/CustomerOptionGroupTranslation.php b/src/Entity/CustomerOptions/CustomerOptionGroupTranslation.php
index 1add26db..a77ca7ad 100644
--- a/src/Entity/CustomerOptions/CustomerOptionGroupTranslation.php
+++ b/src/Entity/CustomerOptions/CustomerOptionGroupTranslation.php
@@ -12,14 +12,26 @@
namespace Brille24\SyliusCustomerOptionsPlugin\Entity\CustomerOptions;
+use Doctrine\ORM\Mapping as ORM;
use Sylius\Component\Resource\Model\AbstractTranslation;
+use Sylius\Component\Resource\Model\TranslatableInterface;
+#[ORM\Entity]
+#[ORM\Table(name: 'brille24_customer_option_group_translation')]
class CustomerOptionGroupTranslation extends AbstractTranslation implements CustomerOptionGroupTranslationInterface
{
+ #[ORM\Id]
+ #[ORM\GeneratedValue(strategy: 'AUTO')]
+ #[ORM\Column(type: 'integer')]
protected ?int $id = null;
+ #[ORM\Column(type: 'string', nullable: true)]
protected ?string $name = null;
+ #[ORM\ManyToOne(targetEntity: CustomerOptionGroupInterface::class, inversedBy: "translations")]
+ #[ORM\JoinColumn(onDelete: "CASCADE")]
+ protected ?TranslatableInterface $translatable = null;
+
public function getId(): ?int
{
return $this->id;
diff --git a/src/Entity/CustomerOptions/CustomerOptionTranslation.php b/src/Entity/CustomerOptions/CustomerOptionTranslation.php
index 5e359a8e..c1a83494 100644
--- a/src/Entity/CustomerOptions/CustomerOptionTranslation.php
+++ b/src/Entity/CustomerOptions/CustomerOptionTranslation.php
@@ -12,14 +12,26 @@
namespace Brille24\SyliusCustomerOptionsPlugin\Entity\CustomerOptions;
+use Doctrine\ORM\Mapping as ORM;
use Sylius\Component\Resource\Model\AbstractTranslation;
+use Sylius\Component\Resource\Model\TranslatableInterface;
+#[ORM\Entity]
+#[ORM\Table(name: 'brille24_customer_option_translation')]
class CustomerOptionTranslation extends AbstractTranslation implements CustomerOptionTranslationInterface
{
+ #[ORM\Id]
+ #[ORM\GeneratedValue(strategy: 'AUTO')]
+ #[ORM\Column(type: 'integer')]
protected ?int $id = null;
+ #[ORM\Column(type: 'string', nullable: true)]
protected ?string $name = null;
+ #[ORM\ManyToOne(targetEntity: CustomerOption::class, inversedBy: 'translations')]
+ #[ORM\JoinColumn(onDelete: 'CASCADE')]
+ protected ?TranslatableInterface $translatable = null;
+
/**
* @inheritdoc
*/
diff --git a/src/Entity/CustomerOptions/CustomerOptionValue.php b/src/Entity/CustomerOptions/CustomerOptionValue.php
index d61db782..77b0c475 100644
--- a/src/Entity/CustomerOptions/CustomerOptionValue.php
+++ b/src/Entity/CustomerOptions/CustomerOptionValue.php
@@ -14,13 +14,18 @@
use Brille24\SyliusCustomerOptionsPlugin\Entity\CustomerOptions\CustomerOptionValuePriceInterface as COValuePriceInterface;
use Brille24\SyliusCustomerOptionsPlugin\Entity\OrderItemOptionInterface;
+use Brille24\SyliusCustomerOptionsPlugin\Repository\CustomerOptionValueRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
+use Doctrine\ORM\Mapping as ORM;
use Sylius\Component\Core\Model\ChannelInterface;
use Sylius\Component\Core\Model\ProductInterface;
use Sylius\Component\Resource\Model\TranslatableTrait;
use Sylius\Component\Resource\Model\TranslationInterface;
+#[ORM\Entity(repositoryClass: CustomerOptionValueRepository::class)]
+#[ORM\Table(name: 'brille24_customer_option_value')]
+#[ORM\UniqueConstraint(name: 'unique_customer_option_code', columns: ['customerOption_id', 'code'])]
class CustomerOptionValue implements CustomerOptionValueInterface, \Stringable
{
use TranslatableTrait {
@@ -28,21 +33,29 @@ class CustomerOptionValue implements CustomerOptionValueInterface, \Stringable
getTranslation as private doGetTranslation;
}
+ #[ORM\Id]
+ #[ORM\GeneratedValue(strategy: 'AUTO')]
+ #[ORM\Column(type: 'integer')]
protected ?int $id = null;
+ #[ORM\Column(type: 'string')]
protected string $code;
+ #[ORM\OneToMany(mappedBy: 'customerOptionValue', targetEntity: COValuePriceInterface::class, cascade: ['persist', 'remove'])]
protected Collection $prices;
+ #[ORM\ManyToOne(targetEntity: CustomerOptionInterface::class, inversedBy: 'values')]
+ #[ORM\JoinColumn(onDelete: 'CASCADE')]
protected ?CustomerOptionInterface $customerOption = null;
- /** @var OrderItemOptionInterface[] */
- protected $orders;
+ #[ORM\OneToMany(mappedBy: 'customerOptionValue', targetEntity: OrderItemOptionInterface::class)]
+ protected Collection $orders;
public function __construct()
{
$this->initializeTranslationsCollection();
$this->prices = new ArrayCollection();
+ $this->orders = new ArrayCollection();
}
/**
diff --git a/src/Entity/CustomerOptions/CustomerOptionValuePrice.php b/src/Entity/CustomerOptions/CustomerOptionValuePrice.php
index e2098a2e..2234692d 100644
--- a/src/Entity/CustomerOptions/CustomerOptionValuePrice.php
+++ b/src/Entity/CustomerOptions/CustomerOptionValuePrice.php
@@ -13,28 +13,46 @@
namespace Brille24\SyliusCustomerOptionsPlugin\Entity\CustomerOptions;
use Brille24\SyliusCustomerOptionsPlugin\Entity\ProductInterface;
+use Brille24\SyliusCustomerOptionsPlugin\Entity\Tools\DateRange;
use Brille24\SyliusCustomerOptionsPlugin\Entity\Tools\DateRangeInterface;
+use Doctrine\ORM\Mapping as ORM;
use Sylius\Bundle\MoneyBundle\Formatter\MoneyFormatter;
use Sylius\Bundle\MoneyBundle\Formatter\MoneyFormatterInterface;
use Sylius\Component\Core\Model\ChannelInterface;
use Symfony\Component\Config\Definition\Exception\InvalidTypeException;
+#[ORM\Entity]
+#[ORM\Table(name: 'brille24_customer_option_value_price')]
class CustomerOptionValuePrice implements CustomerOptionValuePriceInterface, \Stringable
{
+ #[ORM\Id]
+ #[ORM\GeneratedValue(strategy: 'AUTO')]
+ #[ORM\Column(type: 'integer')]
protected ?int $id = null;
+ #[ORM\Column(type: 'float')]
protected float $percent = 0;
+ #[ORM\Column(type: 'integer')]
protected int $amount = 0;
+ #[ORM\Column(type: 'string', length: 12)]
protected string $type = CustomerOptionValuePriceInterface::TYPE_FIXED_AMOUNT;
+ #[ORM\ManyToOne(targetEntity: CustomerOptionValueInterface::class, cascade: ['persist'], inversedBy: 'prices')]
+ #[ORM\JoinColumn(onDelete: 'CASCADE')]
protected ?CustomerOptionValueInterface $customerOptionValue = null;
+ #[ORM\ManyToOne(targetEntity: ChannelInterface::class)]
+ #[ORM\JoinColumn(onDelete: 'CASCADE')]
protected ?ProductInterface $product = null;
+ #[ORM\ManyToOne(targetEntity: ChannelInterface::class)]
+ #[ORM\JoinColumn(onDelete: 'CASCADE')]
protected ?ChannelInterface $channel = null;
+ #[ORM\OneToOne(targetEntity: DateRange::class, cascade: ['all'])]
+ #[ORM\JoinColumn(nullable: true)]
protected ?DateRangeInterface $dateValid = null;
public function getId(): ?int
diff --git a/src/Entity/CustomerOptions/CustomerOptionValueTranslation.php b/src/Entity/CustomerOptions/CustomerOptionValueTranslation.php
index c897099b..cc6d1741 100644
--- a/src/Entity/CustomerOptions/CustomerOptionValueTranslation.php
+++ b/src/Entity/CustomerOptions/CustomerOptionValueTranslation.php
@@ -12,14 +12,26 @@
namespace Brille24\SyliusCustomerOptionsPlugin\Entity\CustomerOptions;
+use Doctrine\ORM\Mapping as ORM;
use Sylius\Component\Resource\Model\AbstractTranslation;
+use Sylius\Component\Resource\Model\TranslatableInterface;
+#[ORM\Entity]
+#[ORM\Table(name: 'brille24_customer_option_value_translation')]
class CustomerOptionValueTranslation extends AbstractTranslation implements CustomerOptionValueTranslationInterface
{
+ #[ORM\Id]
+ #[ORM\GeneratedValue(strategy: 'AUTO')]
+ #[ORM\Column(type: 'integer')]
protected ?int $id = null;
+ #[ORM\Column(type: 'string', nullable: true)]
protected ?string $name = null;
+ #[ORM\ManyToOne(targetEntity: CustomerOptionValueInterface::class, inversedBy: "translations")]
+ #[ORM\JoinColumn(onDelete: 'CASCADE')]
+ protected ?TranslatableInterface $translatable = null;
+
/**
* @inheritdoc
*/
diff --git a/src/Entity/CustomerOptions/Validator/Condition.php b/src/Entity/CustomerOptions/Validator/Condition.php
index a5c98880..da2e8579 100644
--- a/src/Entity/CustomerOptions/Validator/Condition.php
+++ b/src/Entity/CustomerOptions/Validator/Condition.php
@@ -5,11 +5,17 @@
namespace Brille24\SyliusCustomerOptionsPlugin\Entity\CustomerOptions\Validator;
use Brille24\SyliusCustomerOptionsPlugin\Traits\ConditionTrait;
+use Doctrine\ORM\Mapping as ORM;
+#[ORM\Entity]
+#[ORM\Table(name: 'brille24_customer_option_group_validator_condition')]
class Condition implements ConditionInterface
{
use ConditionTrait;
+ #[ORM\Id]
+ #[ORM\GeneratedValue]
+ #[ORM\Column(type: 'integer')]
protected ?int $id = null;
public function getId(): ?int
diff --git a/src/Entity/CustomerOptions/Validator/Constraint.php b/src/Entity/CustomerOptions/Validator/Constraint.php
index e1874365..0ff23503 100644
--- a/src/Entity/CustomerOptions/Validator/Constraint.php
+++ b/src/Entity/CustomerOptions/Validator/Constraint.php
@@ -5,11 +5,17 @@
namespace Brille24\SyliusCustomerOptionsPlugin\Entity\CustomerOptions\Validator;
use Brille24\SyliusCustomerOptionsPlugin\Traits\ConditionTrait;
+use Doctrine\ORM\Mapping as ORM;
+#[ORM\Entity]
+#[ORM\Table(name: 'brille24_customer_option_group_validator_constraint')]
class Constraint implements ConstraintInterface
{
use ConditionTrait;
+ #[ORM\Id]
+ #[ORM\GeneratedValue]
+ #[ORM\Column(type: 'integer')]
protected ?int $id = null;
public function getId(): ?int
diff --git a/src/Entity/CustomerOptions/Validator/ErrorMessage.php b/src/Entity/CustomerOptions/Validator/ErrorMessage.php
index 180bc1ab..b1e636fa 100644
--- a/src/Entity/CustomerOptions/Validator/ErrorMessage.php
+++ b/src/Entity/CustomerOptions/Validator/ErrorMessage.php
@@ -4,17 +4,25 @@
namespace Brille24\SyliusCustomerOptionsPlugin\Entity\CustomerOptions\Validator;
+use Doctrine\ORM\Mapping as ORM;
use Sylius\Component\Resource\Model\TranslatableTrait;
use Sylius\Component\Resource\Model\TranslationInterface;
+#[ORM\Entity]
+#[ORM\Table(name: 'brille24_validator_error_message')]
class ErrorMessage implements ErrorMessageInterface
{
use TranslatableTrait {
__construct as protected initializeTranslationsCollection;
}
+ #[ORM\Id]
+ #[ORM\GeneratedValue]
+ #[ORM\Column(type: 'integer')]
protected int $id;
+ #[ORM\OneToOne(targetEntity: ValidatorInterface::class)]
+ #[ORM\JoinColumn(onDelete: 'CASCADE')]
protected ValidatorInterface $validator;
public function __construct()
diff --git a/src/Entity/CustomerOptions/Validator/ErrorMessageTranslation.php b/src/Entity/CustomerOptions/Validator/ErrorMessageTranslation.php
index 7a5f550d..d129bb68 100644
--- a/src/Entity/CustomerOptions/Validator/ErrorMessageTranslation.php
+++ b/src/Entity/CustomerOptions/Validator/ErrorMessageTranslation.php
@@ -4,14 +4,26 @@
namespace Brille24\SyliusCustomerOptionsPlugin\Entity\CustomerOptions\Validator;
+use Doctrine\ORM\Mapping as ORM;
use Sylius\Component\Resource\Model\AbstractTranslation;
+use Sylius\Component\Resource\Model\TranslatableInterface;
+#[ORM\Entity]
+#[ORM\Table(name: 'brille24_validator_error_message_translation')]
class ErrorMessageTranslation extends AbstractTranslation implements ErrorMessageTranslationInterface
{
+ #[ORM\Id]
+ #[ORM\GeneratedValue]
+ #[ORM\Column(type: 'integer')]
protected ?int $id = null;
+ #[ORM\Column(type: 'text', nullable: true)]
protected ?string $message = null;
+ #[ORM\ManyToOne(targetEntity: ErrorMessageInterface::class, inversedBy: 'translations')]
+ #[ORM\JoinColumn(onDelete: 'CASCADE')]
+ protected ?TranslatableInterface $translatable = null;
+
public function getId(): ?int
{
return $this->id;
diff --git a/src/Entity/CustomerOptions/Validator/Validator.php b/src/Entity/CustomerOptions/Validator/Validator.php
index acb54a8a..d4a3ee5f 100644
--- a/src/Entity/CustomerOptions/Validator/Validator.php
+++ b/src/Entity/CustomerOptions/Validator/Validator.php
@@ -7,24 +7,36 @@
use Brille24\SyliusCustomerOptionsPlugin\Entity\CustomerOptions\CustomerOptionGroupInterface;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
+use Doctrine\ORM\Mapping as ORM;
+#[ORM\Entity]
+#[ORM\Table(name: 'brille24_customer_option_group_validator')]
class Validator implements ValidatorInterface
{
public const DEFAULT_ERROR_MESSAGE = 'This combination of values is not valid.';
/** @var int */
+ #[ORM\Id]
+ #[ORM\GeneratedValue]
+ #[ORM\Column(type: 'integer')]
protected $id;
/** @var Collection */
+ #[ORM\OneToMany(targetEntity: ConditionInterface::class, mappedBy: 'validator', orphanRemoval: true, cascade: ['all'])]
protected $conditions;
/** @var Collection */
+ #[ORM\OneToMany(targetEntity: ConstraintInterface::class, mappedBy: 'validator', orphanRemoval: true, cascade: ['all'])]
protected $constraints;
/** @var CustomerOptionGroupInterface|null */
+ #[ORM\ManyToOne(targetEntity: CustomerOptionGroupInterface::class, inversedBy: 'validators')]
+ #[ORM\JoinColumn(onDelete: 'CASCADE')]
protected $customerOptionGroup;
/** @var ErrorMessageInterface */
+ #[ORM\OneToOne(targetEntity: ErrorMessage::class, cascade: ['all'])]
+ #[ORM\JoinColumn(onDelete: 'SET NULL')]
protected $errorMessage;
public function __construct()
diff --git a/src/Entity/FileContent.php b/src/Entity/FileContent.php
index 1c36c84e..d4006668 100644
--- a/src/Entity/FileContent.php
+++ b/src/Entity/FileContent.php
@@ -4,14 +4,24 @@
namespace Brille24\SyliusCustomerOptionsPlugin\Entity;
+use Doctrine\ORM\Mapping as ORM;
use Sylius\Component\Resource\Model\ResourceInterface;
+#[ORM\Entity]
+#[ORM\Table(name: 'brille24_customer_option_file_content')]
class FileContent implements ResourceInterface, \Stringable
{
+ #[ORM\Id]
+ #[ORM\GeneratedValue]
+ #[ORM\Column(type: 'integer')]
protected ?int $id = null;
- public function __construct(protected string $content)
+ #[ORM\Column(type: 'text')]
+ protected string $content;
+
+ public function __construct(string $content)
{
+ $this->content = $content;
}
public function getId(): ?int
diff --git a/src/Entity/OrderItem.php b/src/Entity/OrderItem.php
deleted file mode 100644
index 2cb99695..00000000
--- a/src/Entity/OrderItem.php
+++ /dev/null
@@ -1,30 +0,0 @@
-customerOptionCapableConstructor();
- }
-}
diff --git a/src/Entity/OrderItemOption.php b/src/Entity/OrderItemOption.php
index 97f76e68..84182f8a 100644
--- a/src/Entity/OrderItemOption.php
+++ b/src/Entity/OrderItemOption.php
@@ -17,36 +17,59 @@
use Brille24\SyliusCustomerOptionsPlugin\Entity\CustomerOptions\CustomerOptionValuePrice;
use Brille24\SyliusCustomerOptionsPlugin\Entity\CustomerOptions\CustomerOptionValuePriceInterface;
use Brille24\SyliusCustomerOptionsPlugin\Enumerations\CustomerOptionTypeEnum;
+use Doctrine\ORM\Mapping as ORM;
use Webmozart\Assert\Assert;
+#[ORM\Entity]
+#[ORM\Table(name: 'brille24_customer_option_order_item_option')]
class OrderItemOption implements OrderItemOptionInterface, \Stringable
{
+ #[ORM\Id]
+ #[ORM\GeneratedValue(strategy: 'AUTO')]
+ #[ORM\Column(type: 'integer')]
protected ?int $id = null;
+ #[ORM\ManyToOne(targetEntity: OrderItemInterface::class, inversedBy: 'configuration')]
+ #[ORM\JoinColumn(onDelete: 'CASCADE')]
protected OrderItemInterface $orderItem;
+ #[ORM\ManyToOne(targetEntity: CustomerOptionInterface::class, inversedBy: 'orders')]
+ #[ORM\JoinColumn(nullable: true, onDelete: 'SET NULL')]
protected ?CustomerOptionInterface $customerOption = null;
+ #[ORM\Column(type: 'string')]
protected string $customerOptionType;
+ #[ORM\Column(type: 'string')]
protected string $customerOptionCode;
+ #[ORM\Column(type: 'string')]
protected string $customerOptionName;
+ #[ORM\ManyToOne(targetEntity: CustomerOptionValueInterface::class, inversedBy: 'orders')]
+ #[ORM\JoinColumn(nullable: true, onDelete: 'SET NULL')]
protected ?CustomerOptionValueInterface $customerOptionValue = null;
+ #[ORM\Column(type: 'string', nullable: true)]
protected ?string $customerOptionValueCode = null;
+ #[ORM\Column(type: 'string', nullable: true)]
protected ?string $customerOptionValueName = null;
+ #[ORM\Column(type: 'string', nullable: true)]
protected ?string $optionValue = null;
+ #[ORM\Column(type: 'integer')]
protected int $fixedPrice = 0;
+ #[ORM\Column(type: 'string')]
protected string $pricingType = '';
+ #[ORM\Column(type: 'float')]
protected float $percent = 0;
+ #[ORM\OneToOne(targetEntity: FileContent::class, cascade: ['all'])]
+ #[ORM\JoinColumn(nullable: true)]
protected ?FileContent $fileContent = null;
/** @inheritdoc */
diff --git a/src/Entity/Product.php b/src/Entity/Product.php
deleted file mode 100644
index 511da64b..00000000
--- a/src/Entity/Product.php
+++ /dev/null
@@ -1,30 +0,0 @@
-customerOptionCapableConstructor();
- }
-}
diff --git a/src/Entity/Tools/DateRange.php b/src/Entity/Tools/DateRange.php
index 63270b88..5b453c14 100644
--- a/src/Entity/Tools/DateRange.php
+++ b/src/Entity/Tools/DateRange.php
@@ -4,15 +4,23 @@
namespace Brille24\SyliusCustomerOptionsPlugin\Entity\Tools;
+use Doctrine\ORM\Mapping as ORM;
use DateTimeInterface;
use InvalidArgumentException;
+#[ORM\Entity]
+#[ORM\Table(name: 'brille24_customer_option_date_range')]
class DateRange implements DateRangeInterface, \Stringable
{
+ #[ORM\Id]
+ #[ORM\GeneratedValue]
+ #[ORM\Column(type: 'integer')]
private ?int $id = null;
+ #[ORM\Column(type: 'datetime')]
private DateTimeInterface $start;
+ #[ORM\Column(type: 'datetime')]
private DateTimeInterface $end;
public function getId(): ?int
diff --git a/src/Migrations/Version20191010092726.php b/src/Migrations/Version20191010092726.php
deleted file mode 100644
index bb1b1e10..00000000
--- a/src/Migrations/Version20191010092726.php
+++ /dev/null
@@ -1,104 +0,0 @@
-addSql('CREATE TABLE brille24_customer_option (id INT AUTO_INCREMENT NOT NULL, type VARCHAR(255) NOT NULL, configuration LONGTEXT NOT NULL COMMENT \'(DC2Type:json_array)\', code VARCHAR(255) NOT NULL, required TINYINT(1) NOT NULL, UNIQUE INDEX UNIQ_1E7F7D0677153098 (code), PRIMARY KEY(id)) DEFAULT CHARACTER SET UTF8 COLLATE `UTF8_unicode_ci` ENGINE = InnoDB');
- $this->addSql('CREATE TABLE brille24_customer_option_association (id INT AUTO_INCREMENT NOT NULL, option_id INT NOT NULL, group_id INT NOT NULL, position INT NOT NULL, INDEX IDX_1AF36ED0A7C41D6F (option_id), INDEX IDX_1AF36ED0FE54D947 (group_id), UNIQUE INDEX UNIQ_1AF36ED0A7C41D6FFE54D947 (option_id, group_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET UTF8 COLLATE `UTF8_unicode_ci` ENGINE = InnoDB');
- $this->addSql('CREATE TABLE brille24_customer_option_date_range (id INT AUTO_INCREMENT NOT NULL, start DATETIME NOT NULL, end DATETIME NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET UTF8 COLLATE `UTF8_unicode_ci` ENGINE = InnoDB');
- $this->addSql('CREATE TABLE brille24_customer_option_group (id INT AUTO_INCREMENT NOT NULL, code VARCHAR(255) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET UTF8 COLLATE `UTF8_unicode_ci` ENGINE = InnoDB');
- $this->addSql('CREATE TABLE brille24_customer_option_group_translation (id INT AUTO_INCREMENT NOT NULL, translatable_id INT DEFAULT NULL, name VARCHAR(255) DEFAULT NULL, locale VARCHAR(255) NOT NULL, INDEX IDX_DD9F6EB32C2AC5D3 (translatable_id), UNIQUE INDEX brille24_customer_option_group_translation_uniq_trans (translatable_id, locale), PRIMARY KEY(id)) DEFAULT CHARACTER SET UTF8 COLLATE `UTF8_unicode_ci` ENGINE = InnoDB');
- $this->addSql('CREATE TABLE brille24_customer_option_group_validator (id INT AUTO_INCREMENT NOT NULL, errorMessage_id INT DEFAULT NULL, customerOptionGroup_id INT DEFAULT NULL, UNIQUE INDEX UNIQ_1C13475874E6266C (errorMessage_id), INDEX IDX_1C1347586DCF05EC (customerOptionGroup_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET UTF8 COLLATE `UTF8_unicode_ci` ENGINE = InnoDB');
- $this->addSql('CREATE TABLE brille24_customer_option_group_validator_condition (id INT AUTO_INCREMENT NOT NULL, validator_id INT DEFAULT NULL, comparator VARCHAR(255) NOT NULL, value LONGTEXT DEFAULT NULL COMMENT \'(DC2Type:json_array)\', customerOption_id INT DEFAULT NULL, INDEX IDX_B230415EB0644AEC (validator_id), INDEX IDX_B230415E27309983 (customerOption_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET UTF8 COLLATE `UTF8_unicode_ci` ENGINE = InnoDB');
- $this->addSql('CREATE TABLE brille24_customer_option_group_validator_constraint (id INT AUTO_INCREMENT NOT NULL, validator_id INT DEFAULT NULL, comparator VARCHAR(255) NOT NULL, value LONGTEXT DEFAULT NULL COMMENT \'(DC2Type:json_array)\', customerOption_id INT DEFAULT NULL, INDEX IDX_5A4304E2B0644AEC (validator_id), INDEX IDX_5A4304E227309983 (customerOption_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET UTF8 COLLATE `UTF8_unicode_ci` ENGINE = InnoDB');
- $this->addSql('CREATE TABLE brille24_customer_option_order_item_option (id INT AUTO_INCREMENT NOT NULL, customerOptionCode VARCHAR(255) NOT NULL, customerOptionName VARCHAR(255) NOT NULL, customerOptionValueCode VARCHAR(255) DEFAULT NULL, customerOptionValueName VARCHAR(255) DEFAULT NULL, optionValue LONGTEXT DEFAULT NULL, fixedPrice INT NOT NULL, percent DOUBLE PRECISION NOT NULL, pricingType VARCHAR(255) NOT NULL, orderItem_id INT DEFAULT NULL, customerOption_id INT DEFAULT NULL, customerOptionValue_id INT DEFAULT NULL, INDEX IDX_8B833EE4E76E9C94 (orderItem_id), INDEX IDX_8B833EE427309983 (customerOption_id), INDEX IDX_8B833EE46ABB6709 (customerOptionValue_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET UTF8 COLLATE `UTF8_unicode_ci` ENGINE = InnoDB');
- $this->addSql('CREATE TABLE brille24_customer_option_translation (id INT AUTO_INCREMENT NOT NULL, translatable_id INT DEFAULT NULL, name VARCHAR(255) DEFAULT NULL, locale VARCHAR(255) NOT NULL, INDEX IDX_531F0A732C2AC5D3 (translatable_id), UNIQUE INDEX brille24_customer_option_translation_uniq_trans (translatable_id, locale), PRIMARY KEY(id)) DEFAULT CHARACTER SET UTF8 COLLATE `UTF8_unicode_ci` ENGINE = InnoDB');
- $this->addSql('CREATE TABLE brille24_customer_option_value (id INT AUTO_INCREMENT NOT NULL, code VARCHAR(255) NOT NULL, customerOption_id INT DEFAULT NULL, INDEX IDX_65B04D7B27309983 (customerOption_id), UNIQUE INDEX UNIQ_65B04D7B2730998377153098 (customerOption_id, code), PRIMARY KEY(id)) DEFAULT CHARACTER SET UTF8 COLLATE `UTF8_unicode_ci` ENGINE = InnoDB');
- $this->addSql('CREATE TABLE brille24_customer_option_value_price (id INT AUTO_INCREMENT NOT NULL, channel_id INT DEFAULT NULL, product_id INT DEFAULT NULL, percent DOUBLE PRECISION NOT NULL, amount INT NOT NULL, type VARCHAR(12) NOT NULL, dateValid_id INT DEFAULT NULL, customerOptionValue_id INT DEFAULT NULL, UNIQUE INDEX UNIQ_D218E8EE50552292 (dateValid_id), INDEX IDX_D218E8EE6ABB6709 (customerOptionValue_id), INDEX IDX_D218E8EE72F5A1AA (channel_id), INDEX IDX_D218E8EE4584665A (product_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET UTF8 COLLATE `UTF8_unicode_ci` ENGINE = InnoDB');
- $this->addSql('CREATE TABLE brille24_customer_option_value_translation (id INT AUTO_INCREMENT NOT NULL, translatable_id INT DEFAULT NULL, name VARCHAR(255) DEFAULT NULL, locale VARCHAR(255) NOT NULL, INDEX IDX_3AD2C9512C2AC5D3 (translatable_id), UNIQUE INDEX brille24_customer_option_value_translation_uniq_trans (translatable_id, locale), PRIMARY KEY(id)) DEFAULT CHARACTER SET UTF8 COLLATE `UTF8_unicode_ci` ENGINE = InnoDB');
- $this->addSql('CREATE TABLE brille24_validator_error_message (id INT AUTO_INCREMENT NOT NULL, validator_id INT DEFAULT NULL, UNIQUE INDEX UNIQ_5535DA3B0644AEC (validator_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET UTF8 COLLATE `UTF8_unicode_ci` ENGINE = InnoDB');
- $this->addSql('CREATE TABLE brille24_validator_error_message_translation (id INT AUTO_INCREMENT NOT NULL, translatable_id INT DEFAULT NULL, message VARCHAR(255) DEFAULT NULL, locale VARCHAR(255) NOT NULL, INDEX IDX_4E22795E2C2AC5D3 (translatable_id), UNIQUE INDEX brille24_validator_error_message_translation_uniq_trans (translatable_id, locale), PRIMARY KEY(id)) DEFAULT CHARACTER SET UTF8 COLLATE `UTF8_unicode_ci` ENGINE = InnoDB');
- $this->addSql('ALTER TABLE brille24_customer_option_association ADD CONSTRAINT FK_1AF36ED0A7C41D6F FOREIGN KEY (option_id) REFERENCES brille24_customer_option (id) ON DELETE CASCADE');
- $this->addSql('ALTER TABLE brille24_customer_option_association ADD CONSTRAINT FK_1AF36ED0FE54D947 FOREIGN KEY (group_id) REFERENCES brille24_customer_option_group (id) ON DELETE CASCADE');
- $this->addSql('ALTER TABLE brille24_customer_option_group_translation ADD CONSTRAINT FK_DD9F6EB32C2AC5D3 FOREIGN KEY (translatable_id) REFERENCES brille24_customer_option_group (id)');
- $this->addSql('ALTER TABLE brille24_customer_option_group_validator ADD CONSTRAINT FK_1C13475874E6266C FOREIGN KEY (errorMessage_id) REFERENCES brille24_validator_error_message (id) ON DELETE SET NULL');
- $this->addSql('ALTER TABLE brille24_customer_option_group_validator ADD CONSTRAINT FK_1C1347586DCF05EC FOREIGN KEY (customerOptionGroup_id) REFERENCES brille24_customer_option_group (id)');
- $this->addSql('ALTER TABLE brille24_customer_option_group_validator_condition ADD CONSTRAINT FK_B230415EB0644AEC FOREIGN KEY (validator_id) REFERENCES brille24_customer_option_group_validator (id) ON DELETE CASCADE');
- $this->addSql('ALTER TABLE brille24_customer_option_group_validator_condition ADD CONSTRAINT FK_B230415E27309983 FOREIGN KEY (customerOption_id) REFERENCES brille24_customer_option (id) ON DELETE SET NULL');
- $this->addSql('ALTER TABLE brille24_customer_option_group_validator_constraint ADD CONSTRAINT FK_5A4304E2B0644AEC FOREIGN KEY (validator_id) REFERENCES brille24_customer_option_group_validator (id) ON DELETE CASCADE');
- $this->addSql('ALTER TABLE brille24_customer_option_group_validator_constraint ADD CONSTRAINT FK_5A4304E227309983 FOREIGN KEY (customerOption_id) REFERENCES brille24_customer_option (id) ON DELETE SET NULL');
- $this->addSql('ALTER TABLE brille24_customer_option_order_item_option ADD CONSTRAINT FK_8B833EE4E76E9C94 FOREIGN KEY (orderItem_id) REFERENCES sylius_order_item (id)');
- $this->addSql('ALTER TABLE brille24_customer_option_order_item_option ADD CONSTRAINT FK_8B833EE427309983 FOREIGN KEY (customerOption_id) REFERENCES brille24_customer_option (id) ON DELETE SET NULL');
- $this->addSql('ALTER TABLE brille24_customer_option_order_item_option ADD CONSTRAINT FK_8B833EE46ABB6709 FOREIGN KEY (customerOptionValue_id) REFERENCES brille24_customer_option_value (id) ON DELETE SET NULL');
- $this->addSql('ALTER TABLE brille24_customer_option_translation ADD CONSTRAINT FK_531F0A732C2AC5D3 FOREIGN KEY (translatable_id) REFERENCES brille24_customer_option (id)');
- $this->addSql('ALTER TABLE brille24_customer_option_value ADD CONSTRAINT FK_65B04D7B27309983 FOREIGN KEY (customerOption_id) REFERENCES brille24_customer_option (id)');
- $this->addSql('ALTER TABLE brille24_customer_option_value_price ADD CONSTRAINT FK_D218E8EE50552292 FOREIGN KEY (dateValid_id) REFERENCES brille24_customer_option_date_range (id)');
- $this->addSql('ALTER TABLE brille24_customer_option_value_price ADD CONSTRAINT FK_D218E8EE6ABB6709 FOREIGN KEY (customerOptionValue_id) REFERENCES brille24_customer_option_value (id)');
- $this->addSql('ALTER TABLE brille24_customer_option_value_price ADD CONSTRAINT FK_D218E8EE72F5A1AA FOREIGN KEY (channel_id) REFERENCES sylius_channel (id) ON DELETE CASCADE');
- $this->addSql('ALTER TABLE brille24_customer_option_value_price ADD CONSTRAINT FK_D218E8EE4584665A FOREIGN KEY (product_id) REFERENCES sylius_product (id)');
- $this->addSql('ALTER TABLE brille24_customer_option_value_translation ADD CONSTRAINT FK_3AD2C9512C2AC5D3 FOREIGN KEY (translatable_id) REFERENCES brille24_customer_option_value (id) ON DELETE CASCADE');
- $this->addSql('ALTER TABLE brille24_validator_error_message ADD CONSTRAINT FK_5535DA3B0644AEC FOREIGN KEY (validator_id) REFERENCES brille24_customer_option_group_validator (id) ON DELETE CASCADE');
- $this->addSql('ALTER TABLE brille24_validator_error_message_translation ADD CONSTRAINT FK_4E22795E2C2AC5D3 FOREIGN KEY (translatable_id) REFERENCES brille24_validator_error_message (id) ON DELETE CASCADE');
- $this->addSql('ALTER TABLE sylius_product ADD customerOptionGroup_id INT DEFAULT NULL');
- $this->addSql('ALTER TABLE sylius_product ADD CONSTRAINT FK_677B9B746DCF05EC FOREIGN KEY (customerOptionGroup_id) REFERENCES brille24_customer_option_group (id) ON DELETE SET NULL');
- $this->addSql('CREATE INDEX IDX_677B9B746DCF05EC ON sylius_product (customerOptionGroup_id)');
- }
-
- public function down(Schema $schema): void
- {
- // this down() migration is auto-generated, please modify it to your needs
- $this->addSql('ALTER TABLE brille24_customer_option_association DROP FOREIGN KEY FK_1AF36ED0A7C41D6F');
- $this->addSql('ALTER TABLE brille24_customer_option_group_validator_condition DROP FOREIGN KEY FK_B230415E27309983');
- $this->addSql('ALTER TABLE brille24_customer_option_group_validator_constraint DROP FOREIGN KEY FK_5A4304E227309983');
- $this->addSql('ALTER TABLE brille24_customer_option_order_item_option DROP FOREIGN KEY FK_8B833EE427309983');
- $this->addSql('ALTER TABLE brille24_customer_option_translation DROP FOREIGN KEY FK_531F0A732C2AC5D3');
- $this->addSql('ALTER TABLE brille24_customer_option_value DROP FOREIGN KEY FK_65B04D7B27309983');
- $this->addSql('ALTER TABLE brille24_customer_option_value_price DROP FOREIGN KEY FK_D218E8EE50552292');
- $this->addSql('ALTER TABLE brille24_customer_option_association DROP FOREIGN KEY FK_1AF36ED0FE54D947');
- $this->addSql('ALTER TABLE brille24_customer_option_group_translation DROP FOREIGN KEY FK_DD9F6EB32C2AC5D3');
- $this->addSql('ALTER TABLE brille24_customer_option_group_validator DROP FOREIGN KEY FK_1C1347586DCF05EC');
- $this->addSql('ALTER TABLE sylius_product DROP FOREIGN KEY FK_677B9B746DCF05EC');
- $this->addSql('ALTER TABLE brille24_customer_option_group_validator_condition DROP FOREIGN KEY FK_B230415EB0644AEC');
- $this->addSql('ALTER TABLE brille24_customer_option_group_validator_constraint DROP FOREIGN KEY FK_5A4304E2B0644AEC');
- $this->addSql('ALTER TABLE brille24_validator_error_message DROP FOREIGN KEY FK_5535DA3B0644AEC');
- $this->addSql('ALTER TABLE brille24_customer_option_order_item_option DROP FOREIGN KEY FK_8B833EE46ABB6709');
- $this->addSql('ALTER TABLE brille24_customer_option_value_price DROP FOREIGN KEY FK_D218E8EE6ABB6709');
- $this->addSql('ALTER TABLE brille24_customer_option_value_translation DROP FOREIGN KEY FK_3AD2C9512C2AC5D3');
- $this->addSql('ALTER TABLE brille24_customer_option_group_validator DROP FOREIGN KEY FK_1C13475874E6266C');
- $this->addSql('ALTER TABLE brille24_validator_error_message_translation DROP FOREIGN KEY FK_4E22795E2C2AC5D3');
- $this->addSql('DROP TABLE brille24_customer_option');
- $this->addSql('DROP TABLE brille24_customer_option_association');
- $this->addSql('DROP TABLE brille24_customer_option_date_range');
- $this->addSql('DROP TABLE brille24_customer_option_group');
- $this->addSql('DROP TABLE brille24_customer_option_group_translation');
- $this->addSql('DROP TABLE brille24_customer_option_group_validator');
- $this->addSql('DROP TABLE brille24_customer_option_group_validator_condition');
- $this->addSql('DROP TABLE brille24_customer_option_group_validator_constraint');
- $this->addSql('DROP TABLE brille24_customer_option_order_item_option');
- $this->addSql('DROP TABLE brille24_customer_option_translation');
- $this->addSql('DROP TABLE brille24_customer_option_value');
- $this->addSql('DROP TABLE brille24_customer_option_value_price');
- $this->addSql('DROP TABLE brille24_customer_option_value_translation');
- $this->addSql('DROP TABLE brille24_validator_error_message');
- $this->addSql('DROP TABLE brille24_validator_error_message_translation');
- $this->addSql('DROP INDEX IDX_677B9B746DCF05EC ON sylius_product');
- $this->addSql('ALTER TABLE sylius_product DROP customerOptionGroup_id');
- }
-}
diff --git a/src/Migrations/Version20191010092727.php b/src/Migrations/Version20191010092727.php
deleted file mode 100644
index 53d18f41..00000000
--- a/src/Migrations/Version20191010092727.php
+++ /dev/null
@@ -1,35 +0,0 @@
-abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.');
-
- $this->addSql('ALTER TABLE brille24_customer_option_order_item_option ADD customerOptionType VARCHAR(255) NOT NULL, CHANGE optionValue optionValue LONGTEXT DEFAULT NULL');
- }
-
- public function down(Schema $schema): void
- {
- // this down() migration is auto-generated, please modify it to your needs
- $this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.');
-
- $this->addSql('ALTER TABLE brille24_customer_option_order_item_option DROP customerOptionType, CHANGE optionValue optionValue VARCHAR(255) DEFAULT NULL COLLATE utf8_unicode_ci');
- }
-}
diff --git a/src/Migrations/Version20191010092728.php b/src/Migrations/Version20191010092728.php
deleted file mode 100644
index 5cd4bcfb..00000000
--- a/src/Migrations/Version20191010092728.php
+++ /dev/null
@@ -1,35 +0,0 @@
-abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.');
-
- $this->addSql('UPDATE sylius_adjustment SET type = "customer_option" WHERE type = "CUSTOMER_OPTION_ADJUSTMENT"');
- }
-
- public function down(Schema $schema): void
- {
- // this down() migration is auto-generated, please modify it to your needs
- $this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.');
-
- $this->addSql('UPDATE sylius_adjustment SET type = "CUSTOMER_OPTION_ADJUSTMENT" WHERE type = "customer_option"');
- }
-}
diff --git a/src/Migrations/Version20210303184909.php b/src/Migrations/Version20210303184909.php
deleted file mode 100644
index 02c65ece..00000000
--- a/src/Migrations/Version20210303184909.php
+++ /dev/null
@@ -1,124 +0,0 @@
-container = $container;
- }
-
- 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('CREATE TABLE brille24_customer_option_file_content (id INT AUTO_INCREMENT NOT NULL, content LONGTEXT NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET UTF8 COLLATE `UTF8_unicode_ci` ENGINE = InnoDB');
- $this->addSql('ALTER TABLE brille24_customer_option_order_item_option ADD fileContent_id INT DEFAULT NULL');
- $this->addSql('ALTER TABLE brille24_customer_option_order_item_option ADD CONSTRAINT FK_8B833EE486EBE56 FOREIGN KEY (fileContent_id) REFERENCES brille24_customer_option_file_content (id)');
- $this->addSql('CREATE UNIQUE INDEX UNIQ_8B833EE486EBE56 ON brille24_customer_option_order_item_option (fileContent_id)');
-
- $id = 1;
- foreach ($this->getOrderItemOptionsWithValues() as $orderItemOption) {
- $fileContent = $orderItemOption['optionValue'];
-
- $this->addSql('INSERT INTO brille24_customer_option_file_content (id, content) VALUES(:id, :content)', ['id' => $id, 'content' => $fileContent]);
- $this->addSql('UPDATE brille24_customer_option_order_item_option SET fileContent_id = :file_content_id, optionValue = "file-content" WHERE id = :id', ['file_content_id' => $id, 'id' => $orderItemOption['id']]);
-
- ++$id;
- }
- }
-
- public function down(Schema $schema): void
- {
- foreach ($this->getOrderItemOptionsWithFileContent() as $orderItemOption) {
- $fileContent = $orderItemOption['content'];
- $id = $orderItemOption['id'];
-
- $this->addSql('UPDATE brille24_customer_option_order_item_option SET optionValue = :content WHERE id = :id', ['content' => $fileContent, 'id' => $id]);
- }
-
- // this down() migration is auto-generated, please modify it to your needs
- $this->addSql('ALTER TABLE brille24_customer_option_order_item_option DROP FOREIGN KEY FK_8B833EE486EBE56');
- $this->addSql('DROP TABLE brille24_customer_option_file_content');
- $this->addSql('DROP INDEX UNIQ_8B833EE486EBE56 ON brille24_customer_option_order_item_option');
- $this->addSql('ALTER TABLE brille24_customer_option_order_item_option DROP fileContent_id');
- }
-
- private function getOrderItemOptionsWithValues(): array
- {
- if ($this->container === null) {
- throw new \InvalidArgumentException('This migration needs the container to be set: ' . self::class);
- }
-
- /** @var string $orderItemClass */
- $orderItemClass = $this->container->getParameter('brille24.model.order_item_option.class');
-
- $entityManager = $this->getEntityManager($orderItemClass);
-
- return $entityManager->createQueryBuilder()
- ->select('o.id, o.optionValue')
- ->from($orderItemClass, 'o')
- ->where('o.customerOptionType = :type')
- ->setParameter('type', CustomerOptionTypeEnum::FILE)
- ->getQuery()
- ->getArrayResult()
- ;
- }
-
- private function getOrderItemOptionsWithFileContent(): array
- {
- if ($this->container === null) {
- throw new \InvalidArgumentException('This migration needs the container to be set: ' . self::class);
- }
-
- /** @var string $orderItemClass */
- $orderItemClass = $this->container->getParameter('brille24.model.order_item_option.class');
-
- $entityManager = $this->getEntityManager($orderItemClass);
-
- return $entityManager->createQueryBuilder()
- ->select('o.id, f.content')
- ->from($orderItemClass, 'o')
- ->join('o.fileContent', 'f')
- ->where('o.customerOptionType = :type')
- ->setParameter('type', CustomerOptionTypeEnum::FILE)
- ->getQuery()
- ->getArrayResult()
- ;
- }
-
- private function getEntityManager(string $class): EntityManagerInterface
- {
- if ($this->container === null) {
- throw new \InvalidArgumentException('This migration needs the container to be set: ' . self::class);
- }
-
- /** @var ManagerRegistry $managerRegistry */
- $managerRegistry = $this->container->get('doctrine');
-
- /** @var EntityManagerInterface $manager */
- $manager = $managerRegistry->getManagerForClass($class);
-
- return $manager;
- }
-}
diff --git a/src/Migrations/Version20210317090200.php b/src/Migrations/Version20210317090200.php
deleted file mode 100644
index 34f2e551..00000000
--- a/src/Migrations/Version20210317090200.php
+++ /dev/null
@@ -1,31 +0,0 @@
-addSql('ALTER TABLE brille24_customer_option_order_item_option CHANGE optionValue optionValue VARCHAR(255) DEFAULT NULL');
- }
-
- public function down(Schema $schema): void
- {
- // this down() migration is auto-generated, please modify it to your needs
- $this->addSql('ALTER TABLE brille24_customer_option_order_item_option CHANGE optionValue optionValue LONGTEXT CHARACTER SET utf8 DEFAULT NULL COLLATE `utf8_unicode_ci`');
- }
-}
diff --git a/src/Migrations/Version20230615072300.php b/src/Migrations/Version20230615072300.php
deleted file mode 100644
index 901b776d..00000000
--- a/src/Migrations/Version20230615072300.php
+++ /dev/null
@@ -1,42 +0,0 @@
-= 3.0';
- }
-
- public function up(Schema $schema): void
- {
- if ('postgresql' === $this->connection->getDatabasePlatform()->getName()) {
- $this->addSql(/* @lang PostgreSQL */ 'COMMENT ON COLUMN brille24_customer_option.configuration IS NULL');
- $this->addSql(/* @lang PostgreSQL */ 'COMMENT ON COLUMN brille24_customer_option_group_validator_condition.value IS NULL');
- $this->addSql(/* @lang PostgreSQL */ 'COMMENT ON COLUMN brille24_customer_option_group_validator_constraint.value IS NULL');
- } elseif ('mysql' === $this->connection->getDatabasePlatform()->getName()) {
- $this->addSql(/* @lang MySQL */ 'ALTER TABLE brille24_customer_option CHANGE configuration configuration LONGTEXT NOT NULL');
- $this->addSql(/* @lang MySQL */ 'ALTER TABLE brille24_customer_option_group_validator_condition CHANGE value value LONGTEXT NULL');
- $this->addSql(/* @lang MySQL */ 'ALTER TABLE brille24_customer_option_group_validator_constraint CHANGE value value LONGTEXT NULL');
- }
- }
-
- public function down(Schema $schema): void
- {
- if ('postgresql' === $this->connection->getDatabasePlatform()->getName()) {
- $this->addSql(/* @lang PostgreSQL */ 'COMMENT ON COLUMN brille24_customer_option.configuration IS \'(DC2Type:json_array)\'');
- $this->addSql(/* @lang PostgreSQL */ 'COMMENT ON COLUMN brille24_customer_option_group_validator_condition.value IS \'(DC2Type:json_array)\'');
- $this->addSql(/* @lang PostgreSQL */ 'COMMENT ON COLUMN brille24_customer_option_group_validator_constraint.value IS \'(DC2Type:json_array)\'');
- } elseif ('mysql' === $this->connection->getDatabasePlatform()->getName()) {
- $this->addSql(/* @lang MySQL */ 'ALTER TABLE brille24_customer_option CHANGE configuration configuration LONGTEXT NOT NULL COMMENT \'(DC2Type:json_array)\'');
- $this->addSql(/* @lang MySQL */ 'ALTER TABLE brille24_customer_option_group_validator_condition CHANGE value value LONGTEXT NULL COMMENT \'(DC2Type:json_array)\'');
- $this->addSql(/* @lang MySQL */ 'ALTER TABLE brille24_customer_option_group_validator_constraint CHANGE value value LONGTEXT NULL COMMENT \'(DC2Type:json_array)\'');
- }
- }
-}
diff --git a/src/Resources/config/app/resources.yml b/src/Resources/config/app/resources.yml
index 52623faa..ddaaa1cc 100644
--- a/src/Resources/config/app/resources.yml
+++ b/src/Resources/config/app/resources.yml
@@ -1,14 +1,14 @@
-# Overriding the Sylius resources
-sylius_product:
- resources:
- product:
- classes:
- model: Brille24\SyliusCustomerOptionsPlugin\Entity\Product
-sylius_order:
- resources:
- order_item:
- classes:
- model: Brille24\SyliusCustomerOptionsPlugin\Entity\OrderItem
+## Overriding the Sylius resources
+#sylius_product:
+# resources:
+# product:
+# classes:
+# model: Brille24\SyliusCustomerOptionsPlugin\Entity\Product
+#sylius_order:
+# resources:
+# order_item:
+# classes:
+# model: Brille24\SyliusCustomerOptionsPlugin\Entity\OrderItem
# Defining new resources
sylius_resource:
diff --git a/src/Resources/config/doctrine/CustomerOptions.CustomerOption.orm.xml b/src/Resources/config/doctrine/CustomerOptions.CustomerOption.orm.xml
deleted file mode 100644
index f17cf67c..00000000
--- a/src/Resources/config/doctrine/CustomerOptions.CustomerOption.orm.xml
+++ /dev/null
@@ -1,52 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/src/Resources/config/doctrine/CustomerOptions.CustomerOptionAssociation.orm.xml b/src/Resources/config/doctrine/CustomerOptions.CustomerOptionAssociation.orm.xml
deleted file mode 100644
index fbc51078..00000000
--- a/src/Resources/config/doctrine/CustomerOptions.CustomerOptionAssociation.orm.xml
+++ /dev/null
@@ -1,31 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/src/Resources/config/doctrine/CustomerOptions.CustomerOptionGroup.orm.xml b/src/Resources/config/doctrine/CustomerOptions.CustomerOptionGroup.orm.xml
deleted file mode 100644
index 1b526592..00000000
--- a/src/Resources/config/doctrine/CustomerOptions.CustomerOptionGroup.orm.xml
+++ /dev/null
@@ -1,49 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/src/Resources/config/doctrine/CustomerOptions.CustomerOptionGroupTranslation.orm.xml b/src/Resources/config/doctrine/CustomerOptions.CustomerOptionGroupTranslation.orm.xml
deleted file mode 100644
index 58488b2d..00000000
--- a/src/Resources/config/doctrine/CustomerOptions.CustomerOptionGroupTranslation.orm.xml
+++ /dev/null
@@ -1,16 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/src/Resources/config/doctrine/CustomerOptions.CustomerOptionTranslation.orm.xml b/src/Resources/config/doctrine/CustomerOptions.CustomerOptionTranslation.orm.xml
deleted file mode 100644
index 8dd2b190..00000000
--- a/src/Resources/config/doctrine/CustomerOptions.CustomerOptionTranslation.orm.xml
+++ /dev/null
@@ -1,18 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/src/Resources/config/doctrine/CustomerOptions.CustomerOptionValue.orm.xml b/src/Resources/config/doctrine/CustomerOptions.CustomerOptionValue.orm.xml
deleted file mode 100644
index c629bfc5..00000000
--- a/src/Resources/config/doctrine/CustomerOptions.CustomerOptionValue.orm.xml
+++ /dev/null
@@ -1,41 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/src/Resources/config/doctrine/CustomerOptions.CustomerOptionValuePrice.orm.xml b/src/Resources/config/doctrine/CustomerOptions.CustomerOptionValuePrice.orm.xml
deleted file mode 100644
index 1909c512..00000000
--- a/src/Resources/config/doctrine/CustomerOptions.CustomerOptionValuePrice.orm.xml
+++ /dev/null
@@ -1,43 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/src/Resources/config/doctrine/CustomerOptions.CustomerOptionValueTranslation.orm.xml b/src/Resources/config/doctrine/CustomerOptions.CustomerOptionValueTranslation.orm.xml
deleted file mode 100644
index d9e17ac4..00000000
--- a/src/Resources/config/doctrine/CustomerOptions.CustomerOptionValueTranslation.orm.xml
+++ /dev/null
@@ -1,18 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/src/Resources/config/doctrine/CustomerOptions.Validator.Condition.orm.xml b/src/Resources/config/doctrine/CustomerOptions.Validator.Condition.orm.xml
deleted file mode 100644
index 8a6a0adc..00000000
--- a/src/Resources/config/doctrine/CustomerOptions.Validator.Condition.orm.xml
+++ /dev/null
@@ -1,32 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/src/Resources/config/doctrine/CustomerOptions.Validator.Constraint.orm.xml b/src/Resources/config/doctrine/CustomerOptions.Validator.Constraint.orm.xml
deleted file mode 100644
index 2724c491..00000000
--- a/src/Resources/config/doctrine/CustomerOptions.Validator.Constraint.orm.xml
+++ /dev/null
@@ -1,32 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/src/Resources/config/doctrine/CustomerOptions.Validator.ErrorMessage.orm.xml b/src/Resources/config/doctrine/CustomerOptions.Validator.ErrorMessage.orm.xml
deleted file mode 100644
index 31d3d320..00000000
--- a/src/Resources/config/doctrine/CustomerOptions.Validator.ErrorMessage.orm.xml
+++ /dev/null
@@ -1,14 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/src/Resources/config/doctrine/CustomerOptions.Validator.ErrorMessageTranslation.orm.xml b/src/Resources/config/doctrine/CustomerOptions.Validator.ErrorMessageTranslation.orm.xml
deleted file mode 100644
index 37f17610..00000000
--- a/src/Resources/config/doctrine/CustomerOptions.Validator.ErrorMessageTranslation.orm.xml
+++ /dev/null
@@ -1,23 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/src/Resources/config/doctrine/CustomerOptions.Validator.Validator.orm.xml b/src/Resources/config/doctrine/CustomerOptions.Validator.Validator.orm.xml
deleted file mode 100644
index 852a0f93..00000000
--- a/src/Resources/config/doctrine/CustomerOptions.Validator.Validator.orm.xml
+++ /dev/null
@@ -1,47 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/src/Resources/config/doctrine/FileContent.orm.xml b/src/Resources/config/doctrine/FileContent.orm.xml
deleted file mode 100644
index d7b269a9..00000000
--- a/src/Resources/config/doctrine/FileContent.orm.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
-
-
-
-
-
-
-
diff --git a/src/Resources/config/doctrine/OrderItem.orm.xml b/src/Resources/config/doctrine/OrderItem.orm.xml
deleted file mode 100644
index f31e91ed..00000000
--- a/src/Resources/config/doctrine/OrderItem.orm.xml
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
diff --git a/src/Resources/config/doctrine/OrderItemOption.orm.xml b/src/Resources/config/doctrine/OrderItemOption.orm.xml
deleted file mode 100644
index 01cf0c1c..00000000
--- a/src/Resources/config/doctrine/OrderItemOption.orm.xml
+++ /dev/null
@@ -1,42 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/src/Resources/config/doctrine/Product.orm.xml b/src/Resources/config/doctrine/Product.orm.xml
deleted file mode 100644
index c949b14a..00000000
--- a/src/Resources/config/doctrine/Product.orm.xml
+++ /dev/null
@@ -1,22 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/src/Resources/config/doctrine/Tools.DateRange.orm.xml b/src/Resources/config/doctrine/Tools.DateRange.orm.xml
deleted file mode 100644
index 9e487161..00000000
--- a/src/Resources/config/doctrine/Tools.DateRange.orm.xml
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/src/Traits/ConditionTrait.php b/src/Traits/ConditionTrait.php
index d8b0d821..60f9cb06 100644
--- a/src/Traits/ConditionTrait.php
+++ b/src/Traits/ConditionTrait.php
@@ -8,16 +8,24 @@
use Brille24\SyliusCustomerOptionsPlugin\Entity\CustomerOptions\Validator\ValidatorInterface;
use Brille24\SyliusCustomerOptionsPlugin\Enumerations\ConditionComparatorEnum;
use Brille24\SyliusCustomerOptionsPlugin\Enumerations\CustomerOptionTypeEnum;
+use Doctrine\ORM\Mapping as ORM;
use Webmozart\Assert\Assert;
+
trait ConditionTrait
{
+ #[ORM\ManyToOne(targetEntity: CustomerOptionInterface::class)]
+ #[ORM\JoinColumn(onDelete: 'SET NULL')]
protected ?CustomerOptionInterface $customerOption = null;
+ #[ORM\Column(type: 'string', nullable: true)]
protected ?string $comparator = null;
+ #[ORM\Column(type: 'json', nullable: true)]
protected ?array $value = null;
+ #[ORM\ManyToOne(targetEntity: ValidatorInterface::class, cascade: ['persist'], inversedBy: 'conditions')]
+ #[ORM\JoinColumn(onDelete: 'CASCADE')]
protected ?ValidatorInterface $validator = null;
/** @inheritdoc */