1
|
|
|
<?php declare(strict_types=1); |
2
|
|
|
|
3
|
|
|
namespace Shopware\Core\Checkout\Promotion\Aggregate\PromotionPersonaCustomer; |
4
|
|
|
|
5
|
|
|
use Shopware\Core\Checkout\Customer\CustomerDefinition; |
6
|
|
|
use Shopware\Core\Checkout\Promotion\PromotionDefinition; |
7
|
|
|
use Shopware\Core\Framework\Api\Context\SalesChannelApiSource; |
8
|
|
|
use Shopware\Core\Framework\DataAbstractionLayer\Field\FkField; |
9
|
|
|
use Shopware\Core\Framework\DataAbstractionLayer\Field\Flag\PrimaryKey; |
10
|
|
|
use Shopware\Core\Framework\DataAbstractionLayer\Field\Flag\ReadProtected; |
11
|
|
|
use Shopware\Core\Framework\DataAbstractionLayer\Field\Flag\Required; |
12
|
|
|
use Shopware\Core\Framework\DataAbstractionLayer\Field\ManyToOneAssociationField; |
13
|
|
|
use Shopware\Core\Framework\DataAbstractionLayer\FieldCollection; |
14
|
|
|
use Shopware\Core\Framework\DataAbstractionLayer\MappingEntityDefinition; |
15
|
|
|
|
16
|
|
|
class PromotionPersonaCustomerDefinition extends MappingEntityDefinition |
17
|
|
|
{ |
18
|
|
|
public const ENTITY_NAME = 'promotion_persona_customer'; |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* This class is used as m:n relation between promotions and customers. |
22
|
|
|
* It gives the option to assign what customers may use this |
23
|
|
|
* promotion based on a whitelist algorithm. |
24
|
|
|
*/ |
25
|
|
|
public function getEntityName(): string |
26
|
|
|
{ |
27
|
|
|
return self::ENTITY_NAME; |
28
|
|
|
} |
29
|
|
|
|
30
|
|
|
public function since(): ?string |
31
|
|
|
{ |
32
|
|
|
return '6.0.0.0'; |
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
protected function defineFields(): FieldCollection |
36
|
|
|
{ |
37
|
|
|
return new FieldCollection([ |
38
|
|
|
(new FkField('promotion_id', 'promotionId', PromotionDefinition::class))->addFlags(new PrimaryKey(), new Required()), |
39
|
|
|
(new FkField('customer_id', 'customerId', CustomerDefinition::class))->addFlags(new PrimaryKey(), new Required()), |
40
|
|
|
new ManyToOneAssociationField('promotion', 'promotion_id', PromotionDefinition::class, 'id'), |
41
|
|
|
(new ManyToOneAssociationField('customer', 'customer_id', CustomerDefinition::class, 'id')) |
42
|
|
|
->addFlags(new ReadProtected(SalesChannelApiSource::class)), |
43
|
|
|
]); |
44
|
|
|
} |
45
|
|
|
} |
46
|
|
|
|