mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-21 09:35:49 +02:00
Replaced filter classes getters with public readonly properties to improve DX
This commit is contained in:
parent
afa17ca429
commit
4a644d8712
5 changed files with 56 additions and 325 deletions
|
@ -167,7 +167,7 @@ class PartListsController extends AbstractController
|
|||
return $this->showListWithFilter($request,
|
||||
'parts/lists/category_list.html.twig',
|
||||
function (PartFilter $filter) use ($category) {
|
||||
$filter->getCategory()->setOperator('INCLUDING_CHILDREN')->setValue($category);
|
||||
$filter->category->setOperator('INCLUDING_CHILDREN')->setValue($category);
|
||||
}, function (FormInterface $filterForm) {
|
||||
$this->disableFormFieldAfterCreation($filterForm->get('category')->get('value'));
|
||||
}, [
|
||||
|
@ -185,7 +185,7 @@ class PartListsController extends AbstractController
|
|||
return $this->showListWithFilter($request,
|
||||
'parts/lists/footprint_list.html.twig',
|
||||
function (PartFilter $filter) use ($footprint) {
|
||||
$filter->getFootprint()->setOperator('INCLUDING_CHILDREN')->setValue($footprint);
|
||||
$filter->footprint->setOperator('INCLUDING_CHILDREN')->setValue($footprint);
|
||||
}, function (FormInterface $filterForm) {
|
||||
$this->disableFormFieldAfterCreation($filterForm->get('footprint')->get('value'));
|
||||
}, [
|
||||
|
@ -203,7 +203,7 @@ class PartListsController extends AbstractController
|
|||
return $this->showListWithFilter($request,
|
||||
'parts/lists/manufacturer_list.html.twig',
|
||||
function (PartFilter $filter) use ($manufacturer) {
|
||||
$filter->getManufacturer()->setOperator('INCLUDING_CHILDREN')->setValue($manufacturer);
|
||||
$filter->manufacturer->setOperator('INCLUDING_CHILDREN')->setValue($manufacturer);
|
||||
}, function (FormInterface $filterForm) {
|
||||
$this->disableFormFieldAfterCreation($filterForm->get('manufacturer')->get('value'));
|
||||
}, [
|
||||
|
@ -221,7 +221,7 @@ class PartListsController extends AbstractController
|
|||
return $this->showListWithFilter($request,
|
||||
'parts/lists/store_location_list.html.twig',
|
||||
function (PartFilter $filter) use ($storelocation) {
|
||||
$filter->getStorelocation()->setOperator('INCLUDING_CHILDREN')->setValue($storelocation);
|
||||
$filter->storelocation->setOperator('INCLUDING_CHILDREN')->setValue($storelocation);
|
||||
}, function (FormInterface $filterForm) {
|
||||
$this->disableFormFieldAfterCreation($filterForm->get('storelocation')->get('value'));
|
||||
}, [
|
||||
|
@ -239,7 +239,7 @@ class PartListsController extends AbstractController
|
|||
return $this->showListWithFilter($request,
|
||||
'parts/lists/supplier_list.html.twig',
|
||||
function (PartFilter $filter) use ($supplier) {
|
||||
$filter->getSupplier()->setOperator('INCLUDING_CHILDREN')->setValue($supplier);
|
||||
$filter->supplier->setOperator('INCLUDING_CHILDREN')->setValue($supplier);
|
||||
}, function (FormInterface $filterForm) {
|
||||
$this->disableFormFieldAfterCreation($filterForm->get('supplier')->get('value'));
|
||||
}, [
|
||||
|
@ -257,7 +257,7 @@ class PartListsController extends AbstractController
|
|||
return $this->showListWithFilter($request,
|
||||
'parts/lists/tags_list.html.twig',
|
||||
function (PartFilter $filter) use ($tag) {
|
||||
$filter->getTags()->setOperator('ANY')->setValue($tag);
|
||||
$filter->tags->setOperator('ANY')->setValue($tag);
|
||||
}, function (FormInterface $filterForm) {
|
||||
$this->disableFormFieldAfterCreation($filterForm->get('tags')->get('value'));
|
||||
}, [
|
||||
|
|
|
@ -37,13 +37,13 @@ class AttachmentFilter implements FilterInterface
|
|||
{
|
||||
use CompoundFilterTrait;
|
||||
|
||||
protected NumberConstraint $dbId;
|
||||
protected InstanceOfConstraint $targetType;
|
||||
protected TextConstraint $name;
|
||||
protected EntityConstraint $attachmentType;
|
||||
protected BooleanConstraint $showInTable;
|
||||
protected DateTimeConstraint $lastModified;
|
||||
protected DateTimeConstraint $addedDate;
|
||||
public readonly NumberConstraint $dbId;
|
||||
public readonly InstanceOfConstraint $targetType;
|
||||
public readonly TextConstraint $name;
|
||||
public readonly EntityConstraint $attachmentType;
|
||||
public readonly BooleanConstraint $showInTable;
|
||||
public readonly DateTimeConstraint $lastModified;
|
||||
public readonly DateTimeConstraint $addedDate;
|
||||
|
||||
|
||||
public function __construct(NodesListBuilder $nodesListBuilder)
|
||||
|
@ -61,47 +61,4 @@ class AttachmentFilter implements FilterInterface
|
|||
{
|
||||
$this->applyAllChildFilters($queryBuilder);
|
||||
}
|
||||
|
||||
public function getDbId(): NumberConstraint
|
||||
{
|
||||
return $this->dbId;
|
||||
}
|
||||
|
||||
public function getName(): TextConstraint
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
public function getLastModified(): DateTimeConstraint
|
||||
{
|
||||
return $this->lastModified;
|
||||
}
|
||||
|
||||
public function getAddedDate(): DateTimeConstraint
|
||||
{
|
||||
return $this->addedDate;
|
||||
}
|
||||
|
||||
|
||||
public function getShowInTable(): BooleanConstraint
|
||||
{
|
||||
return $this->showInTable;
|
||||
}
|
||||
|
||||
|
||||
public function getAttachmentType(): EntityConstraint
|
||||
{
|
||||
return $this->attachmentType;
|
||||
}
|
||||
|
||||
public function getTargetType(): InstanceOfConstraint
|
||||
{
|
||||
return $this->targetType;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -39,9 +39,6 @@ trait CompoundFilterTrait
|
|||
$reflection = new \ReflectionClass($this);
|
||||
|
||||
foreach ($reflection->getProperties() as $property) {
|
||||
//Set property to accessible (otherwise we run into problems on PHP < 8.1)
|
||||
$property->setAccessible(true);
|
||||
|
||||
$value = $property->getValue($this);
|
||||
//We only want filters (objects implementing FilterInterface)
|
||||
if($value instanceof FilterInterface) {
|
||||
|
|
|
@ -35,13 +35,13 @@ class LogFilter implements FilterInterface
|
|||
{
|
||||
use CompoundFilterTrait;
|
||||
|
||||
protected DateTimeConstraint $timestamp;
|
||||
protected IntConstraint $dbId;
|
||||
protected ChoiceConstraint $level;
|
||||
protected InstanceOfConstraint $eventType;
|
||||
protected ChoiceConstraint $targetType;
|
||||
protected IntConstraint $targetId;
|
||||
protected EntityConstraint $user;
|
||||
public readonly DateTimeConstraint $timestamp;
|
||||
public readonly IntConstraint $dbId;
|
||||
public readonly ChoiceConstraint $level;
|
||||
public readonly InstanceOfConstraint $eventType;
|
||||
public readonly ChoiceConstraint $targetType;
|
||||
public readonly IntConstraint $targetId;
|
||||
public readonly EntityConstraint $user;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
|
@ -59,44 +59,4 @@ class LogFilter implements FilterInterface
|
|||
{
|
||||
$this->applyAllChildFilters($queryBuilder);
|
||||
}
|
||||
|
||||
public function getTimestamp(): DateTimeConstraint
|
||||
{
|
||||
return $this->timestamp;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return IntConstraint|NumberConstraint
|
||||
*/
|
||||
public function getDbId(): IntConstraint|NumberConstraint
|
||||
{
|
||||
return $this->dbId;
|
||||
}
|
||||
|
||||
public function getLevel(): ChoiceConstraint
|
||||
{
|
||||
return $this->level;
|
||||
}
|
||||
|
||||
public function getEventType(): InstanceOfConstraint
|
||||
{
|
||||
return $this->eventType;
|
||||
}
|
||||
|
||||
public function getTargetType(): ChoiceConstraint
|
||||
{
|
||||
return $this->targetType;
|
||||
}
|
||||
|
||||
public function getTargetId(): IntConstraint
|
||||
{
|
||||
return $this->targetId;
|
||||
}
|
||||
|
||||
public function getUser(): EntityConstraint
|
||||
{
|
||||
return $this->user;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -49,46 +49,46 @@ class PartFilter implements FilterInterface
|
|||
|
||||
use CompoundFilterTrait;
|
||||
|
||||
protected IntConstraint $dbId;
|
||||
protected TextConstraint $ipn;
|
||||
protected TextConstraint $name;
|
||||
protected TextConstraint $description;
|
||||
protected TextConstraint $comment;
|
||||
protected TagsConstraint $tags;
|
||||
protected NumberConstraint $minAmount;
|
||||
protected BooleanConstraint $favorite;
|
||||
protected BooleanConstraint $needsReview;
|
||||
protected NumberConstraint $mass;
|
||||
protected DateTimeConstraint $lastModified;
|
||||
protected DateTimeConstraint $addedDate;
|
||||
protected EntityConstraint $category;
|
||||
protected EntityConstraint $footprint;
|
||||
protected EntityConstraint $manufacturer;
|
||||
protected ChoiceConstraint $manufacturing_status;
|
||||
protected EntityConstraint $supplier;
|
||||
protected IntConstraint $orderdetailsCount;
|
||||
protected BooleanConstraint $obsolete;
|
||||
protected EntityConstraint $storelocation;
|
||||
protected IntConstraint $lotCount;
|
||||
protected IntConstraint $amountSum;
|
||||
protected LessThanDesiredConstraint $lessThanDesired;
|
||||
public readonly IntConstraint $dbId;
|
||||
public readonly TextConstraint $ipn;
|
||||
public readonly TextConstraint $name;
|
||||
public readonly TextConstraint $description;
|
||||
public readonly TextConstraint $comment;
|
||||
public readonly TagsConstraint $tags;
|
||||
public readonly NumberConstraint $minAmount;
|
||||
public readonly BooleanConstraint $favorite;
|
||||
public readonly BooleanConstraint $needsReview;
|
||||
public readonly NumberConstraint $mass;
|
||||
public readonly DateTimeConstraint $lastModified;
|
||||
public readonly DateTimeConstraint $addedDate;
|
||||
public readonly EntityConstraint $category;
|
||||
public readonly EntityConstraint $footprint;
|
||||
public readonly EntityConstraint $manufacturer;
|
||||
public readonly ChoiceConstraint $manufacturing_status;
|
||||
public readonly EntityConstraint $supplier;
|
||||
public readonly IntConstraint $orderdetailsCount;
|
||||
public readonly BooleanConstraint $obsolete;
|
||||
public readonly EntityConstraint $storelocation;
|
||||
public readonly IntConstraint $lotCount;
|
||||
public readonly IntConstraint $amountSum;
|
||||
public readonly LessThanDesiredConstraint $lessThanDesired;
|
||||
|
||||
protected BooleanConstraint $lotNeedsRefill;
|
||||
protected TextConstraint $lotDescription;
|
||||
protected BooleanConstraint $lotUnknownAmount;
|
||||
protected DateTimeConstraint $lotExpirationDate;
|
||||
protected EntityConstraint $lotOwner;
|
||||
public readonly BooleanConstraint $lotNeedsRefill;
|
||||
public readonly TextConstraint $lotDescription;
|
||||
public readonly BooleanConstraint $lotUnknownAmount;
|
||||
public readonly DateTimeConstraint $lotExpirationDate;
|
||||
public readonly EntityConstraint $lotOwner;
|
||||
|
||||
protected EntityConstraint $measurementUnit;
|
||||
protected TextConstraint $manufacturer_product_url;
|
||||
protected TextConstraint $manufacturer_product_number;
|
||||
protected IntConstraint $attachmentsCount;
|
||||
protected EntityConstraint $attachmentType;
|
||||
protected TextConstraint $attachmentName;
|
||||
public readonly EntityConstraint $measurementUnit;
|
||||
public readonly TextConstraint $manufacturer_product_url;
|
||||
public readonly TextConstraint $manufacturer_product_number;
|
||||
public readonly IntConstraint $attachmentsCount;
|
||||
public readonly EntityConstraint $attachmentType;
|
||||
public readonly TextConstraint $attachmentName;
|
||||
|
||||
/** @var ArrayCollection<int, ParameterConstraint> */
|
||||
protected ArrayCollection $parameters;
|
||||
protected IntConstraint $parametersCount;
|
||||
public readonly ArrayCollection $parameters;
|
||||
public readonly IntConstraint $parametersCount;
|
||||
|
||||
public function __construct(NodesListBuilder $nodesListBuilder)
|
||||
{
|
||||
|
@ -146,187 +146,4 @@ class PartFilter implements FilterInterface
|
|||
{
|
||||
$this->applyAllChildFilters($queryBuilder);
|
||||
}
|
||||
|
||||
|
||||
public function getFavorite(): BooleanConstraint
|
||||
{
|
||||
return $this->favorite;
|
||||
}
|
||||
|
||||
public function getNeedsReview(): BooleanConstraint
|
||||
{
|
||||
return $this->needsReview;
|
||||
}
|
||||
|
||||
public function getMass(): NumberConstraint
|
||||
{
|
||||
return $this->mass;
|
||||
}
|
||||
|
||||
public function getName(): TextConstraint
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
public function getDescription(): TextConstraint
|
||||
{
|
||||
return $this->description;
|
||||
}
|
||||
|
||||
public function getLastModified(): DateTimeConstraint
|
||||
{
|
||||
return $this->lastModified;
|
||||
}
|
||||
|
||||
public function getAddedDate(): DateTimeConstraint
|
||||
{
|
||||
return $this->addedDate;
|
||||
}
|
||||
|
||||
public function getCategory(): EntityConstraint
|
||||
{
|
||||
return $this->category;
|
||||
}
|
||||
|
||||
public function getFootprint(): EntityConstraint
|
||||
{
|
||||
return $this->footprint;
|
||||
}
|
||||
|
||||
public function getManufacturer(): EntityConstraint
|
||||
{
|
||||
return $this->manufacturer;
|
||||
}
|
||||
|
||||
public function getSupplier(): EntityConstraint
|
||||
{
|
||||
return $this->supplier;
|
||||
}
|
||||
|
||||
public function getStorelocation(): EntityConstraint
|
||||
{
|
||||
return $this->storelocation;
|
||||
}
|
||||
|
||||
public function getMeasurementUnit(): EntityConstraint
|
||||
{
|
||||
return $this->measurementUnit;
|
||||
}
|
||||
|
||||
public function getDbId(): NumberConstraint
|
||||
{
|
||||
return $this->dbId;
|
||||
}
|
||||
|
||||
public function getIpn(): TextConstraint
|
||||
{
|
||||
return $this->ipn;
|
||||
}
|
||||
|
||||
public function getComment(): TextConstraint
|
||||
{
|
||||
return $this->comment;
|
||||
}
|
||||
|
||||
public function getMinAmount(): NumberConstraint
|
||||
{
|
||||
return $this->minAmount;
|
||||
}
|
||||
|
||||
public function getManufacturerProductUrl(): TextConstraint
|
||||
{
|
||||
return $this->manufacturer_product_url;
|
||||
}
|
||||
|
||||
public function getManufacturerProductNumber(): TextConstraint
|
||||
{
|
||||
return $this->manufacturer_product_number;
|
||||
}
|
||||
|
||||
public function getLotCount(): NumberConstraint
|
||||
{
|
||||
return $this->lotCount;
|
||||
}
|
||||
|
||||
public function getLotOwner(): EntityConstraint
|
||||
{
|
||||
return $this->lotOwner;
|
||||
}
|
||||
|
||||
public function getTags(): TagsConstraint
|
||||
{
|
||||
return $this->tags;
|
||||
}
|
||||
|
||||
public function getOrderdetailsCount(): IntConstraint
|
||||
{
|
||||
return $this->orderdetailsCount;
|
||||
}
|
||||
|
||||
public function getAttachmentsCount(): IntConstraint
|
||||
{
|
||||
return $this->attachmentsCount;
|
||||
}
|
||||
|
||||
public function getLotNeedsRefill(): BooleanConstraint
|
||||
{
|
||||
return $this->lotNeedsRefill;
|
||||
}
|
||||
|
||||
public function getLotUnknownAmount(): BooleanConstraint
|
||||
{
|
||||
return $this->lotUnknownAmount;
|
||||
}
|
||||
|
||||
public function getLotExpirationDate(): DateTimeConstraint
|
||||
{
|
||||
return $this->lotExpirationDate;
|
||||
}
|
||||
|
||||
public function getAttachmentType(): EntityConstraint
|
||||
{
|
||||
return $this->attachmentType;
|
||||
}
|
||||
|
||||
public function getAttachmentName(): TextConstraint
|
||||
{
|
||||
return $this->attachmentName;
|
||||
}
|
||||
|
||||
public function getManufacturingStatus(): ChoiceConstraint
|
||||
{
|
||||
return $this->manufacturing_status;
|
||||
}
|
||||
|
||||
public function getAmountSum(): NumberConstraint
|
||||
{
|
||||
return $this->amountSum;
|
||||
}
|
||||
|
||||
public function getParameters(): ArrayCollection
|
||||
{
|
||||
return $this->parameters;
|
||||
}
|
||||
|
||||
public function getParametersCount(): IntConstraint
|
||||
{
|
||||
return $this->parametersCount;
|
||||
}
|
||||
|
||||
public function getLotDescription(): TextConstraint
|
||||
{
|
||||
return $this->lotDescription;
|
||||
}
|
||||
|
||||
public function getObsolete(): BooleanConstraint
|
||||
{
|
||||
return $this->obsolete;
|
||||
}
|
||||
|
||||
public function getLessThanDesired(): LessThanDesiredConstraint
|
||||
{
|
||||
return $this->lessThanDesired;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue