Passed
Push — trunk ( c1976e...a42427 )
by Christian
12:40 queued 13s
created

CountryTranslationDefinition::getDefaults()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 4
rs 10
1
<?php declare(strict_types=1);
2
3
namespace Shopware\Core\System\Country\Aggregate\CountryTranslation;
4
5
use Shopware\Core\Framework\DataAbstractionLayer\EntityTranslationDefinition;
6
use Shopware\Core\Framework\DataAbstractionLayer\Field\CustomFields;
7
use Shopware\Core\Framework\DataAbstractionLayer\Field\Flag\ApiAware;
8
use Shopware\Core\Framework\DataAbstractionLayer\Field\Flag\Required;
9
use Shopware\Core\Framework\DataAbstractionLayer\Field\JsonField;
10
use Shopware\Core\Framework\DataAbstractionLayer\Field\StringField;
11
use Shopware\Core\Framework\DataAbstractionLayer\FieldCollection;
12
use Shopware\Core\System\Country\CountryDefinition;
13
14
class CountryTranslationDefinition extends EntityTranslationDefinition
15
{
16
    public const ENTITY_NAME = 'country_translation';
17
18
    public function getEntityName(): string
19
    {
20
        return self::ENTITY_NAME;
21
    }
22
23
    public function getCollectionClass(): string
24
    {
25
        return CountryTranslationCollection::class;
26
    }
27
28
    public function getEntityClass(): string
29
    {
30
        return CountryTranslationEntity::class;
31
    }
32
33
    public function since(): ?string
34
    {
35
        return '6.0.0.0';
36
    }
37
38
    public function getDefaults(): array
39
    {
40
        return [
41
            'addressFormat' => CountryDefinition::DEFAULT_ADDRESS_FORMAT,
42
        ];
43
    }
44
45
    protected function getParentDefinitionClass(): string
46
    {
47
        return CountryDefinition::class;
48
    }
49
50
    protected function defineFields(): FieldCollection
51
    {
52
        return new FieldCollection([
53
            (new StringField('name', 'name'))->addFlags(new ApiAware(), new Required()),
54
            (new JsonField('address_format', 'addressFormat'))->addFlags(new ApiAware(), new Required()),
55
            (new CustomFields())->addFlags(new ApiAware()),
56
        ]);
57
    }
58
}
59