Passed
Push — master ( 03f7d7...c4abfd )
by Christian
11:46 queued 12s
created

CustomerRecoveryDefinition::getCollectionClass()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php declare(strict_types=1);
2
3
namespace Shopware\Core\Checkout\Customer\Aggregate\CustomerRecovery;
4
5
use Shopware\Core\Checkout\Customer\CustomerDefinition;
6
use Shopware\Core\Framework\Api\Context\SalesChannelApiSource;
7
use Shopware\Core\Framework\DataAbstractionLayer\EntityDefinition;
8
use Shopware\Core\Framework\DataAbstractionLayer\Field\CreatedAtField;
9
use Shopware\Core\Framework\DataAbstractionLayer\Field\FkField;
10
use Shopware\Core\Framework\DataAbstractionLayer\Field\Flag\PrimaryKey;
11
use Shopware\Core\Framework\DataAbstractionLayer\Field\Flag\ReadProtected;
12
use Shopware\Core\Framework\DataAbstractionLayer\Field\Flag\Required;
13
use Shopware\Core\Framework\DataAbstractionLayer\Field\IdField;
14
use Shopware\Core\Framework\DataAbstractionLayer\Field\OneToOneAssociationField;
15
use Shopware\Core\Framework\DataAbstractionLayer\Field\StringField;
16
use Shopware\Core\Framework\DataAbstractionLayer\FieldCollection;
17
18
class CustomerRecoveryDefinition extends EntityDefinition
19
{
20
    public const ENTITY_NAME = 'customer_recovery';
21
22
    public function getEntityName(): string
23
    {
24
        return self::ENTITY_NAME;
25
    }
26
27
    public function getEntityClass(): string
28
    {
29
        return CustomerRecoveryEntity::class;
30
    }
31
32
    public function getCollectionClass(): string
33
    {
34
        return CustomerRecoveryCollection::class;
35
    }
36
37
    public function since(): ?string
38
    {
39
        return '6.1.0.0';
40
    }
41
42
    protected function getParentDefinitionClass(): ?string
43
    {
44
        return CustomerDefinition::class;
45
    }
46
47
    protected function defineFields(): FieldCollection
48
    {
49
        return new FieldCollection([
50
            (new IdField('id', 'id'))->addFlags(new PrimaryKey(), new Required()),
51
            (new StringField('hash', 'hash'))->addFlags(new Required()),
52
            (new FkField('customer_id', 'customerId', CustomerDefinition::class))->addFlags(new Required()),
53
            (new CreatedAtField())->addFlags(new Required()),
54
            (new OneToOneAssociationField('customer', 'customer_id', 'id', CustomerDefinition::class, false))
55
                ->addFlags(new ReadProtected(SalesChannelApiSource::class)),
56
        ]);
57
    }
58
}
59