Passed
Push — 6.4 ( 969936...be76f2 )
by Christian
44:06 queued 29:02
created

OrderLineItemDownloadDefinition   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 19
dl 0
loc 46
rs 10
c 1
b 0
f 0
wmc 6

6 Methods

Rating   Name   Duplication   Size   Complexity  
A defineFields() 0 16 1
A getEntityName() 0 3 1
A getParentDefinitionClass() 0 3 1
A since() 0 3 1
A getCollectionClass() 0 3 1
A getEntityClass() 0 3 1
1
<?php declare(strict_types=1);
2
3
namespace Shopware\Core\Checkout\Order\Aggregate\OrderLineItemDownload;
4
5
use Shopware\Core\Checkout\Order\Aggregate\OrderLineItem\OrderLineItemDefinition;
6
use Shopware\Core\Content\Media\MediaDefinition;
7
use Shopware\Core\Framework\DataAbstractionLayer\EntityDefinition;
8
use Shopware\Core\Framework\DataAbstractionLayer\Field\BoolField;
9
use Shopware\Core\Framework\DataAbstractionLayer\Field\CustomFields;
10
use Shopware\Core\Framework\DataAbstractionLayer\Field\FkField;
11
use Shopware\Core\Framework\DataAbstractionLayer\Field\Flag\ApiAware;
12
use Shopware\Core\Framework\DataAbstractionLayer\Field\Flag\PrimaryKey;
13
use Shopware\Core\Framework\DataAbstractionLayer\Field\Flag\Required;
14
use Shopware\Core\Framework\DataAbstractionLayer\Field\IdField;
15
use Shopware\Core\Framework\DataAbstractionLayer\Field\IntField;
16
use Shopware\Core\Framework\DataAbstractionLayer\Field\ManyToOneAssociationField;
17
use Shopware\Core\Framework\DataAbstractionLayer\Field\ReferenceVersionField;
18
use Shopware\Core\Framework\DataAbstractionLayer\Field\VersionField;
19
use Shopware\Core\Framework\DataAbstractionLayer\FieldCollection;
20
use Shopware\Core\Framework\Log\Package;
21
22
#[Package('customer-order')]
23
class OrderLineItemDownloadDefinition extends EntityDefinition
24
{
25
    public const ENTITY_NAME = 'order_line_item_download';
26
27
    public function getEntityName(): string
28
    {
29
        return self::ENTITY_NAME;
30
    }
31
32
    public function getCollectionClass(): string
33
    {
34
        return OrderLineItemDownloadCollection::class;
35
    }
36
37
    public function getEntityClass(): string
38
    {
39
        return OrderLineItemDownloadEntity::class;
40
    }
41
42
    public function since(): ?string
43
    {
44
        return '6.4.19.0';
45
    }
46
47
    protected function getParentDefinitionClass(): ?string
48
    {
49
        return OrderLineItemDefinition::class;
50
    }
51
52
    protected function defineFields(): FieldCollection
53
    {
54
        return new FieldCollection([
55
            (new IdField('id', 'id'))->addFlags(new ApiAware(), new PrimaryKey(), new Required()),
56
            (new VersionField())->addFlags(new ApiAware()),
57
58
            (new FkField('order_line_item_id', 'orderLineItemId', OrderLineItemDefinition::class))->addFlags(new ApiAware(), new Required()),
59
            (new ReferenceVersionField(OrderLineItemDefinition::class))->addFlags(new ApiAware(), new Required()),
60
61
            (new FkField('media_id', 'mediaId', MediaDefinition::class))->addFlags(new ApiAware(), new Required()),
62
            (new IntField('position', 'position'))->addFlags(new ApiAware(), new Required()),
63
            (new BoolField('access_granted', 'accessGranted'))->addFlags(new ApiAware(), new Required()),
64
65
            (new ManyToOneAssociationField('orderLineItem', 'order_line_item_id', OrderLineItemDefinition::class, 'id'))->addFlags(new ApiAware()),
66
            (new ManyToOneAssociationField('media', 'media_id', MediaDefinition::class, 'id'))->addFlags(new ApiAware()),
67
            (new CustomFields())->addFlags(new ApiAware()),
68
        ]);
69
    }
70
}
71