Passed
Push — master ( 04c2f7...8e7d49 )
by Christian
13:07 queued 11s
created

UserConfigDefinition::getEntityClass()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 1
c 1
b 0
f 1
nc 1
nop 0
dl 0
loc 3
rs 10
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