Removed unnecessary getIDString() function in AbstractDBElement.

This commit is contained in:
Jan Böhmer 2020-05-13 21:19:23 +02:00
parent a3af55d4e2
commit 8b6fe757a0
26 changed files with 3 additions and 219 deletions

View file

@ -154,7 +154,7 @@ class ConvertBBCodeCommand extends Command
foreach ($results as $result) {
/** @var AbstractNamedDBElement $result */
$io->writeln(
'Convert entity: '.$result->getName().' ('.$result->getIDString().')',
'Convert entity: '.$result->getName().' (' . get_class($result) . ': ' . $result->getID() . ')',
OutputInterface::VERBOSITY_VERBOSE
);
foreach ($properties as $property) {

View file

@ -337,16 +337,6 @@ abstract class Attachment extends AbstractNamedDBElement
return $this->attachment_type;
}
/**
* Returns the ID as an string, defined by the element class.
* This should have a form like P000014, for a part with ID 14.
*
* @return string The ID as a string;
*/
public function getIDString(): string
{
return 'A'.sprintf('%09d', $this->getID());
}
/*****************************************************************************************************
* Setters

View file

@ -118,14 +118,4 @@ class AttachmentType extends AbstractStructuralDBElement
return $this;
}
/**
* Returns the ID as an string, defined by the element class.
* This should have a form like P000014, for a part with ID 14.
*
* @return string The ID as a string;
*/
public function getIDString(): string
{
return 'AT'.sprintf('%09d', $this->getID());
}
}

View file

@ -87,14 +87,6 @@ abstract class AbstractDBElement implements \JsonSerializable
return $this->id;
}
/**
* Returns the ID as an string, defined by the element class.
* This should have a form like P000014, for a part with ID 14.
*
* @return string The ID as a string;
*/
abstract public function getIDString(): string;
public function jsonSerialize()
{
return ['@id' => $this->getID()];

View file

@ -168,15 +168,4 @@ class Device extends AbstractPartsContainingDBElement
return $this;
}
/**
* Returns the ID as an string, defined by the element class.
* This should have a form like P000014, for a part with ID 14.
*
* @return string The ID as a string;
*/
public function getIDString(): string
{
return 'D'.sprintf('%09d', $this->getID());
}
}

View file

@ -86,15 +86,4 @@ class DevicePart extends AbstractDBElement
* @ORM\JoinColumn(name="id_part", referencedColumnName="id")
*/
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.
*
* @return string The ID as a string;
*/
public function getIDString(): string
{
return 'DP'.sprintf('%06d', $this->getID());
}
}

View file

@ -120,9 +120,4 @@ class LabelProfile extends AttachmentContainingDBElement
return $this;
}
public function getIDString(): string
{
return 'LP'.sprintf('%09d', $this->getID());
}
}

View file

@ -306,11 +306,6 @@ abstract class AbstractLogEntry extends AbstractDBElement
return $this->typeString;
}
public function getIDString(): string
{
return 'LOG'.$this->getID();
}
/**
* Returns the class name of the target element associated with this log entry.
* Returns null, if this log entry is not associated with an log entry.

View file

@ -387,11 +387,6 @@ abstract class AbstractParameter extends AbstractNamedDBElement
return $this;
}
public function getIDString(): string
{
return 'PM'.sprintf('%09d', $this->getID());
}
/**
* Return a string representation and (if possible) with its unit.
*

View file

@ -116,16 +116,6 @@ class Category extends AbstractPartsContainingDBElement
*/
protected $parameters;
/**
* Returns the ID as an string, defined by the element class.
* This should have a form like P000014, for a part with ID 14.
*
* @return string The ID as a string;
*/
public function getIDString(): string
{
return 'C'.sprintf('%09d', $this->getID());
}
public function getPartnameHint(): string
{

View file

@ -103,16 +103,6 @@ class Footprint extends AbstractPartsContainingDBElement
*/
protected $parameters;
/**
* Returns the ID as an string, defined by the element class.
* This should have a form like P000014, for a part with ID 14.
*
* @return string The ID as a string;
*/
public function getIDString(): string
{
return 'F'.sprintf('%06d', $this->getID());
}
/****************************************
* Getters

View file

@ -95,15 +95,4 @@ class Manufacturer extends AbstractCompany
* @Assert\Valid()
*/
protected $parameters;
/**
* Returns the ID as an string, defined by the element class.
* This should have a form like P000014, for a part with ID 14.
*
* @return string The ID as a string;
*/
public function getIDString(): string
{
return 'M'.sprintf('%06d', $this->getID());
}
}

View file

@ -113,16 +113,6 @@ class MeasurementUnit extends AbstractPartsContainingDBElement
*/
protected $parameters;
/**
* Returns the ID as an string, defined by the element class.
* This should have a form like P000014, for a part with ID 14.
*
* @return string The ID as a string;
*/
public function getIDString(): string
{
return 'MU'.$this->getID();
}
/**
* @return string

View file

@ -176,16 +176,6 @@ class Part extends AttachmentContainingDBElement
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.
*
* @return string The ID as a string;
*/
public function getIDString(): string
{
return 'P'.sprintf('%06d', $this->getID());
}
/**
* Get all devices which uses this part.

View file

@ -128,16 +128,6 @@ class PartLot extends AbstractDBElement implements TimeStampableInterface, Named
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.
*
* @return string The ID as a string;
*/
public function getIDString(): string
{
return 'PL'.$this->getID();
}
/**
* Check if the current part lot is expired.

View file

@ -224,15 +224,4 @@ class Storelocation extends AbstractPartsContainingDBElement
return $this;
}
/**
* Returns the ID as an string, defined by the element class.
* This should have a form like P000014, for a part with ID 14.
*
* @return string The ID as a string;
*/
public function getIDString(): string
{
return 'L'.sprintf('%06d', $this->getID());
}
}

View file

@ -172,15 +172,4 @@ class Supplier extends AbstractCompany
return $this;
}
/**
* Returns the ID as an string, defined by the element class.
* This should have a form like P000014, for a part with ID 14.
*
* @return string The ID as a string;
*/
public function getIDString(): string
{
return 'L'.sprintf('%06d', $this->getID());
}
}

View file

@ -162,15 +162,4 @@ class Currency extends AbstractStructuralDBElement
return $this;
}
/**
* Returns the ID as an string, defined by the element class.
* This should have a form like P000014, for a part with ID 14.
*
* @return string The ID as a string;
*/
public function getIDString(): string
{
return 'C'.$this->getID();
}
}

View file

@ -134,17 +134,6 @@ class Orderdetail extends AbstractDBElement implements TimeStampableInterface, N
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.
*
* @return string The ID as a string;
*/
public function getIDString(): string
{
return 'O'.sprintf('%06d', $this->getID());
}
/********************************************************************************
*
* Getters

View file

@ -330,15 +330,4 @@ class Pricedetail extends AbstractDBElement implements TimeStampableInterface
return $this;
}
/**
* Returns the ID as an string, defined by the element class.
* This should have a form like P000014, for a part with ID 14.
*
* @return string The ID as a string;
*/
public function getIDString(): string
{
return 'PD'.sprintf('%06d', $this->getID());
}
}

View file

@ -132,17 +132,6 @@ class Group extends AbstractStructuralDBElement implements HasPermissionsInterfa
return $this;
}
/**
* Returns the ID as an string, defined by the element class.
* This should have a form like P000014, for a part with ID 14.
*
* @return string The ID as a string;
*/
public function getIDString(): string
{
return 'G'.sprintf('%06d', $this->getID());
}
public function getPermissions(): PermissionsEmbed
{
return $this->permissions;

View file

@ -410,16 +410,6 @@ class User extends AttachmentContainingDBElement implements UserInterface, HasPe
return $this;
}
/**
* Returns the ID as an string, defined by the element class.
* This should have a form like P000014, for a part with ID 14.
*
* @return string The ID as a string;
*/
public function getIDString(): string
{
return 'U'.sprintf('%06d', $this->getID());
}
public function getPermissions(): PermissionsEmbed
{

View file

@ -34,7 +34,7 @@
<tr> {# ID #}
<td>{% trans %}id.label{% endtrans %}</td>
<td>{{ part.iD }} ({{ part.iDString}})</td>
<td>{{ part.iD }}</td>
</tr>
<tr> {# Favorite status #}

View file

@ -83,10 +83,6 @@ class ElementTypeNameGeneratorTest extends WebTestCase
//Test exception for unknpwn type
$this->expectException(EntityNotSupportedException::class);
$this->service->getLocalizedTypeLabel(new class() extends AbstractDBElement {
public function getIDString(): string
{
return 'Stub';
}
});
}

View file

@ -65,12 +65,7 @@ class LabelGeneratorTest extends WebTestCase
$this->assertTrue($this->service->supports($options, new $class()));
//Ensure that another class is not supported
$not_supported = new class() extends AbstractDBElement {
public function getIDString(): string
{
return 'not_important';
}
};
$not_supported = new class() extends AbstractDBElement {};
$this->assertFalse($this->service->supports($options, $not_supported));
}

View file

@ -42,11 +42,6 @@ class AbstractElementProviderTest extends WebTestCase
$this->service = self::$container->get(AbstractDBElementProvider::class);
$this->target = new class() extends AbstractDBElement {
protected $id = 123;
public function getIDString(): string
{
return 'ignore';
}
};
}