|
1
|
|
|
<?php declare(strict_types=1); |
|
2
|
|
|
|
|
3
|
|
|
namespace Shopware\Core\System\User\Aggregate\UserConfig; |
|
4
|
|
|
|
|
5
|
|
|
use Shopware\Core\Framework\Api\Context\SalesChannelApiSource; |
|
6
|
|
|
use Shopware\Core\Framework\DataAbstractionLayer\EntityDefinition; |
|
7
|
|
|
use Shopware\Core\Framework\DataAbstractionLayer\Field\FkField; |
|
8
|
|
|
use Shopware\Core\Framework\DataAbstractionLayer\Field\Flag\PrimaryKey; |
|
9
|
|
|
use Shopware\Core\Framework\DataAbstractionLayer\Field\Flag\ReadProtected; |
|
10
|
|
|
use Shopware\Core\Framework\DataAbstractionLayer\Field\Flag\Required; |
|
11
|
|
|
use Shopware\Core\Framework\DataAbstractionLayer\Field\IdField; |
|
12
|
|
|
use Shopware\Core\Framework\DataAbstractionLayer\Field\JsonField; |
|
13
|
|
|
use Shopware\Core\Framework\DataAbstractionLayer\Field\ManyToOneAssociationField; |
|
14
|
|
|
use Shopware\Core\Framework\DataAbstractionLayer\Field\StringField; |
|
15
|
|
|
use Shopware\Core\Framework\DataAbstractionLayer\FieldCollection; |
|
16
|
|
|
use Shopware\Core\System\User\UserDefinition; |
|
17
|
|
|
|
|
18
|
|
|
class UserConfigDefinition extends EntityDefinition |
|
19
|
|
|
{ |
|
20
|
|
|
public const ENTITY_NAME = 'user_config'; |
|
21
|
|
|
|
|
22
|
|
|
public function getEntityName(): string |
|
23
|
|
|
{ |
|
24
|
|
|
return self::ENTITY_NAME; |
|
25
|
|
|
} |
|
26
|
|
|
|
|
27
|
|
|
public function getEntityClass(): string |
|
28
|
|
|
{ |
|
29
|
|
|
return UserConfigEntity::class; |
|
30
|
|
|
} |
|
31
|
|
|
|
|
32
|
|
|
public function getCollectionClass(): string |
|
33
|
|
|
{ |
|
34
|
|
|
return UserConfigCollection::class; |
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
|
|
public function since(): ?string |
|
38
|
|
|
{ |
|
39
|
|
|
return '6.3.5.0'; |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
|
|
protected function defineFields(): FieldCollection |
|
43
|
|
|
{ |
|
44
|
|
|
return new FieldCollection([ |
|
45
|
|
|
(new IdField('id', 'id'))->addFlags(new PrimaryKey(), new Required()), |
|
46
|
|
|
(new FkField('user_id', 'userId', UserDefinition::class))->addFlags(new Required()), |
|
47
|
|
|
(new StringField('key', 'key'))->addFlags(new Required()), |
|
48
|
|
|
(new JsonField('value', 'value')), |
|
49
|
|
|
|
|
50
|
|
|
(new ManyToOneAssociationField('user', 'user_id', UserDefinition::class, 'id', false)) |
|
51
|
|
|
->addFlags(new ReadProtected(SalesChannelApiSource::class)), |
|
52
|
|
|
]); |
|
53
|
|
|
} |
|
54
|
|
|
} |
|
55
|
|
|
|