Hallo, ich möchte eine benutzerdefinierte Validierung zu der unten stehenden Entitätsdefinition hinzufügen, um die Überschneidung der Bereiche „von“ und „bis“ zu verhindern. Könnten Sie mich bitte anleiten, wie ich das erreichen kann?
<?php declare(strict_types=1);
namespace Swag\PriceMatrix\Core\Content\SwagPriceMatrix;
use Shopware\Core\Framework\DataAbstractionLayer\EntityDefinition;
use Shopware\Core\Framework\DataAbstractionLayer\Field\BoolField;
use Shopware\Core\Framework\DataAbstractionLayer\Field\Flag\PrimaryKey;
use Shopware\Core\Framework\DataAbstractionLayer\Field\Flag\Required;
use Shopware\Core\Framework\DataAbstractionLayer\Field\FloatField;
use Shopware\Core\Framework\DataAbstractionLayer\Field\IdField;
use Shopware\Core\Framework\DataAbstractionLayer\Field\IntField;
use Shopware\Core\Framework\DataAbstractionLayer\Field\StringField;
use Shopware\Core\Framework\DataAbstractionLayer\FieldCollection;
class SwagPriceMatrixDefinition extends EntityDefinition
{
public const ENTITY_NAME = 'swag_price_matrix';
public function getEntityName(): string
{
return self::ENTITY_NAME;
}
protected function defineFields(): FieldCollection
{
return new FieldCollection([
(new IdField('id', 'id'))->addFlags(new Required(), new PrimaryKey()),
(new IntField('from', 'from'))->addFlags(new Required()),
(new IntField('to', 'to')),
(new FloatField('price', 'price'))->addFlags(new Required()),
(new IntField('type', 'type'))->addFlags(new Required())
]);
}
public function getEntityClass(): string
{
return SwagPriceMatrixEntity::class;
}
public function getCollectionClass(): string
{
return SwagPriceMatrixEntityCollection::class;
}
}