-
Notifications
You must be signed in to change notification settings - Fork 977
/
ProductCategoryDefinition.php
48 lines (40 loc) · 1.91 KB
/
ProductCategoryDefinition.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<?php declare(strict_types=1);
namespace Shopware\Core\Content\Product\Aggregate\ProductCategory;
use Shopware\Core\Content\Category\CategoryDefinition;
use Shopware\Core\Content\Product\ProductDefinition;
use Shopware\Core\Framework\DataAbstractionLayer\Field\FkField;
use Shopware\Core\Framework\DataAbstractionLayer\Field\Flag\PrimaryKey;
use Shopware\Core\Framework\DataAbstractionLayer\Field\Flag\Required;
use Shopware\Core\Framework\DataAbstractionLayer\Field\ManyToOneAssociationField;
use Shopware\Core\Framework\DataAbstractionLayer\Field\ReferenceVersionField;
use Shopware\Core\Framework\DataAbstractionLayer\FieldCollection;
use Shopware\Core\Framework\DataAbstractionLayer\MappingEntityDefinition;
use Shopware\Core\Framework\Log\Package;
#[Package('inventory')]
class ProductCategoryDefinition extends MappingEntityDefinition
{
final public const ENTITY_NAME = 'product_category';
public function getEntityName(): string
{
return self::ENTITY_NAME;
}
public function isVersionAware(): bool
{
return true;
}
public function since(): ?string
{
return '6.0.0.0';
}
protected function defineFields(): FieldCollection
{
return new FieldCollection([
(new FkField('product_id', 'productId', ProductDefinition::class))->addFlags(new PrimaryKey(), new Required()),
(new ReferenceVersionField(ProductDefinition::class))->addFlags(new PrimaryKey(), new Required()),
(new FkField('category_id', 'categoryId', CategoryDefinition::class))->addFlags(new PrimaryKey(), new Required()),
(new ReferenceVersionField(CategoryDefinition::class))->addFlags(new PrimaryKey(), new Required()),
new ManyToOneAssociationField('product', 'product_id', ProductDefinition::class, 'id', false),
new ManyToOneAssociationField('category', 'category_id', CategoryDefinition::class, 'id', false),
]);
}
}