Applied symplify rules to codebase.

This commit is contained in:
Jan Böhmer 2020-01-05 22:49:00 +01:00
parent 2f20d90041
commit 388e847b17
136 changed files with 1370 additions and 789 deletions

View file

@ -36,12 +36,6 @@ use Doctrine\ORM\Mapping as ORM;
*/
class Category extends PartsContainingDBElement
{
/**
* @var Collection|CategoryAttachment[]
* @ORM\OneToMany(targetEntity="App\Entity\Attachments\CategoryAttachment", mappedBy="element", cascade={"persist", "remove"}, orphanRemoval=true)
*/
protected $attachments;
/**
* @ORM\OneToMany(targetEntity="Category", mappedBy="parent")
*/
@ -105,6 +99,11 @@ class Category extends PartsContainingDBElement
* @ORM\Column(type="text")
*/
protected $default_comment = '';
/**
* @var Collection|CategoryAttachment[]
* @ORM\OneToMany(targetEntity="App\Entity\Attachments\CategoryAttachment", mappedBy="element", cascade={"persist", "remove"}, orphanRemoval=true)
*/
protected $attachments;
/**
* Returns the ID as an string, defined by the element class.

View file

@ -65,26 +65,25 @@ use Doctrine\ORM\Mapping as ORM;
class Footprint extends PartsContainingDBElement
{
/**
* @var Collection|FootprintAttachment[]
* @ORM\OneToMany(targetEntity="App\Entity\Attachments\FootprintAttachment", mappedBy="element", cascade={"persist", "remove"}, orphanRemoval=true)
* @ORM\ManyToOne(targetEntity="Footprint", inversedBy="children")
* @ORM\JoinColumn(name="parent_id", referencedColumnName="id")
*/
protected $attachments;
protected $parent;
/**
* @ORM\OneToMany(targetEntity="Footprint", mappedBy="parent")
*/
protected $children;
/**
* @ORM\ManyToOne(targetEntity="Footprint", inversedBy="children")
* @ORM\JoinColumn(name="parent_id", referencedColumnName="id")
*/
protected $parent;
/**
* @ORM\OneToMany(targetEntity="Part", mappedBy="footprint", fetch="EXTRA_LAZY")
*/
protected $parts;
/**
* @var Collection|FootprintAttachment[]
* @ORM\OneToMany(targetEntity="App\Entity\Attachments\FootprintAttachment", mappedBy="element", cascade={"persist", "remove"}, orphanRemoval=true)
*/
protected $attachments;
/**
* @var FootprintAttachment|null

View file

@ -65,26 +65,25 @@ use Doctrine\ORM\Mapping as ORM;
class Manufacturer extends Company
{
/**
* @var Collection|ManufacturerAttachment[]
* @ORM\OneToMany(targetEntity="App\Entity\Attachments\ManufacturerAttachment", mappedBy="element", cascade={"persist", "remove"}, orphanRemoval=true)
* @ORM\ManyToOne(targetEntity="Manufacturer", inversedBy="children")
* @ORM\JoinColumn(name="parent_id", referencedColumnName="id")
*/
protected $attachments;
protected $parent;
/**
* @ORM\OneToMany(targetEntity="Manufacturer", mappedBy="parent")
*/
protected $children;
/**
* @ORM\ManyToOne(targetEntity="Manufacturer", inversedBy="children")
* @ORM\JoinColumn(name="parent_id", referencedColumnName="id")
*/
protected $parent;
/**
* @ORM\OneToMany(targetEntity="Part", mappedBy="manufacturer", fetch="EXTRA_LAZY")
*/
protected $parts;
/**
* @var Collection|ManufacturerAttachment[]
* @ORM\OneToMany(targetEntity="App\Entity\Attachments\ManufacturerAttachment", mappedBy="element", cascade={"persist", "remove"}, orphanRemoval=true)
*/
protected $attachments;
/**
* Returns the ID as an string, defined by the element class.

View file

@ -41,12 +41,6 @@ use Symfony\Component\Validator\Constraints as Assert;
*/
class MeasurementUnit extends PartsContainingDBElement
{
/**
* @var Collection|MeasurementUnitAttachment[]
* @ORM\OneToMany(targetEntity="App\Entity\Attachments\MeasurementUnitAttachment", mappedBy="element", cascade={"persist", "remove"}, orphanRemoval=true)
*/
protected $attachments;
/**
* @var string The unit symbol that should be used for the Unit. This could be something like "", g (for grams)
* or m (for meters).
@ -84,6 +78,11 @@ class MeasurementUnit extends PartsContainingDBElement
* @ORM\OneToMany(targetEntity="Part", mappedBy="partUnit", fetch="EXTRA_LAZY")
*/
protected $parts;
/**
* @var Collection|MeasurementUnitAttachment[]
* @ORM\OneToMany(targetEntity="App\Entity\Attachments\MeasurementUnitAttachment", mappedBy="element", cascade={"persist", "remove"}, orphanRemoval=true)
*/
protected $attachments;
/**
* Returns the ID as an string, defined by the element class.

View file

@ -60,6 +60,7 @@ use App\Entity\Parts\PartTraits\InstockTrait;
use App\Entity\Parts\PartTraits\ManufacturerTrait;
use App\Entity\Parts\PartTraits\OrderTrait;
use App\Security\Annotations\ColumnSecurity;
use DateTime;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
@ -82,7 +83,9 @@ class Part extends AttachmentContainingDBElement
use ManufacturerTrait;
use OrderTrait;
/** TODO */
/**
* TODO
*/
protected $devices;
/**
@ -91,16 +94,9 @@ class Part extends AttachmentContainingDBElement
*/
protected $addedDate;
/**
* @var \DateTime the date when this element was modified the last time
* @ColumnSecurity(type="datetime")
* @ORM\Column(type="datetime", name="last_modified", options={"default"="CURRENT_TIMESTAMP"})
*/
protected $lastModified;
/** *************************************************************
* Overridden properties
* (They are defined here and not in a trait, to avoid conflicts)
* (They are defined here and not in a trait, to avoid conflicts).
****************************************************************/
/**
@ -117,6 +113,13 @@ class Part extends AttachmentContainingDBElement
*/
protected $attachments;
/**
* @var DateTime the date when this element was modified the last time
* @ColumnSecurity(type="datetime")
* @ORM\Column(type="datetime", name="last_modified", options={"default"="CURRENT_TIMESTAMP"})
*/
protected $lastModified;
/**
* @var Attachment
* @ORM\ManyToOne(targetEntity="App\Entity\Attachments\Attachment")

View file

@ -29,7 +29,9 @@ use App\Entity\Base\TimestampTrait;
use App\Entity\Parts\PartTraits\InstockTrait;
use App\Validator\Constraints\Selectable;
use App\Validator\Constraints\ValidPartLot;
use DateTime;
use Doctrine\ORM\Mapping as ORM;
use Exception;
use Symfony\Component\Validator\Constraints as Assert;
/**
@ -58,8 +60,8 @@ class PartLot extends DBElement
protected $comment = '';
/**
* @var ?\DateTime Set a time until when the lot must be used.
* Set to null, if the lot can be used indefinitely.
* @var ?DateTime Set a time until when the lot must be used.
* Set to null, if the lot can be used indefinitely.
* @ORM\Column(type="datetime", name="expiration_date", nullable=true)
*/
protected $expiration_date;
@ -72,14 +74,6 @@ class PartLot extends DBElement
*/
protected $storage_location;
/**
* @var Part The part that is stored in this lot
* @ORM\ManyToOne(targetEntity="Part", inversedBy="partLots")
* @ORM\JoinColumn(name="id_part", referencedColumnName="id", nullable=false, onDelete="CASCADE")
* @Assert\NotNull()
*/
protected $part;
/**
* @var bool If this is set to true, the instock amount is marked as not known
* @ORM\Column(type="boolean")
@ -99,6 +93,14 @@ class PartLot extends DBElement
*/
protected $needs_refill = false;
/**
* @var Part The part that is stored in this lot
* @ORM\ManyToOne(targetEntity="Part", inversedBy="partLots")
* @ORM\JoinColumn(name="id_part", referencedColumnName="id", nullable=false, onDelete="CASCADE")
* @Assert\NotNull()
*/
protected $part;
/**
* Returns the ID as an string, defined by the element class.
* This should have a form like P000014, for a part with ID 14.
@ -116,7 +118,7 @@ class PartLot extends DBElement
*
* @return bool|null True, if the part lot is expired. Returns null, if no expiration date was set.
*
* @throws \Exception If an error with the DateTime occurs
* @throws Exception If an error with the DateTime occurs
*/
public function isExpired(): ?bool
{
@ -125,7 +127,7 @@ class PartLot extends DBElement
}
//Check if the expiration date is bigger then current time
return $this->expiration_date < new \DateTime('now');
return $this->expiration_date < new DateTime('now');
}
/**
@ -175,9 +177,9 @@ class PartLot extends DBElement
/**
* Gets the expiration date for the part lot. Returns null, if no expiration date was set.
*
* @return \DateTime|null
* @return DateTime|null
*/
public function getExpirationDate(): ?\DateTime
public function getExpirationDate(): ?DateTime
{
return $this->expiration_date;
}
@ -185,11 +187,11 @@ class PartLot extends DBElement
/**
* Sets the expiration date for the part lot. Set to null, if the part lot does not expires.
*
* @param \DateTime $expiration_date
* @param DateTime $expiration_date
*
* @return PartLot
*/
public function setExpirationDate(?\DateTime $expiration_date): self
public function setExpirationDate(?DateTime $expiration_date): self
{
$this->expiration_date = $expiration_date;

View file

@ -26,6 +26,7 @@ namespace App\Entity\Parts\PartTraits;
use App\Entity\PriceInformations\Orderdetail;
use App\Security\Annotations\ColumnSecurity;
use function count;
use Doctrine\Common\Collections\Collection;
/**
@ -183,7 +184,7 @@ trait OrderTrait
{
$all_orderdetails = $this->getOrderdetails();
if (0 === \count($all_orderdetails)) {
if (0 === count($all_orderdetails)) {
return false;
}

View file

@ -64,12 +64,6 @@ use Doctrine\ORM\Mapping as ORM;
*/
class Storelocation extends PartsContainingDBElement
{
/**
* @var Collection|StorelocationAttachment[]
* @ORM\OneToMany(targetEntity="App\Entity\Attachments\StorelocationAttachment", mappedBy="element", cascade={"persist", "remove"}, orphanRemoval=true)
*/
protected $attachments;
/**
* @ORM\OneToMany(targetEntity="Storelocation", mappedBy="parent")
*/
@ -81,6 +75,22 @@ class Storelocation extends PartsContainingDBElement
*/
protected $parent;
/**
* @var MeasurementUnit|null The measurement unit, which parts can be stored in here
* @ORM\ManyToOne(targetEntity="MeasurementUnit")
* @ORM\JoinColumn(name="storage_type_id", referencedColumnName="id")
*/
protected $storage_type;
/**
* @ORM\ManyToMany(targetEntity="Part", fetch="EXTRA_LAZY")
* @ORM\JoinTable(name="part_lots",
* joinColumns={@ORM\JoinColumn(name="id_store_location", referencedColumnName="id")},
* inverseJoinColumns={@ORM\JoinColumn(name="id_part", referencedColumnName="id")}
* )
*/
protected $parts;
/**
* @var bool
* @ORM\Column(type="boolean")
@ -98,22 +108,11 @@ class Storelocation extends PartsContainingDBElement
* @ORM\Column(type="boolean")
*/
protected $limit_to_existing_parts = false;
/**
* @var MeasurementUnit|null The measurement unit, which parts can be stored in here
* @ORM\ManyToOne(targetEntity="MeasurementUnit")
* @ORM\JoinColumn(name="storage_type_id", referencedColumnName="id")
* @var Collection|StorelocationAttachment[]
* @ORM\OneToMany(targetEntity="App\Entity\Attachments\StorelocationAttachment", mappedBy="element", cascade={"persist", "remove"}, orphanRemoval=true)
*/
protected $storage_type;
/**
* @ORM\ManyToMany(targetEntity="Part", fetch="EXTRA_LAZY")
* @ORM\JoinTable(name="part_lots",
* joinColumns={@ORM\JoinColumn(name="id_store_location", referencedColumnName="id")},
* inverseJoinColumns={@ORM\JoinColumn(name="id_part", referencedColumnName="id")}
* )
*/
protected $parts;
protected $attachments;
/********************************************************************************
*

View file

@ -67,12 +67,6 @@ use Symfony\Component\Validator\Constraints as Assert;
*/
class Supplier extends Company
{
/**
* @var Collection|SupplierAttachment[]
* @ORM\OneToMany(targetEntity="App\Entity\Attachments\SupplierAttachment", mappedBy="element", cascade={"persist", "remove"}, orphanRemoval=true)
*/
protected $attachments;
/**
* @ORM\OneToMany(targetEntity="Supplier", mappedBy="parent")
*/
@ -113,6 +107,11 @@ class Supplier extends Company
* )
*/
protected $parts;
/**
* @var Collection|SupplierAttachment[]
* @ORM\OneToMany(targetEntity="App\Entity\Attachments\SupplierAttachment", mappedBy="element", cascade={"persist", "remove"}, orphanRemoval=true)
*/
protected $attachments;
/**
* Gets the currency that should be used by default, when creating a orderdetail with this supplier.