mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-07-14 20:35:08 +02:00
Moved custom validators from annotations to attributes
This commit is contained in:
parent
e5a14557a2
commit
930adaf439
27 changed files with 50 additions and 148 deletions
|
@ -41,7 +41,6 @@ use Symfony\Component\Validator\Context\ExecutionContextInterface;
|
|||
* This entity describes a lot where parts can be stored.
|
||||
* It is the connection between a part and its store locations.
|
||||
*
|
||||
* @ValidPartLot()
|
||||
* @see \App\Tests\Entity\Parts\PartLotTest
|
||||
*/
|
||||
#[ORM\Entity]
|
||||
|
@ -49,6 +48,7 @@ use Symfony\Component\Validator\Context\ExecutionContextInterface;
|
|||
#[ORM\Table(name: 'part_lots')]
|
||||
#[ORM\Index(name: 'part_lots_idx_instock_un_expiration_id_part', columns: ['instock_unknown', 'expiration_date', 'id_part'])]
|
||||
#[ORM\Index(name: 'part_lots_idx_needs_refill', columns: ['needs_refill'])]
|
||||
#[ValidPartLot]
|
||||
class PartLot extends AbstractDBElement implements TimeStampableInterface, NamedElementInterface
|
||||
{
|
||||
use TimestampTrait;
|
||||
|
@ -77,11 +77,11 @@ class PartLot extends AbstractDBElement implements TimeStampableInterface, Named
|
|||
|
||||
/**
|
||||
* @var Storelocation|null The storelocation of this lot
|
||||
* @Selectable()
|
||||
*/
|
||||
#[Groups(['simple', 'extended', 'full', 'import'])]
|
||||
#[ORM\ManyToOne(targetEntity: 'Storelocation')]
|
||||
#[ORM\JoinColumn(name: 'id_store_location')]
|
||||
#[Selectable()]
|
||||
protected ?Storelocation $storage_location = null;
|
||||
|
||||
/**
|
||||
|
@ -334,7 +334,7 @@ class PartLot extends AbstractDBElement implements TimeStampableInterface, Named
|
|||
//When the storage location sets the owner must match, the part lot owner must match the storage location owner
|
||||
if ($this->getStorageLocation() && $this->getStorageLocation()->isPartOwnerMustMatch()
|
||||
&& $this->getStorageLocation()->getOwner() && $this->getOwner() && ($this->getOwner() !== $this->getStorageLocation()->getOwner()
|
||||
&& $this->owner->getID() !== $this->getStorageLocation()->getOwner()->getID())) {
|
||||
&& $this->owner->getID() !== $this->getStorageLocation()->getOwner()->getID())) {
|
||||
$context->buildViolation('validator.part_lot.owner_must_match_storage_location_owner')
|
||||
->setParameter('%owner_name%', $this->getStorageLocation()->getOwner()->getFullName(true))
|
||||
->atPath('owner')
|
||||
|
|
|
@ -62,9 +62,9 @@ trait BasicPropertyTrait
|
|||
/**
|
||||
* @var Category|null The category this part belongs too (e.g. Resistors). Use tags, for more complex grouping.
|
||||
* Every part must have a category.
|
||||
* @Selectable()
|
||||
*/
|
||||
#[Assert\NotNull(message: 'validator.select_valid_category')]
|
||||
#[Selectable()]
|
||||
#[Groups(['simple', 'extended', 'full', 'import'])]
|
||||
#[ORM\ManyToOne(targetEntity: 'Category')]
|
||||
#[ORM\JoinColumn(name: 'id_category', nullable: false)]
|
||||
|
@ -72,11 +72,11 @@ trait BasicPropertyTrait
|
|||
|
||||
/**
|
||||
* @var Footprint|null The footprint of this part (e.g. DIP8)
|
||||
* @Selectable()
|
||||
*/
|
||||
#[Groups(['simple', 'extended', 'full', 'import'])]
|
||||
#[ORM\ManyToOne(targetEntity: 'Footprint')]
|
||||
#[ORM\JoinColumn(name: 'id_footprint')]
|
||||
#[Selectable()]
|
||||
protected ?Footprint $footprint = null;
|
||||
|
||||
/**
|
||||
|
|
|
@ -37,11 +37,11 @@ trait ManufacturerTrait
|
|||
{
|
||||
/**
|
||||
* @var Manufacturer|null The manufacturer of this part
|
||||
* @Selectable()
|
||||
*/
|
||||
#[Groups(['simple', 'extended', 'full', 'import'])]
|
||||
#[ORM\ManyToOne(targetEntity: 'Manufacturer')]
|
||||
#[ORM\JoinColumn(name: 'id_manufacturer')]
|
||||
#[Selectable()]
|
||||
protected ?Manufacturer $manufacturer = null;
|
||||
|
||||
/**
|
||||
|
|
|
@ -70,18 +70,18 @@ class Supplier extends AbstractCompany
|
|||
/**
|
||||
* @var Currency|null The currency that should be used by default for order informations with this supplier.
|
||||
* Set to null, to use global base currency.
|
||||
* @Selectable()
|
||||
*/
|
||||
#[ORM\ManyToOne(targetEntity: Currency::class)]
|
||||
#[ORM\JoinColumn(name: 'default_currency_id')]
|
||||
#[Selectable()]
|
||||
protected ?Currency $default_currency = null;
|
||||
|
||||
/**
|
||||
* @var BigDecimal|null the shipping costs that have to be paid, when ordering via this supplier
|
||||
* @BigDecimalPositiveOrZero()
|
||||
*/
|
||||
#[Groups(['extended', 'full', 'import'])]
|
||||
#[ORM\Column(name: 'shipping_costs', nullable: true, type: 'big_decimal', precision: 11, scale: 5)]
|
||||
#[BigDecimalPositiveOrZero()]
|
||||
protected ?BigDecimal $shipping_costs = null;
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue