1
|
|
|
<?php declare(strict_types=1); |
2
|
|
|
|
3
|
|
|
namespace Shopware\Core\System\Integration; |
4
|
|
|
|
5
|
|
|
use Shopware\Core\Framework\Api\Acl\Role\AclRoleDefinition; |
6
|
|
|
use Shopware\Core\Framework\App\AppDefinition; |
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\DateTimeField; |
11
|
|
|
use Shopware\Core\Framework\DataAbstractionLayer\Field\Flag\CascadeDelete; |
12
|
|
|
use Shopware\Core\Framework\DataAbstractionLayer\Field\Flag\Deprecated; |
13
|
|
|
use Shopware\Core\Framework\DataAbstractionLayer\Field\Flag\PrimaryKey; |
14
|
|
|
use Shopware\Core\Framework\DataAbstractionLayer\Field\Flag\Required; |
15
|
|
|
use Shopware\Core\Framework\DataAbstractionLayer\Field\IdField; |
16
|
|
|
use Shopware\Core\Framework\DataAbstractionLayer\Field\ManyToManyAssociationField; |
17
|
|
|
use Shopware\Core\Framework\DataAbstractionLayer\Field\OneToOneAssociationField; |
18
|
|
|
use Shopware\Core\Framework\DataAbstractionLayer\Field\PasswordField; |
19
|
4 |
|
use Shopware\Core\Framework\DataAbstractionLayer\Field\StringField; |
20
|
|
|
use Shopware\Core\Framework\DataAbstractionLayer\FieldCollection; |
21
|
4 |
|
use Shopware\Core\Framework\Feature; |
22
|
|
|
use Shopware\Core\System\Integration\Aggregate\IntegrationRole\IntegrationRoleDefinition; |
23
|
|
|
|
24
|
1 |
|
class IntegrationDefinition extends EntityDefinition |
25
|
|
|
{ |
26
|
1 |
|
public const ENTITY_NAME = 'integration'; |
27
|
|
|
|
28
|
|
|
public function getEntityName(): string |
29
|
2 |
|
{ |
30
|
|
|
return self::ENTITY_NAME; |
31
|
2 |
|
} |
32
|
|
|
|
33
|
|
|
public function getCollectionClass(): string |
34
|
1 |
|
{ |
35
|
|
|
return IntegrationCollection::class; |
36
|
1 |
|
} |
37
|
1 |
|
|
38
|
1 |
|
public function getEntityClass(): string |
39
|
1 |
|
{ |
40
|
1 |
|
return IntegrationEntity::class; |
41
|
1 |
|
} |
42
|
1 |
|
|
43
|
1 |
|
public function getDefaults(): array |
44
|
1 |
|
{ |
45
|
|
|
return [ |
46
|
|
|
'admin' => true, |
47
|
|
|
]; |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
protected function defineFields(): FieldCollection |
51
|
|
|
{ |
52
|
|
|
$collection = new FieldCollection([ |
53
|
|
|
(new IdField('id', 'id'))->addFlags(new PrimaryKey(), new Required()), |
54
|
|
|
(new StringField('label', 'label'))->addFlags(new Required()), |
55
|
|
|
(new StringField('access_key', 'accessKey'))->addFlags(new Required()), |
56
|
|
|
(new PasswordField('secret_access_key', 'secretAccessKey'))->addFlags(new Required()), |
57
|
|
|
new BoolField('write_access', 'writeAccess'), |
58
|
|
|
new DateTimeField('last_usage_at', 'lastUsageAt'), |
59
|
|
|
new BoolField('admin', 'admin'), |
60
|
|
|
new CustomFields(), |
61
|
|
|
]); |
62
|
|
|
|
63
|
|
|
if (Feature::isActive('FEATURE_NEXT_10286')) { |
64
|
|
|
$collection->add( |
65
|
|
|
(new OneToOneAssociationField('app', 'id', 'integration_id', AppDefinition::class, false)) |
66
|
|
|
->addFlags(new CascadeDelete()) |
67
|
|
|
); |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
if (Feature::isActive('FEATURE_NEXT_3722')) { |
71
|
|
|
$collection->add( |
72
|
|
|
(new BoolField('write_access', 'writeAccess'))->addFlags(new Deprecated('v3', 'v4')) |
73
|
|
|
); |
74
|
|
|
$collection->add( |
75
|
|
|
new ManyToManyAssociationField('aclRoles', AclRoleDefinition::class, IntegrationRoleDefinition::class, 'integration_id', 'acl_role_id') |
76
|
|
|
); |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
return $collection; |
80
|
|
|
} |
81
|
|
|
} |
82
|
|
|
|