Fixed coding style.

This commit is contained in:
Jan Böhmer 2020-03-15 13:56:31 +01:00
parent 24939f2342
commit fd61c8d9e2
129 changed files with 962 additions and 1091 deletions

View file

@ -365,7 +365,6 @@ abstract class Attachment extends AbstractNamedDBElement
/**
* Sets the element that is associated with this attachment.
*
* @param AttachmentContainingDBElement $element
* @return $this
*/
public function setElement(AttachmentContainingDBElement $element): self
@ -394,7 +393,6 @@ abstract class Attachment extends AbstractNamedDBElement
}
/**
* @param AttachmentType $attachement_type
* @return $this
*/
public function setAttachmentType(AttachmentType $attachement_type): self
@ -408,7 +406,6 @@ abstract class Attachment extends AbstractNamedDBElement
* Sets the url associated with this attachment.
* If the url is empty nothing is changed, to not override the file path.
*
* @param string|null $url
* @return Attachment
*/
public function setURL(?string $url): self

View file

@ -22,8 +22,8 @@ declare(strict_types=1);
namespace App\Entity\Attachments;
use App\Entity\Base\MasterAttachmentTrait;
use App\Entity\Base\AbstractNamedDBElement;
use App\Entity\Base\MasterAttachmentTrait;
use App\Entity\Contracts\HasAttachmentsInterface;
use App\Entity\Contracts\HasMasterAttachmentInterface;
use Doctrine\Common\Collections\ArrayCollection;
@ -39,8 +39,8 @@ abstract class AttachmentContainingDBElement extends AbstractNamedDBElement impl
/**
* @var Attachment[]|Collection
* //TODO
* //@ORM\OneToMany(targetEntity="Attachment", mappedBy="element")
* //TODO
* //@ORM\OneToMany(targetEntity="Attachment", mappedBy="element")
*
* Mapping is done in sub classes like part
*/
@ -51,6 +51,25 @@ abstract class AttachmentContainingDBElement extends AbstractNamedDBElement impl
$this->attachments = new ArrayCollection();
}
public function __clone()
{
if ($this->id) {
$attachments = $this->attachments;
$this->attachments = new ArrayCollection();
//Set master attachment is needed
foreach ($attachments as $attachment) {
$clone = clone $attachment;
if ($attachment === $this->master_picture_attachment) {
$this->setMasterPictureAttachment($clone);
}
$this->addAttachment($clone);
}
}
//Parent has to be last call, as it resets the ID
parent::__clone();
}
/********************************************************************************
*
* Getters
@ -86,7 +105,6 @@ abstract class AttachmentContainingDBElement extends AbstractNamedDBElement impl
/**
* Removes the given attachment from this element.
*
* @param Attachment $attachment
* @return $this
*/
public function removeAttachment(Attachment $attachment): self
@ -95,23 +113,4 @@ abstract class AttachmentContainingDBElement extends AbstractNamedDBElement impl
return $this;
}
public function __clone()
{
if ($this->id) {
$attachments = $this->attachments;
$this->attachments = new ArrayCollection();
//Set master attachment is needed
foreach ($attachments as $attachment) {
$clone = clone $attachment;
if ($attachment === $this->master_picture_attachment) {
$this->setMasterPictureAttachment($clone);
}
$this->addAttachment($clone);
}
}
//Parent has to be last call, as it resets the ID
parent::__clone();
}
}

View file

@ -24,7 +24,6 @@ namespace App\Entity\Attachments;
use App\Entity\Base\AbstractStructuralDBElement;
use App\Entity\Parameters\AttachmentTypeParameter;
use App\Entity\Parameters\DeviceParameter;
use App\Validator\Constraints\ValidFileFilter;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;

View file

@ -173,7 +173,7 @@ abstract class AbstractCompany extends AbstractPartsContainingDBElement
/**
* Set the addres.
*
* @param string $new_address the new address (with "\n" as line break)
* @param string $new_address the new address (with "\n" as line break)
*
* @return $this
*/
@ -188,6 +188,7 @@ abstract class AbstractCompany extends AbstractPartsContainingDBElement
* Set the phone number.
*
* @param string $new_phone_number the new phone number
*
* @return $this
*/
public function setPhoneNumber(string $new_phone_number): self
@ -201,6 +202,7 @@ abstract class AbstractCompany extends AbstractPartsContainingDBElement
* Set the fax number.
*
* @param string $new_fax_number the new fax number
*
* @return $this
*/
public function setFaxNumber(string $new_fax_number): self
@ -214,6 +216,7 @@ abstract class AbstractCompany extends AbstractPartsContainingDBElement
* Set the e-mail address.
*
* @param string $new_email_address the new e-mail address
*
* @return $this
*/
public function setEmailAddress(string $new_email_address): self
@ -227,6 +230,7 @@ abstract class AbstractCompany extends AbstractPartsContainingDBElement
* Set the website.
*
* @param string $new_website the new website
*
* @return $this
*/
public function setWebsite(string $new_website): self
@ -240,6 +244,7 @@ abstract class AbstractCompany extends AbstractPartsContainingDBElement
* Set the link to the website of an article.
*
* @param string $new_url the new URL with the placeholder %PARTNUMBER% for the part number
*
* @return $this
*/
public function setAutoProductUrl(string $new_url): self

View file

@ -57,6 +57,15 @@ abstract class AbstractNamedDBElement extends AbstractDBElement implements Named
return $this->getName();
}
public function __clone()
{
if ($this->id) {
//We create a new object, so give it a new creation date
$this->addedDate = null;
}
parent::__clone(); // TODO: Change the autogenerated stub
}
/********************************************************************************
*
* Getters
@ -89,15 +98,7 @@ abstract class AbstractNamedDBElement extends AbstractDBElement implements Named
public function setName(string $new_name): self
{
$this->name = $new_name;
return $this;
}
public function __clone()
{
if ($this->id) {
//We create a new object, so give it a new creation date
$this->addedDate = null;
}
parent::__clone(); // TODO: Change the autogenerated stub
}
}

View file

@ -115,7 +115,7 @@ abstract class AbstractStructuralDBElement extends AttachmentContainingDBElement
* Check if this element is a child of another element (recursive).
*
* @param AbstractStructuralDBElement $another_element the object to compare
* IMPORTANT: both objects to compare must be from the same class (for example two "Device" objects)!
* IMPORTANT: both objects to compare must be from the same class (for example two "Device" objects)!
*
* @return bool True, if this element is child of $another_element.
*
@ -316,13 +316,14 @@ abstract class AbstractStructuralDBElement extends AttachmentContainingDBElement
}
/**
* @param static[]|Collection $elements
* @param static[]|Collection $elements
*
* @return $this
*/
public function setChildren($elements): self
{
if (!is_array($elements) && !$elements instanceof Collection) {
throw new InvalidArgumentException('$elements must be an array or Collection!');
if (! is_array($elements) && ! $elements instanceof Collection) {
throw new InvalidArgumentException('$elements must be an array or Collection!');
}
$this->children = $elements;
@ -331,7 +332,6 @@ abstract class AbstractStructuralDBElement extends AttachmentContainingDBElement
}
/**
* @param bool $not_selectable
* @return AbstractStructuralDBElement
*/
public function setNotSelectable(bool $not_selectable): self

View file

@ -72,7 +72,6 @@ trait MasterAttachmentTrait
/**
* Sets the new master picture for this part.
*
* @param Attachment|null $new_master_attachment
* @return $this
*/
public function setMasterPictureAttachment(?Attachment $new_master_attachment): self

View file

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
@ -20,10 +23,9 @@
namespace App\Entity\Contracts;
use Doctrine\Common\Collections\Collection;
interface HasAttachmentsInterface
{
public function getAttachments(): Collection;
}
}

View file

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
@ -20,7 +23,6 @@
namespace App\Entity\Contracts;
use App\Entity\Attachments\Attachment;
interface HasMasterAttachmentInterface
@ -32,4 +34,4 @@ interface HasMasterAttachmentInterface
* @return Attachment|null the master picture Attachment of this part (if there is one)
*/
public function getMasterPictureAttachment(): ?Attachment;
}
}

View file

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
@ -20,11 +23,11 @@
namespace App\Entity\Contracts;
interface LogWithCommentInterface
{
/**
* Checks if this log entry has a user provided comment.
*
* @return bool
*/
public function hasComment(): bool;
@ -32,14 +35,15 @@ interface LogWithCommentInterface
/**
* Gets the user provided comment associated with this log entry.
* Returns null if not comment was set.
*
* @return string|null
*/
public function getComment(): ?string;
/**
* Sets the user provided comment associated with this log entry.
* @param string|null $new_comment
*
* @return $this
*/
public function setComment(?string $new_comment): self;
}
}

View file

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
@ -20,27 +23,27 @@
namespace App\Entity\Contracts;
use App\Entity\LogSystem\AbstractLogEntry;
interface LogWithEventUndoInterface
{
/**
* Checks if this element undoes another event.
*
* @return bool
*/
public function isUndoEvent(): bool;
/**
* Returns the ID of the undone event or null if no event is undone.
*
* @return int|null
*/
public function getUndoEventID(): ?int;
/**
* Sets the event that is undone, and the undo mode.
* @param AbstractLogEntry $event
* @param string $mode
*
* @return $this
*/
public function setUndoneEvent(AbstractLogEntry $event, string $mode = 'undo'): self;
@ -49,7 +52,8 @@ interface LogWithEventUndoInterface
* Returns the mode how the event was undone:
* "undo" = Only a single event was applied to element
* "revert" = Element was reverted to the state it was to the timestamp of the log.
*
* @return string
*/
public function getUndoMode(): string;
}
}

View file

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
@ -20,7 +23,6 @@
namespace App\Entity\Contracts;
interface NamedElementInterface
{
/**
@ -29,4 +31,4 @@ interface NamedElementInterface
* @return string the name of this element
*/
public function getName(): string;
}
}

View file

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
@ -21,7 +24,6 @@
namespace App\Entity\Contracts;
use DateTime;
interface TimeStampableInterface
@ -41,4 +43,4 @@ interface TimeStampableInterface
* @return DateTime|null the creation time of the part
*/
public function getAddedDate(): ?DateTime;
}
}

View file

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
@ -21,11 +24,11 @@
namespace App\Entity\Contracts;
interface TimeTravelInterface
{
/**
* Checks if this entry has informations which data has changed.
*
* @return bool True if this entry has informations about the changed data.
*/
public function hasOldDataInformations(): bool;
@ -35,7 +38,8 @@ interface TimeTravelInterface
/**
* Returns the the timestamp associated with this change.
*
* @return \DateTime
*/
public function getTimestamp(): \DateTime;
}
}

View file

@ -147,7 +147,7 @@ abstract class AbstractLogEntry extends AbstractDBElement
self::TARGET_TYPE_ORDERDETAIL => Orderdetail::class,
self::TARGET_TYPE_PRICEDETAIL => Pricedetail::class,
self::TARGET_TYPE_MEASUREMENTUNIT => MeasurementUnit::class,
self::TARGET_TYPE_PARAMETER => AbstractParameter::class
self::TARGET_TYPE_PARAMETER => AbstractParameter::class,
];
/** @var User The user which has caused this log entry
@ -206,7 +206,6 @@ abstract class AbstractLogEntry extends AbstractDBElement
/**
* Sets the user that caused the event.
*
* @param User $user
* @return $this
*/
public function setUser(User $user): self
@ -229,7 +228,6 @@ abstract class AbstractLogEntry extends AbstractDBElement
/**
* Sets the timestamp when the event happened.
*
* @param DateTime $timestamp
* @return $this
*/
public function setTimestamp(DateTime $timestamp): self
@ -258,7 +256,6 @@ abstract class AbstractLogEntry extends AbstractDBElement
/**
* Sets the new level of this log entry.
*
* @param int $level
* @return $this
*/
public function setLevel(int $level): self
@ -284,7 +281,6 @@ abstract class AbstractLogEntry extends AbstractDBElement
/**
* Sets the priority level of this log entry as PSR3 compatible string.
*
* @param string $level
* @return $this
*/
public function setLevelString(string $level): self
@ -373,12 +369,13 @@ abstract class AbstractLogEntry extends AbstractDBElement
/**
* Sets the target ID of the element associated with this element.
* @param int $target_id
*
* @return $this
*/
public function setTargetElementID(int $target_id): self
{
$this->target_id = $target_id;
return $this;
}

View file

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
@ -20,7 +23,6 @@
namespace App\Entity\LogSystem;
use App\Entity\Base\AbstractDBElement;
use App\Entity\Contracts\LogWithEventUndoInterface;
use App\Entity\Contracts\NamedElementInterface;
@ -52,6 +54,7 @@ class CollectionElementDeleted extends AbstractLogEntry implements LogWithEventU
/**
* Get the name of the collection (on target element) that was changed.
*
* @return string
*/
public function getCollectionName(): string
@ -62,6 +65,7 @@ class CollectionElementDeleted extends AbstractLogEntry implements LogWithEventU
/**
* Gets the name of the element that was deleted.
* Return null, if the element did not have a name.
*
* @return string|null
*/
public function getOldName(): ?string
@ -71,6 +75,7 @@ class CollectionElementDeleted extends AbstractLogEntry implements LogWithEventU
/**
* Returns the class of the deleted element.
*
* @return string
*/
public function getDeletedElementClass(): string
@ -80,6 +85,7 @@ class CollectionElementDeleted extends AbstractLogEntry implements LogWithEventU
/**
* Returns the ID of the deleted element.
*
* @return int
*/
public function getDeletedElementID(): int
@ -87,32 +93,23 @@ class CollectionElementDeleted extends AbstractLogEntry implements LogWithEventU
return $this->extra['i'];
}
/**
* @inheritDoc
*/
public function isUndoEvent(): bool
{
return isset($this->extra['u']);
}
/**
* @inheritDoc
*/
public function getUndoEventID(): ?int
{
return $this->extra['u'] ?? null;
}
/**
* @inheritDoc
*/
public function setUndoneEvent(AbstractLogEntry $event, string $mode = 'undo'): LogWithEventUndoInterface
{
$this->extra['u'] = $event->getID();
if ($mode === 'undo') {
if ('undo' === $mode) {
$this->extra['um'] = 1;
} elseif ($mode === 'revert') {
} elseif ('revert' === $mode) {
$this->extra['um'] = 2;
} else {
throw new \InvalidArgumentException('Passed invalid $mode!');
@ -121,16 +118,13 @@ class CollectionElementDeleted extends AbstractLogEntry implements LogWithEventU
return $this;
}
/**
* @inheritDoc
*/
public function getUndoMode(): string
{
$mode_int = $this->extra['um'] ?? 1;
if ($mode_int === 1) {
if (1 === $mode_int) {
return 'undo';
} else {
return 'revert';
}
return 'revert';
}
}
}

View file

@ -55,6 +55,7 @@ class ConfigChangedLogEntry extends AbstractLogEntry
public function __construct()
{
parent::__construct();
throw new LogEntryObsoleteException();
}
}

View file

@ -88,57 +88,40 @@ class ElementCreatedLogEntry extends AbstractLogEntry implements LogWithCommentI
return null !== $this->getCreationInstockValue();
}
/**
* @inheritDoc
*/
public function hasComment(): bool
{
return isset($this->extra['m']);
}
/**
* @inheritDoc
*/
public function getComment(): ?string
{
return $this->extra['m'] ?? null;
}
/**
* @inheritDoc
*/
public function setComment(?string $new_comment): LogWithCommentInterface
{
$this->extra['m'] = $new_comment;
return $this;
}
/**
* @inheritDoc
*/
public function isUndoEvent(): bool
{
return isset($this->extra['u']);
}
/**
* @inheritDoc
*/
public function getUndoEventID(): ?int
{
return $this->extra['u'] ?? null;
}
/**
* @inheritDoc
*/
public function setUndoneEvent(AbstractLogEntry $event, string $mode = 'undo'): LogWithEventUndoInterface
{
$this->extra['u'] = $event->getID();
if ($mode === 'undo') {
if ('undo' === $mode) {
$this->extra['um'] = 1;
} elseif ($mode === 'revert') {
} elseif ('revert' === $mode) {
$this->extra['um'] = 2;
} else {
throw new \InvalidArgumentException('Passed invalid $mode!');
@ -147,16 +130,13 @@ class ElementCreatedLogEntry extends AbstractLogEntry implements LogWithCommentI
return $this;
}
/**
* @inheritDoc
*/
public function getUndoMode(): string
{
$mode_int = $this->extra['um'] ?? 1;
if ($mode_int === 1) {
if (1 === $mode_int) {
return 'undo';
} else {
return 'revert';
}
return 'revert';
}
}

View file

@ -71,7 +71,6 @@ class ElementDeletedLogEntry extends AbstractLogEntry implements TimeTravelInter
}
/**
* @inheritDoc
* @return $this
*/
public function setTargetElement(?AbstractDBElement $element): AbstractLogEntry
@ -80,12 +79,14 @@ class ElementDeletedLogEntry extends AbstractLogEntry implements TimeTravelInter
if ($element instanceof NamedElementInterface) {
$this->setOldName($element->getName());
}
return $this;
}
public function setOldName(string $old_name): self
{
$this->extra['n'] = $old_name;
return $this;
}
@ -96,82 +97,60 @@ class ElementDeletedLogEntry extends AbstractLogEntry implements TimeTravelInter
/**
* Sets the old data for this entry.
* @param array $old_data
*
* @return $this
*/
public function setOldData(array $old_data): self
{
$this->extra['o'] = $old_data;
return $this;
}
/**
* @inheritDoc
*/
public function hasOldDataInformations(): bool
{
return !empty($this->extra['o']);
return ! empty($this->extra['o']);
}
/**
* @inheritDoc
*/
public function getOldData(): array
{
return $this->extra['o'] ?? [];
}
/**
* @inheritDoc
*/
public function hasComment(): bool
{
return isset($this->extra['m']);
}
/**
* @inheritDoc
*/
public function getComment(): ?string
{
return $this->extra['m'] ?? null;
}
/**
* @inheritDoc
*/
public function setComment(?string $new_comment): LogWithCommentInterface
{
$this->extra['m'] = $new_comment;
return $this;
}
/**
* @inheritDoc
*/
public function isUndoEvent(): bool
{
return isset($this->extra['u']);
}
/**
* @inheritDoc
*/
public function getUndoEventID(): ?int
{
return $this->extra['u'] ?? null;
}
/**
* @inheritDoc
*/
public function setUndoneEvent(AbstractLogEntry $event, string $mode = 'undo'): LogWithEventUndoInterface
{
$this->extra['u'] = $event->getID();
if ($mode === 'undo') {
if ('undo' === $mode) {
$this->extra['um'] = 1;
} elseif ($mode === 'revert') {
} elseif ('revert' === $mode) {
$this->extra['um'] = 2;
} else {
throw new \InvalidArgumentException('Passed invalid $mode!');
@ -180,15 +159,13 @@ class ElementDeletedLogEntry extends AbstractLogEntry implements TimeTravelInter
return $this;
}
/**
* @inheritDoc
*/
public function getUndoMode(): string
{
$mode_int = $this->extra['um'] ?? 1;
if ($mode_int === 1) {
if (1 === $mode_int) {
return 'undo';
}
return 'revert';
}
}

View file

@ -65,6 +65,7 @@ class ElementEditedLogEntry extends AbstractLogEntry implements TimeTravelInterf
/**
* Checks if this log contains infos about which fields has changed.
*
* @return bool
*/
public function hasChangedFieldsInfo(): bool
@ -74,6 +75,7 @@ class ElementEditedLogEntry extends AbstractLogEntry implements TimeTravelInterf
/**
* Return the names of all fields that were changed during the change.
*
* @return string[]
*/
public function getChangedFields(): array
@ -91,93 +93,74 @@ class ElementEditedLogEntry extends AbstractLogEntry implements TimeTravelInterf
/**
* Set the fields that were changed during this element change.
* @param string[] $changed_fields The names of the fields that were changed during the elements
*
* @param string[] $changed_fields The names of the fields that were changed during the elements
*
* @return $this
*/
public function setChangedFields(array $changed_fields): self
{
$this->extra['f'] = $changed_fields;
return $this;
}
/**
* Sets the old data for this entry.
* @param array $old_data
*
* @return $this
*/
public function setOldData(array $old_data): self
{
$this->extra['d'] = $old_data;
return $this;
}
/**
* @inheritDoc
*/
public function hasOldDataInformations(): bool
{
return !empty($this->extra['d']);
return ! empty($this->extra['d']);
}
/**
* @inheritDoc
*/
public function getOldData(): array
{
return $this->extra['d'] ?? [];
}
/**
* @inheritDoc
*/
public function hasComment(): bool
{
return isset($this->extra['m']);
}
/**
* @inheritDoc
*/
public function getComment(): ?string
{
return $this->extra['m'] ?? null;
}
/**
* @inheritDoc
*/
public function setComment(?string $new_comment): LogWithCommentInterface
{
$this->extra['m'] = $new_comment;
return $this;
}
/**
* @inheritDoc
*/
public function isUndoEvent(): bool
{
return isset($this->extra['u']);
}
/**
* @inheritDoc
*/
public function getUndoEventID(): ?int
{
return $this->extra['u'] ?? null;
}
/**
* @inheritDoc
*/
public function setUndoneEvent(AbstractLogEntry $event, string $mode = 'undo'): LogWithEventUndoInterface
{
$this->extra['u'] = $event->getID();
if ($mode === 'undo') {
if ('undo' === $mode) {
$this->extra['um'] = 1;
} elseif ($mode === 'revert') {
} elseif ('revert' === $mode) {
$this->extra['um'] = 2;
} else {
throw new \InvalidArgumentException('Passed invalid $mode!');
@ -186,16 +169,13 @@ class ElementEditedLogEntry extends AbstractLogEntry implements TimeTravelInterf
return $this;
}
/**
* @inheritDoc
*/
public function getUndoMode(): string
{
$mode_int = $this->extra['um'] ?? 1;
if ($mode_int === 1) {
if (1 === $mode_int) {
return 'undo';
} else {
return 'revert';
}
return 'revert';
}
}

View file

@ -55,6 +55,7 @@ class ExceptionLogEntry extends AbstractLogEntry
public function __construct()
{
parent::__construct();
throw new LogEntryObsoleteException();
}

View file

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
@ -22,7 +25,6 @@ namespace App\Entity\Parameters;
use App\Entity\Base\AbstractDBElement;
use App\Entity\Base\AbstractNamedDBElement;
use App\Repository\DBElementRepository;
use Doctrine\ORM\Mapping as ORM;
use InvalidArgumentException;
use LogicException;
@ -59,7 +61,7 @@ abstract class AbstractParameter extends AbstractNamedDBElement
* @Assert\Length(max=20)
* @ORM\Column(type="string", nullable=false)
*/
protected $symbol = "";
protected $symbol = '';
/**
* @var float|null The guaranteed minimum value of this property.
@ -90,22 +92,23 @@ abstract class AbstractParameter extends AbstractNamedDBElement
* @Assert\Length(max=5)
* @ORM\Column(type="string", nullable=false)
*/
protected $unit = "";
protected $unit = '';
/**
* @var string A text value for the given property.
* @ORM\Column(type="string", nullable=false)
*/
protected $value_text = "";
protected $value_text = '';
/**
* @var string The group this parameter belongs to.
* @ORM\Column(type="string", nullable=false, name="param_group")
*/
protected $group = "";
protected $group = '';
/**
* Mapping is done in sub classes
* Mapping is done in sub classes.
*
* @var AbstractDBElement|null The element to which this parameter belongs to.
*/
protected $element;
@ -119,6 +122,7 @@ abstract class AbstractParameter extends AbstractNamedDBElement
/**
* Returns the name of the specification (e.g. "Collector-Base Voltage").
*
* @return string
*/
public function getName(): string
@ -128,6 +132,7 @@ abstract class AbstractParameter extends AbstractNamedDBElement
/**
* Returns the element this parameter belongs to.
*
* @return AbstractDBElement|null
*/
public function getElement(): ?AbstractDBElement
@ -137,13 +142,14 @@ abstract class AbstractParameter extends AbstractNamedDBElement
/**
* Return a formatted string version of the values of the string.
* Based on the set values it can return something like this: 34 V (12 V ... 50 V) [Text]
* Based on the set values it can return something like this: 34 V (12 V ... 50 V) [Text].
*
* @return string
*/
public function getFormattedValue(): string
{
//If we just only have text value, return early
if ($this->value_typical === null && $this->value_min === null && $this->value_max === null) {
if (null === $this->value_typical && null === $this->value_min && null === $this->value_max) {
return $this->value_text;
}
@ -158,11 +164,11 @@ abstract class AbstractParameter extends AbstractNamedDBElement
}
if ($this->value_max && $this->value_min) {
$str .= $this->getValueMinWithUnit() . ' ... ' . $this->getValueMaxWithUnit();
$str .= $this->getValueMinWithUnit().' ... '.$this->getValueMaxWithUnit();
} elseif ($this->value_max) {
$str .= 'max. ' . $this->getValueMaxWithUnit();
$str .= 'max. '.$this->getValueMaxWithUnit();
} elseif ($this->value_min) {
$str .= 'min. ' . $this->getValueMinWithUnit();
$str .= 'min. '.$this->getValueMinWithUnit();
}
//Add closing bracket
@ -171,7 +177,7 @@ abstract class AbstractParameter extends AbstractNamedDBElement
}
if ($this->value_text) {
$str .= ' [' . $this->value_text . ']';
$str .= ' ['.$this->value_text.']';
}
return $str;
@ -179,7 +185,7 @@ abstract class AbstractParameter extends AbstractNamedDBElement
/**
* Sets the element to which this parameter belongs to.
* @param AbstractDBElement $element
*
* @return $this
*/
public function setElement(AbstractDBElement $element): self
@ -189,22 +195,25 @@ abstract class AbstractParameter extends AbstractNamedDBElement
}
$this->element = $element;
return $this;
}
/**
* Sets the name of the specification. This value is required.
* @param string $name
*
* @return $this
*/
public function setName(string $name): AbstractNamedDBElement
{
$this->name = $name;
return $this;
}
/**
* Returns the mathematical symbol for this specification (e.g. "V_CB")
* Returns the mathematical symbol for this specification (e.g. "V_CB").
*
* @return string
*/
public function getSymbol(): string
@ -213,18 +222,20 @@ abstract class AbstractParameter extends AbstractNamedDBElement
}
/**
* Sets the mathematical symbol for this specification (e.g. "V_CB")
* @param string $symbol
* Sets the mathematical symbol for this specification (e.g. "V_CB").
*
* @return $this
*/
public function setSymbol(string $symbol): self
{
$this->symbol = $symbol;
return $this;
}
/**
* Returns The guaranteed minimum value of this property.
*
* @return float|null
*/
public function getValueMin(): ?float
@ -234,17 +245,19 @@ abstract class AbstractParameter extends AbstractNamedDBElement
/**
* Sets the minimum value of this property.
* @param float|null $value_min
*
* @return $this
*/
public function setValueMin(?float $value_min): self
{
$this->value_min = $value_min;
return $this;
}
/**
* Returns the typical value of this property.
*
* @return float|null
*/
public function getValueTypical(): ?float
@ -253,22 +266,8 @@ abstract class AbstractParameter extends AbstractNamedDBElement
}
/**
* Return a string representation and (if possible) with its unit.
* @param float $value
* @param string $format
* @return string
*/
protected function formatWithUnit(float $value, string $format = "%g"): string
{
$str = \sprintf($format, $value);
if (!empty($this->unit)) {
return $str . ' ' . $this->unit;
}
return $str;
}
/**
* Return a formatted version with the minimum value with the unit of this parameter
* Return a formatted version with the minimum value with the unit of this parameter.
*
* @return string
*/
public function getValueTypicalWithUnit(): string
@ -277,7 +276,8 @@ abstract class AbstractParameter extends AbstractNamedDBElement
}
/**
* Return a formatted version with the maximum value with the unit of this parameter
* Return a formatted version with the maximum value with the unit of this parameter.
*
* @return string
*/
public function getValueMaxWithUnit(): string
@ -286,7 +286,8 @@ abstract class AbstractParameter extends AbstractNamedDBElement
}
/**
* Return a formatted version with the typical value with the unit of this parameter
* Return a formatted version with the typical value with the unit of this parameter.
*
* @return string
*/
public function getValueMinWithUnit(): string
@ -295,18 +296,22 @@ abstract class AbstractParameter extends AbstractNamedDBElement
}
/**
* Sets the typical value of this property
* @param float $value_typical
* Sets the typical value of this property.
*
* @param float $value_typical
*
* @return $this
*/
public function setValueTypical(?float $value_typical): self
{
$this->value_typical = $value_typical;
return $this;
}
/**
* Returns the guaranteed maximum value
* Returns the guaranteed maximum value.
*
* @return float|null
*/
public function getValueMax(): ?float
@ -315,18 +320,20 @@ abstract class AbstractParameter extends AbstractNamedDBElement
}
/**
* Sets the guaranteed maximum value
* @param float|null $value_max
* Sets the guaranteed maximum value.
*
* @return $this
*/
public function setValueMax(?float $value_max): self
{
$this->value_max = $value_max;
return $this;
}
/**
* Returns the unit used by the value (e.g. "V")
* Returns the unit used by the value (e.g. "V").
*
* @return string
*/
public function getUnit(): string
@ -336,17 +343,19 @@ abstract class AbstractParameter extends AbstractNamedDBElement
/**
* Sets the unit used by the value.
* @param string $unit
*
* @return $this
*/
public function setUnit(string $unit): self
{
$this->unit = $unit;
return $this;
}
/**
* Returns the text value.
*
* @return string
*/
public function getValueText(): string
@ -356,12 +365,13 @@ abstract class AbstractParameter extends AbstractNamedDBElement
/**
* Sets the text value.
* @param string $value_text
*
* @return $this
*/
public function setValueText(string $value_text): self
{
$this->value_text = $value_text;
return $this;
}
@ -369,4 +379,19 @@ abstract class AbstractParameter extends AbstractNamedDBElement
{
return 'PM'.sprintf('%09d', $this->getID());
}
}
/**
* Return a string representation and (if possible) with its unit.
*
* @return string
*/
protected function formatWithUnit(float $value, string $format = '%g'): string
{
$str = \sprintf($format, $value);
if (! empty($this->unit)) {
return $str.' '.$this->unit;
}
return $str;
}
}

View file

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
@ -20,13 +23,11 @@
namespace App\Entity\Parameters;
use App\Entity\Attachments\AttachmentType;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity()
* @package App\Entity\Parameters
*/
class AttachmentTypeParameter extends AbstractParameter
{
@ -37,4 +38,4 @@ class AttachmentTypeParameter extends AbstractParameter
* @ORM\JoinColumn(name="element_id", referencedColumnName="id", nullable=false, onDelete="CASCADE").
*/
protected $element;
}
}

View file

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
@ -20,13 +23,11 @@
namespace App\Entity\Parameters;
use App\Entity\Parts\Category;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity()
* @package App\Entity\Parameters
*/
class CategoryParameter extends AbstractParameter
{
@ -37,4 +38,4 @@ class CategoryParameter extends AbstractParameter
* @ORM\JoinColumn(name="element_id", referencedColumnName="id", nullable=false, onDelete="CASCADE").
*/
protected $element;
}
}

View file

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
@ -38,4 +41,4 @@ class CurrencyParameter extends AbstractParameter
* @ORM\JoinColumn(name="element_id", referencedColumnName="id", nullable=false, onDelete="CASCADE").
*/
protected $element;
}
}

View file

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
@ -20,13 +23,11 @@
namespace App\Entity\Parameters;
use App\Entity\Devices\Device;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity()
* @package App\Entity\Parameters
*/
class DeviceParameter extends AbstractParameter
{
@ -38,4 +39,4 @@ class DeviceParameter extends AbstractParameter
* @ORM\JoinColumn(name="element_id", referencedColumnName="id", nullable=false, onDelete="CASCADE").
*/
protected $element;
}
}

View file

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
@ -25,7 +28,6 @@ use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity()
* @package App\Entity\Parameters
*/
class FootprintParameter extends AbstractParameter
{
@ -37,4 +39,4 @@ class FootprintParameter extends AbstractParameter
* @ORM\JoinColumn(name="element_id", referencedColumnName="id", nullable=false, onDelete="CASCADE").
*/
protected $element;
}
}

View file

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
@ -25,7 +28,6 @@ use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity()
* @package App\Entity\Parameters
*/
class GroupParameter extends AbstractParameter
{
@ -37,4 +39,4 @@ class GroupParameter extends AbstractParameter
* @ORM\JoinColumn(name="element_id", referencedColumnName="id", nullable=false, onDelete="CASCADE").
*/
protected $element;
}
}

View file

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
@ -25,7 +28,6 @@ use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity()
* @package App\Entity\Parameters
*/
class ManufacturerParameter extends AbstractParameter
{
@ -37,4 +39,4 @@ class ManufacturerParameter extends AbstractParameter
* @ORM\JoinColumn(name="element_id", referencedColumnName="id", nullable=false, onDelete="CASCADE").
*/
protected $element;
}
}

View file

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
@ -25,7 +28,6 @@ use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity()
* @package App\Entity\Parameters
*/
class MeasurementUnitParameter extends AbstractParameter
{
@ -37,4 +39,4 @@ class MeasurementUnitParameter extends AbstractParameter
* @ORM\JoinColumn(name="element_id", referencedColumnName="id", nullable=false, onDelete="CASCADE").
*/
protected $element;
}
}

View file

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
@ -20,22 +23,22 @@
namespace App\Entity\Parameters;
use App\Entity\Parameters\AbstractParameter;
use Doctrine\Common\Collections\Collection;
use Symfony\Component\Validator\Constraints as Assert;
trait ParametersTrait
{
/**
* Mapping done in subclasses
* Mapping done in subclasses.
*
* @var AbstractParameter[]|Collection
* @Assert\Valid()
*/
protected $parameters;
/**
* Return all associated specifications
* Return all associated specifications.
*
* @return AbstractParameter[]|Collection
*/
public function getParameters(): Collection
@ -45,19 +48,21 @@ trait ParametersTrait
/**
* Add a new parameter information.
* @param AbstractParameter $parameter
*
* @return $this
*/
public function addParameter(AbstractParameter $parameter): self
{
$parameter->setElement($this);
$this->parameters->add($parameter);
return $this;
}
public function removeParameter(AbstractParameter $parameter): self
{
$this->parameters->removeElement($parameter);
return $this;
}
}
}

View file

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
@ -25,7 +28,6 @@ use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity()
* @package App\Entity\Parameters
*/
class PartParameter extends AbstractParameter
{
@ -37,4 +39,4 @@ class PartParameter extends AbstractParameter
* @ORM\JoinColumn(name="element_id", referencedColumnName="id", nullable=false, onDelete="CASCADE").
*/
protected $element;
}
}

View file

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
@ -25,7 +28,6 @@ use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity()
* @package App\Entity\Parameters
*/
class StorelocationParameter extends AbstractParameter
{
@ -37,4 +39,4 @@ class StorelocationParameter extends AbstractParameter
* @ORM\JoinColumn(name="element_id", referencedColumnName="id", nullable=false, onDelete="CASCADE").
*/
protected $element;
}
}

View file

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
@ -25,7 +28,6 @@ use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity()
* @package App\Entity\Parameters
*/
class SupplierParameter extends AbstractParameter
{
@ -37,4 +39,4 @@ class SupplierParameter extends AbstractParameter
* @ORM\JoinColumn(name="element_id", referencedColumnName="id", nullable=false, onDelete="CASCADE").
*/
protected $element;
}
}

View file

@ -25,7 +25,6 @@ namespace App\Entity\Parts;
use App\Entity\Attachments\CategoryAttachment;
use App\Entity\Base\AbstractPartsContainingDBElement;
use App\Entity\Parameters\CategoryParameter;
use App\Entity\Parameters\DeviceParameter;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
@ -131,7 +130,6 @@ class Category extends AbstractPartsContainingDBElement
}
/**
* @param string $partname_hint
* @return Category
*/
public function setPartnameHint(string $partname_hint): self
@ -147,7 +145,6 @@ class Category extends AbstractPartsContainingDBElement
}
/**
* @param string $partname_regex
* @return Category
*/
public function setPartnameRegex(string $partname_regex): self
@ -163,7 +160,6 @@ class Category extends AbstractPartsContainingDBElement
}
/**
* @param bool $disable_footprints
* @return Category
*/
public function setDisableFootprints(bool $disable_footprints): self
@ -179,7 +175,6 @@ class Category extends AbstractPartsContainingDBElement
}
/**
* @param bool $disable_manufacturers
* @return Category
*/
public function setDisableManufacturers(bool $disable_manufacturers): self
@ -195,7 +190,6 @@ class Category extends AbstractPartsContainingDBElement
}
/**
* @param bool $disable_autodatasheets
* @return Category
*/
public function setDisableAutodatasheets(bool $disable_autodatasheets): self
@ -211,7 +205,6 @@ class Category extends AbstractPartsContainingDBElement
}
/**
* @param bool $disable_properties
* @return Category
*/
public function setDisableProperties(bool $disable_properties): self
@ -227,7 +220,6 @@ class Category extends AbstractPartsContainingDBElement
}
/**
* @param string $default_description
* @return Category
*/
public function setDefaultDescription(string $default_description): self
@ -243,7 +235,6 @@ class Category extends AbstractPartsContainingDBElement
}
/**
* @param string $default_comment
* @return Category
*/
public function setDefaultComment(string $default_comment): self

View file

@ -52,7 +52,6 @@ namespace App\Entity\Parts;
use App\Entity\Attachments\FootprintAttachment;
use App\Entity\Base\AbstractPartsContainingDBElement;
use App\Entity\Parameters\DeviceParameter;
use App\Entity\Parameters\FootprintParameter;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;

View file

@ -52,7 +52,6 @@ namespace App\Entity\Parts;
use App\Entity\Attachments\ManufacturerAttachment;
use App\Entity\Base\AbstractCompany;
use App\Entity\Parameters\DeviceParameter;
use App\Entity\Parameters\ManufacturerParameter;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;

View file

@ -44,7 +44,6 @@ namespace App\Entity\Parts;
use App\Entity\Attachments\MeasurementUnitAttachment;
use App\Entity\Base\AbstractPartsContainingDBElement;
use App\Entity\Parameters\DeviceParameter;
use App\Entity\Parameters\MeasurementUnitParameter;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
@ -148,7 +147,6 @@ class MeasurementUnit extends AbstractPartsContainingDBElement
}
/**
* @param bool $isInteger
* @return MeasurementUnit
*/
public function setIsInteger(bool $isInteger): self
@ -164,7 +162,6 @@ class MeasurementUnit extends AbstractPartsContainingDBElement
}
/**
* @param bool $usesSIPrefixes
* @return MeasurementUnit
*/
public function setUseSIPrefix(bool $usesSIPrefixes): self

View file

@ -52,9 +52,8 @@ namespace App\Entity\Parts;
use App\Entity\Attachments\Attachment;
use App\Entity\Attachments\AttachmentContainingDBElement;
use App\Entity\Parameters\ParametersTrait;
use App\Entity\Devices\Device;
use App\Entity\Parameters\DeviceParameter;
use App\Entity\Parameters\ParametersTrait;
use App\Entity\Parameters\PartParameter;
use App\Entity\Parts\PartTraits\AdvancedPropertyTrait;
use App\Entity\Parts\PartTraits\BasicPropertyTrait;
@ -145,6 +144,26 @@ class Part extends AttachmentContainingDBElement
$this->parameters = new ArrayCollection();
}
public function __clone()
{
if ($this->id) {
//Deep clone part lots
$lots = $this->partLots;
$this->partLots = new ArrayCollection();
foreach ($lots as $lot) {
$this->addPartLot(clone $lot);
}
//Deep clone order details
$orderdetails = $this->orderdetails;
$this->orderdetails = new ArrayCollection();
foreach ($orderdetails as $orderdetail) {
$this->addOrderdetail(clone $orderdetail);
}
}
parent::__clone();
}
/**
* Returns the ID as an string, defined by the element class.
* This should have a form like P000014, for a part with ID 14.
@ -167,24 +186,4 @@ class Part extends AttachmentContainingDBElement
{
return $this->devices;
}
public function __clone()
{
if ($this->id) {
//Deep clone part lots
$lots = $this->partLots;
$this->partLots = new ArrayCollection();
foreach ($lots as $lot) {
$this->addPartLot(clone $lot);
}
//Deep clone order details
$orderdetails = $this->orderdetails;
$this->orderdetails = new ArrayCollection();
foreach ($orderdetails as $orderdetail) {
$this->addOrderdetail(clone $orderdetail);
}
}
parent::__clone();
}
}

View file

@ -119,6 +119,14 @@ class PartLot extends AbstractDBElement implements TimeStampableInterface
*/
protected $part;
public function __clone()
{
if ($this->id) {
$this->addedDate = null;
}
parent::__clone();
}
/**
* Returns the ID as an string, defined by the element class.
* This should have a form like P000014, for a part with ID 14.
@ -161,7 +169,6 @@ class PartLot extends AbstractDBElement implements TimeStampableInterface
/**
* Sets the description of the part lot.
*
* @param string $description
* @return PartLot
*/
public function setDescription(string $description): self
@ -184,7 +191,6 @@ class PartLot extends AbstractDBElement implements TimeStampableInterface
/**
* Sets the comment for this part lot.
*
* @param string $comment
* @return PartLot
*/
public function setComment(string $comment): self
@ -231,7 +237,6 @@ class PartLot extends AbstractDBElement implements TimeStampableInterface
/**
* Sets the storage location, where this part lot is stored.
*
* @param Storelocation|null $storage_location
* @return PartLot
*/
public function setStorageLocation(?Storelocation $storage_location): self
@ -254,8 +259,6 @@ class PartLot extends AbstractDBElement implements TimeStampableInterface
/**
* Sets the part that is stored in this part lot.
*
* @param Part $part
*
* @return PartLot
*/
public function setPart(Part $part): self
@ -278,7 +281,6 @@ class PartLot extends AbstractDBElement implements TimeStampableInterface
/**
* Set the unknown instock status of this part lot.
*
* @param bool $instock_unknown
* @return PartLot
*/
public function setInstockUnknown(bool $instock_unknown): self
@ -316,7 +318,6 @@ class PartLot extends AbstractDBElement implements TimeStampableInterface
}
/**
* @param bool $needs_refill
* @return PartLot
*/
public function setNeedsRefill(bool $needs_refill): self
@ -325,12 +326,4 @@ class PartLot extends AbstractDBElement implements TimeStampableInterface
return $this;
}
public function __clone()
{
if($this->id) {
$this->addedDate = null;
}
parent::__clone();
}
}

View file

@ -106,6 +106,7 @@ trait AdvancedPropertyTrait
* Sets a comma separated list of tags, that are assigned to this part.
*
* @param string $tags The new tags
*
* @return $this
*/
public function setTags(string $tags): self
@ -129,6 +130,7 @@ trait AdvancedPropertyTrait
* Sett to null, if the mass is unknown.
*
* @param float|null $mass the new mass
*
* @return $this
*/
public function setMass(?float $mass): self

View file

@ -164,6 +164,7 @@ trait BasicPropertyTrait
* Sets the description of this part.
*
* @param string $new_description the new description
*
* @return $this
*/
public function setDescription(?string $new_description): self
@ -177,6 +178,7 @@ trait BasicPropertyTrait
* Sets the comment property of this part.
*
* @param string $new_comment the new comment
*
* @return $this
*/
public function setComment(string $new_comment): self
@ -191,6 +193,7 @@ trait BasicPropertyTrait
* The category property is required for every part, so you can not pass null like the other properties (footprints).
*
* @param Category $category The new category of this part
*
* @return $this
*/
public function setCategory(Category $category): self
@ -205,6 +208,7 @@ trait BasicPropertyTrait
*
* @param Footprint|null $new_footprint The new footprint of this part. Set to null, if this part should not have
* a footprint.
*
* @return $this
*/
public function setFootprint(?Footprint $new_footprint): self
@ -219,6 +223,7 @@ trait BasicPropertyTrait
*
* @param bool $new_favorite_status The new favorite status, that should be applied on this part.
* Set this to true, when the part should be a favorite.
*
* @return $this
*/
public function setFavorite(bool $new_favorite_status): self

View file

@ -90,7 +90,7 @@ trait InstockTrait
/**
* Adds the given part lot, to the list of part lots.
* The part lot is assigned to this part.
* @param PartLot $lot
*
* @return $this
*/
public function addPartLot(PartLot $lot): self
@ -105,6 +105,7 @@ trait InstockTrait
* Removes the given part lot from the list of part lots.
*
* @param PartLot $lot the part lot that should be deleted
*
* @return $this
*/
public function removePartLot(PartLot $lot): self
@ -126,7 +127,7 @@ trait InstockTrait
/**
* Sets the measurement unit in which the part's amount should be measured.
* Set to null, if the part should be measured in quantities.
* @param MeasurementUnit|null $partUnit
*
* @return $this
*/
public function setPartUnit(?MeasurementUnit $partUnit): self
@ -172,7 +173,6 @@ trait InstockTrait
* Part Lots that have unknown value or are expired, are not used for this value.
*
* @return float The amount of parts given in partUnit
*
*/
public function getAmountSum(): float
{
@ -199,6 +199,7 @@ trait InstockTrait
* See getPartUnit() for the associated unit.
*
* @param float $new_minamount the new count of parts which should be in stock at least
*
* @return $this
*/
public function setMinAmount(float $new_minamount): self

View file

@ -136,7 +136,6 @@ trait ManufacturerTrait
* Sets the manufacturing status for this part
* See getManufacturingStatus() for valid values.
*
* @param string $manufacturing_status
* @return Part
*/
public function setManufacturingStatus(string $manufacturing_status): self
@ -167,7 +166,6 @@ trait ManufacturerTrait
/**
* Sets the manufacturer product number (MPN) for this part.
*
* @param string $manufacturer_product_number
* @return Part
*/
public function setManufacturerProductNumber(string $manufacturer_product_number): self
@ -182,6 +180,7 @@ trait ManufacturerTrait
* Set to "" if this part should use the automatically URL based on its manufacturer.
*
* @param string $new_url The new url
*
* @return $this
*/
public function setManufacturerProductURL(string $new_url): self
@ -196,6 +195,7 @@ trait ManufacturerTrait
*
* @param Manufacturer|null $new_manufacturer The new Manufacturer of this part. Set to null, if this part should
* not have a manufacturer.
*
* @return $this
*/
public function setManufacturer(?Manufacturer $new_manufacturer): self

View file

@ -144,6 +144,7 @@ trait OrderTrait
* The orderdetail is assigned to this part.
*
* @param Orderdetail $orderdetail the orderdetail that should be added
*
* @return $this
*/
public function addOrderdetail(Orderdetail $orderdetail): self
@ -156,7 +157,7 @@ trait OrderTrait
/**
* Removes the given orderdetail from the list of orderdetails.
* @param Orderdetail $orderdetail
*
* @return $this
*/
public function removeOrderdetail(Orderdetail $orderdetail): self
@ -177,6 +178,7 @@ trait OrderTrait
* (if the part has exactly one orderdetails,
* set this orderdetails as order orderdetails.
* Otherwise, set "no order orderdetails")
*
* @return $this
*/
public function setManualOrder(bool $new_manual_order, int $new_order_quantity = 1, ?Orderdetail $new_order_orderdetail = null): self

View file

@ -52,7 +52,6 @@ namespace App\Entity\Parts;
use App\Entity\Attachments\StorelocationAttachment;
use App\Entity\Base\AbstractPartsContainingDBElement;
use App\Entity\Parameters\DeviceParameter;
use App\Entity\Parameters\StorelocationParameter;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
@ -153,7 +152,6 @@ class Storelocation extends AbstractPartsContainingDBElement
}
/**
* @param bool $only_single_part
* @return Storelocation
*/
public function setOnlySinglePart(bool $only_single_part): self
@ -174,7 +172,6 @@ class Storelocation extends AbstractPartsContainingDBElement
}
/**
* @param bool $limit_to_existing_parts
* @return Storelocation
*/
public function setLimitToExistingParts(bool $limit_to_existing_parts): self
@ -193,7 +190,6 @@ class Storelocation extends AbstractPartsContainingDBElement
}
/**
* @param MeasurementUnit|null $storage_type
* @return Storelocation
*/
public function setStorageType(?MeasurementUnit $storage_type): self

View file

@ -52,7 +52,6 @@ namespace App\Entity\Parts;
use App\Entity\Attachments\SupplierAttachment;
use App\Entity\Base\AbstractCompany;
use App\Entity\Parameters\DeviceParameter;
use App\Entity\Parameters\SupplierParameter;
use App\Entity\PriceInformations\Currency;
use App\Validator\Constraints\Selectable;
@ -134,7 +133,6 @@ class Supplier extends AbstractCompany
/**
* Sets the default currency.
*
* @param Currency|null $default_currency
* @return Supplier
*/
public function setDefaultCurrency(?Currency $default_currency): self

View file

@ -45,7 +45,6 @@ namespace App\Entity\PriceInformations;
use App\Entity\Attachments\CurrencyAttachment;
use App\Entity\Base\AbstractStructuralDBElement;
use App\Entity\Parameters\CurrencyParameter;
use App\Entity\Parameters\SupplierParameter;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;

View file

@ -117,6 +117,20 @@ class Orderdetail extends AbstractDBElement implements TimeStampableInterface
$this->pricedetails = new ArrayCollection();
}
public function __clone()
{
if ($this->id) {
$this->addedDate = null;
$pricedetails = $this->pricedetails;
$this->pricedetails = new ArrayCollection();
//Set master attachment is needed
foreach ($pricedetails as $pricedetail) {
$this->addPricedetail(clone $pricedetail);
}
}
parent::__clone();
}
/**
* Returns the ID as an string, defined by the element class.
* This should have a form like P000014, for a part with ID 14.
@ -228,7 +242,6 @@ class Orderdetail extends AbstractDBElement implements TimeStampableInterface
/**
* Removes an pricedetail from this orderdetail.
*
* @param Pricedetail $pricedetail
* @return Orderdetail
*/
public function removePricedetail(Pricedetail $pricedetail): self
@ -276,7 +289,6 @@ class Orderdetail extends AbstractDBElement implements TimeStampableInterface
/**
* Sets a new part with which this orderdetail is associated.
*
* @param Part $part
* @return Orderdetail
*/
public function setPart(Part $part): self
@ -289,7 +301,6 @@ class Orderdetail extends AbstractDBElement implements TimeStampableInterface
/**
* Sets the new supplier associated with this orderdetail.
*
* @param Supplier $new_supplier
* @return Orderdetail
*/
public function setSupplier(Supplier $new_supplier): self
@ -348,18 +359,4 @@ class Orderdetail extends AbstractDBElement implements TimeStampableInterface
return $this;
}
public function __clone()
{
if ($this->id) {
$this->addedDate = null;
$pricedetails = $this->pricedetails;
$this->pricedetails = new ArrayCollection();
//Set master attachment is needed
foreach ($pricedetails as $pricedetail) {
$this->addPricedetail(clone $pricedetail);
}
}
parent::__clone();
}
}

View file

@ -121,6 +121,14 @@ class Pricedetail extends AbstractDBElement implements TimeStampableInterface
bcscale(static::PRICE_PRECISION);
}
public function __clone()
{
if ($this->id) {
$this->addedDate = null;
}
parent::__clone();
}
/********************************************************************************
*
* Getters
@ -230,7 +238,6 @@ class Pricedetail extends AbstractDBElement implements TimeStampableInterface
/**
* Sets the orderdetail to which this pricedetail belongs to.
*
* @param Orderdetail $orderdetail
* @return $this
*/
public function setOrderdetail(Orderdetail $orderdetail): self
@ -244,7 +251,6 @@ class Pricedetail extends AbstractDBElement implements TimeStampableInterface
* Sets the currency associated with the price informations.
* Set to null, to use the global base currency.
*
* @param Currency|null $currency
* @return Pricedetail
*/
public function setCurrency(?Currency $currency): self
@ -262,6 +268,7 @@ class Pricedetail extends AbstractDBElement implements TimeStampableInterface
* * This is the price for "price_related_quantity" parts!!
* * Example: if "price_related_quantity" is '10',
* you have to set here the price for 10 parts!
*
* @return $this
*/
public function setPrice(string $new_price): self
@ -309,6 +316,7 @@ class Pricedetail extends AbstractDBElement implements TimeStampableInterface
* So the orderdetails would have three Pricedetails for one supplier.)
*
* @param float $new_min_discount_quantity the minimum discount quantity
*
* @return $this
*/
public function setMinDiscountQuantity(float $new_min_discount_quantity): self
@ -328,12 +336,4 @@ class Pricedetail extends AbstractDBElement implements TimeStampableInterface
{
return 'PD'.sprintf('%06d', $this->getID());
}
public function __clone()
{
if ($this->id) {
$this->addedDate = null;
}
parent::__clone();
}
}

View file

@ -45,7 +45,6 @@ namespace App\Entity\UserSystem;
use App\Entity\Attachments\GroupAttachment;
use App\Entity\Base\AbstractStructuralDBElement;
use App\Entity\Parameters\GroupParameter;
use App\Entity\Parameters\SupplierParameter;
use App\Security\Interfaces\HasPermissionsInterface;
use App\Validator\Constraints\ValidPermission;
use Doctrine\Common\Collections\Collection;

View file

@ -123,6 +123,7 @@ class U2FKey implements TwoFactorKeyInterface
public function setKeyHandle($keyHandle): self
{
$this->keyHandle = $keyHandle;
return $this;
}
@ -134,6 +135,7 @@ class U2FKey implements TwoFactorKeyInterface
public function setPublicKey($publicKey): self
{
$this->publicKey = $publicKey;
return $this;
}
@ -145,6 +147,7 @@ class U2FKey implements TwoFactorKeyInterface
public function setCertificate($certificate): self
{
$this->certificate = $certificate;
return $this;
}
@ -156,6 +159,7 @@ class U2FKey implements TwoFactorKeyInterface
public function setCounter($counter): self
{
$this->counter = $counter;
return $this;
}
@ -167,6 +171,7 @@ class U2FKey implements TwoFactorKeyInterface
public function setName($name): self
{
$this->name = $name;
return $this;
}
@ -193,7 +198,6 @@ class U2FKey implements TwoFactorKeyInterface
/**
* Sets the user this U2F key belongs to.
*
* @param User $new_user
* @return $this
*/
public function setUser(User $new_user): self

View file

@ -52,8 +52,8 @@ namespace App\Entity\UserSystem;
use App\Entity\Attachments\AttachmentContainingDBElement;
use App\Entity\Attachments\UserAttachment;
use App\Entity\Base\MasterAttachmentTrait;
use App\Entity\Base\AbstractNamedDBElement;
use App\Entity\Base\MasterAttachmentTrait;
use App\Entity\PriceInformations\Currency;
use App\Security\Interfaces\HasPermissionsInterface;
use App\Validator\Constraints\Selectable;
@ -338,7 +338,6 @@ class User extends AttachmentContainingDBElement implements UserInterface, HasPe
/**
* Sets the password hash for this user.
*
* @param string $password
* @return User
*/
public function setPassword(string $password): self
@ -378,7 +377,6 @@ class User extends AttachmentContainingDBElement implements UserInterface, HasPe
/**
* Sets the currency the users prefers to see prices in.
*
* @param Currency|null $currency
* @return User
*/
public function setCurrency(?Currency $currency): self
@ -441,7 +439,6 @@ class User extends AttachmentContainingDBElement implements UserInterface, HasPe
/**
* Set the status, if the user needs a password change.
*
* @param bool $need_pw_change
* @return User
*/
public function setNeedPwChange(bool $need_pw_change): self
@ -464,7 +461,6 @@ class User extends AttachmentContainingDBElement implements UserInterface, HasPe
/**
* Sets the encrypted password reset token.
*
* @param string|null $pw_reset_token
* @return User
*/
public function setPwResetToken(?string $pw_reset_token): self
@ -487,7 +483,6 @@ class User extends AttachmentContainingDBElement implements UserInterface, HasPe
/**
* Sets the datetime when the password reset token expires.
*
* @param DateTime $pw_reset_expires
* @return User
*/
public function setPwResetExpires(DateTime $pw_reset_expires): self
@ -671,7 +666,6 @@ class User extends AttachmentContainingDBElement implements UserInterface, HasPe
/**
* Change the timezone of this user.
*
* @param string|null $timezone
* @return $this
*/
public function setTimezone(?string $timezone): self
@ -764,7 +758,6 @@ class User extends AttachmentContainingDBElement implements UserInterface, HasPe
/**
* Sets the secret used for Google Authenticator. Set to null to disable Google Authenticator.
*
* @param string|null $googleAuthenticatorSecret
* @return $this
*/
public function setGoogleAuthenticatorSecret(?string $googleAuthenticatorSecret): self
@ -881,7 +874,6 @@ class User extends AttachmentContainingDBElement implements UserInterface, HasPe
/**
* Add a U2F key to this user.
* @param TwoFactorKeyInterface $key
*/
public function addU2FKey(TwoFactorKeyInterface $key): void
{
@ -890,7 +882,6 @@ class User extends AttachmentContainingDBElement implements UserInterface, HasPe
/**
* Remove a U2F key from this user.
* @param TwoFactorKeyInterface $key
*/
public function removeU2FKey(TwoFactorKeyInterface $key): void
{