From 594c694ee0721236d1227f4a74664b4355d5d55a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20B=C3=B6hmer?= Date: Sat, 1 Feb 2020 19:48:07 +0100 Subject: [PATCH] Renamed the base DBElement classes to AbstractDBElement to comply with symfony recommendations. --- src/Command/ConvertBBCodeCommand.php | 4 ++-- src/Command/ShowEventLogCommand.php | 4 ++-- .../AdminPages/BaseAdminController.php | 16 +++++++-------- src/DataFixtures/DataStructureFixtures.php | 10 +++++----- src/DataTables/Column/EntityColumn.php | 8 ++++---- .../Column/LogEntryTargetColumn.php | 8 ++++---- src/Entity/Attachments/Attachment.php | 4 ++-- .../AttachmentContainingDBElement.php | 4 ++-- src/Entity/Attachments/AttachmentType.php | 4 ++-- .../Base/{Company.php => AbstractCompany.php} | 2 +- .../{DBElement.php => AbstractDBElement.php} | 2 +- ...Element.php => AbstractNamedDBElement.php} | 2 +- ...p => AbstractPartsContainingDBElement.php} | 2 +- ...nt.php => AbstractStructuralDBElement.php} | 18 ++++++++--------- src/Entity/Devices/Device.php | 4 ++-- src/Entity/Devices/DevicePart.php | 4 ++-- src/Entity/LogSystem/AbstractLogEntry.php | 8 ++++---- src/Entity/Parts/Category.php | 4 ++-- src/Entity/Parts/Footprint.php | 4 ++-- src/Entity/Parts/Manufacturer.php | 4 ++-- src/Entity/Parts/MeasurementUnit.php | 4 ++-- src/Entity/Parts/PartLot.php | 4 ++-- src/Entity/Parts/Storelocation.php | 4 ++-- src/Entity/Parts/Supplier.php | 4 ++-- src/Entity/PriceInformations/Currency.php | 4 ++-- src/Entity/PriceInformations/Orderdetail.php | 4 ++-- src/Entity/PriceInformations/Pricedetail.php | 4 ++-- src/Entity/UserSystem/Group.php | 4 ++-- src/Entity/UserSystem/User.php | 4 ++-- .../TreeCacheInvalidationListener.php | 8 ++++---- .../AdminPages/AttachmentTypeAdminForm.php | 4 ++-- src/Form/AdminPages/BaseEntityAdminForm.php | 8 ++++---- src/Form/AdminPages/CategoryAdminForm.php | 4 ++-- src/Form/AdminPages/CompanyForm.php | 4 ++-- src/Form/AdminPages/CurrencyAdminForm.php | 4 ++-- src/Form/AdminPages/FootprintAdminForm.php | 4 ++-- src/Form/AdminPages/GroupAdminForm.php | 4 ++-- src/Form/AdminPages/ImportType.php | 4 ++-- src/Form/AdminPages/MassCreationForm.php | 4 ++-- .../AdminPages/MeasurementUnitAdminForm.php | 4 ++-- .../AdminPages/StorelocationAdminForm.php | 4 ++-- src/Form/AdminPages/SupplierForm.php | 4 ++-- src/Form/Type/CurrencyEntityType.php | 8 ++++---- src/Form/Type/StructuralEntityType.php | 10 +++++----- src/Form/UserAdminForm.php | 8 ++++---- .../Trees/StructuralDBElementIterator.php | 6 +++--- src/Repository/LogEntryRepository.php | 12 +++++------ src/Repository/NamedDBElementRepository.php | 4 ++-- .../StructuralDBElementRepository.php | 16 +++++++-------- src/Security/Annotations/ColumnSecurity.php | 4 ++-- .../ElementPermissionListener.php | 12 +++++------ src/Services/ElementTypeNameGenerator.php | 10 +++++----- src/Services/EntityExporter.php | 4 ++-- src/Services/EntityImporter.php | 20 +++++++++---------- src/Services/EntityURLGenerator.php | 16 +++++++-------- .../StructuralElementRecursionHelper.php | 12 +++++------ src/Services/Trees/NodesListBuilder.php | 8 ++++---- src/Services/Trees/TreeViewGenerator.php | 18 ++++++++--------- src/Twig/AppExtension.php | 6 +++--- .../NoneOfItsChildrenValidator.php | 8 ++++---- .../Constraints/SelectableValidator.php | 4 ++-- .../Services/ElementTypeNameGeneratorTest.php | 8 ++++---- 62 files changed, 203 insertions(+), 203 deletions(-) rename src/Entity/Base/{Company.php => AbstractCompany.php} (98%) rename src/Entity/Base/{DBElement.php => AbstractDBElement.php} (99%) rename src/Entity/Base/{NamedDBElement.php => AbstractNamedDBElement.php} (97%) rename src/Entity/Base/{PartsContainingDBElement.php => AbstractPartsContainingDBElement.php} (94%) rename src/Entity/Base/{StructuralDBElement.php => AbstractStructuralDBElement.php} (94%) diff --git a/src/Command/ConvertBBCodeCommand.php b/src/Command/ConvertBBCodeCommand.php index 4bc20246..a9d02592 100644 --- a/src/Command/ConvertBBCodeCommand.php +++ b/src/Command/ConvertBBCodeCommand.php @@ -25,7 +25,7 @@ declare(strict_types=1); namespace App\Command; use App\Entity\Attachments\AttachmentType; -use App\Entity\Base\NamedDBElement; +use App\Entity\Base\AbstractNamedDBElement; use App\Entity\Devices\Device; use App\Entity\Parts\Category; use App\Entity\Parts\Manufacturer; @@ -134,7 +134,7 @@ class ConvertBBCodeCommand extends Command //In verbose mode print the names of the entities foreach ($results as $result) { - /** @var NamedDBElement $result */ + /** @var AbstractNamedDBElement $result */ $io->writeln( 'Convert entity: '.$result->getName().' ('.$result->getIDString().')', OutputInterface::VERBOSITY_VERBOSE diff --git a/src/Command/ShowEventLogCommand.php b/src/Command/ShowEventLogCommand.php index 9f368a42..4bd27c65 100644 --- a/src/Command/ShowEventLogCommand.php +++ b/src/Command/ShowEventLogCommand.php @@ -24,7 +24,7 @@ declare(strict_types=1); namespace App\Command; -use App\Entity\Base\NamedDBElement; +use App\Entity\Base\AbstractNamedDBElement; use App\Entity\LogSystem\AbstractLogEntry; use App\Services\ElementTypeNameGenerator; use App\Services\LogSystem\LogEntryExtraFormatter; @@ -133,7 +133,7 @@ class ShowEventLogCommand extends Command { $target = $this->repo->getTargetElement($entry); $target_name = ''; - if ($target instanceof NamedDBElement) { + if ($target instanceof AbstractNamedDBElement) { $target_name = $target->getName().' ('.$target->getID().')'; } elseif ($entry->getTargetID()) { $target_name = '('.$entry->getTargetID().')'; diff --git a/src/Controller/AdminPages/BaseAdminController.php b/src/Controller/AdminPages/BaseAdminController.php index 3a76c15d..f3d7e475 100644 --- a/src/Controller/AdminPages/BaseAdminController.php +++ b/src/Controller/AdminPages/BaseAdminController.php @@ -24,8 +24,8 @@ declare(strict_types=1); namespace App\Controller\AdminPages; -use App\Entity\Base\NamedDBElement; -use App\Entity\Base\StructuralDBElement; +use App\Entity\Base\AbstractNamedDBElement; +use App\Entity\Base\AbstractStructuralDBElement; use App\Entity\UserSystem\User; use App\Exceptions\AttachmentDownloadException; use App\Form\AdminPages\ImportType; @@ -75,7 +75,7 @@ abstract class BaseAdminController extends AbstractController $this->attachmentSubmitHandler = $attachmentSubmitHandler; } - protected function _edit(NamedDBElement $entity, Request $request, EntityManagerInterface $em) + protected function _edit(AbstractNamedDBElement $entity, Request $request, EntityManagerInterface $em) { $this->denyAccessUnlessGranted('read', $entity); @@ -130,7 +130,7 @@ abstract class BaseAdminController extends AbstractController protected function _new(Request $request, EntityManagerInterface $em, EntityImporter $importer) { - /** @var StructuralDBElement|User $new_entity */ + /** @var AbstractStructuralDBElement|User $new_entity */ $new_entity = new $this->entity_class(); $this->denyAccessUnlessGranted('read', $new_entity); @@ -234,7 +234,7 @@ abstract class BaseAdminController extends AbstractController ]); } - protected function _delete(Request $request, NamedDBElement $entity, StructuralElementRecursionHelper $recursionHelper) + protected function _delete(Request $request, AbstractNamedDBElement $entity, StructuralElementRecursionHelper $recursionHelper) { $this->denyAccessUnlessGranted('delete', $entity); @@ -242,10 +242,10 @@ abstract class BaseAdminController extends AbstractController $entityManager = $this->getDoctrine()->getManager(); //Check if we need to remove recursively - if ($entity instanceof StructuralDBElement && $request->get('delete_recursive', false)) { + if ($entity instanceof AbstractStructuralDBElement && $request->get('delete_recursive', false)) { $recursionHelper->delete($entity, false); } else { - if ($entity instanceof StructuralDBElement) { + if ($entity instanceof AbstractStructuralDBElement) { $parent = $entity->getParent(); //Move all sub entities to the current parent @@ -281,7 +281,7 @@ abstract class BaseAdminController extends AbstractController return $exporter->exportEntityFromRequest($entities, $request); } - protected function _exportEntity(NamedDBElement $entity, EntityExporter $exporter, Request $request) + protected function _exportEntity(AbstractNamedDBElement $entity, EntityExporter $exporter, Request $request) { $this->denyAccessUnlessGranted('read', $entity); diff --git a/src/DataFixtures/DataStructureFixtures.php b/src/DataFixtures/DataStructureFixtures.php index 119a0f57..6e05ed1c 100644 --- a/src/DataFixtures/DataStructureFixtures.php +++ b/src/DataFixtures/DataStructureFixtures.php @@ -25,7 +25,7 @@ declare(strict_types=1); namespace App\DataFixtures; use App\Entity\Attachments\AttachmentType; -use App\Entity\Base\StructuralDBElement; +use App\Entity\Base\AbstractStructuralDBElement; use App\Entity\Devices\Device; use App\Entity\Parts\Category; use App\Entity\Parts\Footprint; @@ -71,22 +71,22 @@ class DataStructureFixtures extends Fixture */ public function createNodesForClass(string $class, ObjectManager $manager): void { - if (! new $class() instanceof StructuralDBElement) { + if (! new $class() instanceof AbstractStructuralDBElement) { throw new InvalidArgumentException('$class must be a StructuralDBElement!'); } $table_name = $this->em->getClassMetadata($class)->getTableName(); $this->em->getConnection()->exec("ALTER TABLE `${table_name}` AUTO_INCREMENT = 1;"); - /** @var StructuralDBElement $node1 */ + /** @var AbstractStructuralDBElement $node1 */ $node1 = new $class(); $node1->setName('Node 1'); - /** @var StructuralDBElement $node2 */ + /** @var AbstractStructuralDBElement $node2 */ $node2 = new $class(); $node2->setName('Node 2'); - /** @var StructuralDBElement $node3 */ + /** @var AbstractStructuralDBElement $node3 */ $node3 = new $class(); $node3->setName('Node 3'); diff --git a/src/DataTables/Column/EntityColumn.php b/src/DataTables/Column/EntityColumn.php index f4ce6c35..f9ec159d 100644 --- a/src/DataTables/Column/EntityColumn.php +++ b/src/DataTables/Column/EntityColumn.php @@ -24,8 +24,8 @@ declare(strict_types=1); namespace App\DataTables\Column; -use App\Entity\Base\DBElement; -use App\Entity\Base\NamedDBElement; +use App\Entity\Base\AbstractDBElement; +use App\Entity\Base\AbstractNamedDBElement; use App\Entity\Parts\Part; use App\Services\EntityURLGenerator; use Omines\DataTablesBundle\Column\AbstractColumn; @@ -53,7 +53,7 @@ class EntityColumn extends AbstractColumn */ public function normalize($value) { - /** @var NamedDBElement $value */ + /** @var AbstractNamedDBElement $value */ return $value; } @@ -69,7 +69,7 @@ class EntityColumn extends AbstractColumn $resolver->setDefault('render', function (Options $options) { return function ($value, Part $context) use ($options) { - /** @var DBElement|null $entity */ + /** @var AbstractDBElement|null $entity */ $entity = $this->accessor->getValue($context, $options['property']); if ($entity) { diff --git a/src/DataTables/Column/LogEntryTargetColumn.php b/src/DataTables/Column/LogEntryTargetColumn.php index db937d77..30f421d4 100644 --- a/src/DataTables/Column/LogEntryTargetColumn.php +++ b/src/DataTables/Column/LogEntryTargetColumn.php @@ -24,8 +24,8 @@ declare(strict_types=1); namespace App\DataTables\Column; -use App\Entity\Base\DBElement; -use App\Entity\Base\NamedDBElement; +use App\Entity\Base\AbstractDBElement; +use App\Entity\Base\AbstractNamedDBElement; use App\Entity\LogSystem\AbstractLogEntry; use App\Services\ElementTypeNameGenerator; use App\Services\EntityURLGenerator; @@ -70,7 +70,7 @@ class LogEntryTargetColumn extends AbstractColumn $target = $this->entryRepository->getTargetElement($context); //The element is existing - if ($target instanceof NamedDBElement) { + if ($target instanceof AbstractNamedDBElement) { return sprintf( '%s', $this->entityURLGenerator->infoURL($target), @@ -79,7 +79,7 @@ class LogEntryTargetColumn extends AbstractColumn } //Target does not have a name - if ($target instanceof DBElement) { + if ($target instanceof AbstractDBElement) { return sprintf( '%s: %s', $this->elementTypeNameGenerator->getLocalizedTypeLabel($target), diff --git a/src/Entity/Attachments/Attachment.php b/src/Entity/Attachments/Attachment.php index b9a507a6..cf59efec 100644 --- a/src/Entity/Attachments/Attachment.php +++ b/src/Entity/Attachments/Attachment.php @@ -23,7 +23,7 @@ declare(strict_types=1); namespace App\Entity\Attachments; -use App\Entity\Base\NamedDBElement; +use App\Entity\Base\AbstractNamedDBElement; use App\Validator\Constraints\Selectable; use Doctrine\ORM\Mapping as ORM; use function in_array; @@ -48,7 +48,7 @@ use LogicException; * }) * @ORM\EntityListeners({"App\EntityListeners\AttachmentDeleteListener"}) */ -abstract class Attachment extends NamedDBElement +abstract class Attachment extends AbstractNamedDBElement { /** * A list of file extensions, that browsers can show directly as image. diff --git a/src/Entity/Attachments/AttachmentContainingDBElement.php b/src/Entity/Attachments/AttachmentContainingDBElement.php index 7fc3c153..e691e4f1 100644 --- a/src/Entity/Attachments/AttachmentContainingDBElement.php +++ b/src/Entity/Attachments/AttachmentContainingDBElement.php @@ -24,7 +24,7 @@ declare(strict_types=1); namespace App\Entity\Attachments; use App\Entity\Base\MasterAttachmentTrait; -use App\Entity\Base\NamedDBElement; +use App\Entity\Base\AbstractNamedDBElement; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping as ORM; @@ -32,7 +32,7 @@ use Doctrine\ORM\Mapping as ORM; /** * @ORM\MappedSuperclass() */ -abstract class AttachmentContainingDBElement extends NamedDBElement +abstract class AttachmentContainingDBElement extends AbstractNamedDBElement { use MasterAttachmentTrait; diff --git a/src/Entity/Attachments/AttachmentType.php b/src/Entity/Attachments/AttachmentType.php index da4c4c05..3f377608 100644 --- a/src/Entity/Attachments/AttachmentType.php +++ b/src/Entity/Attachments/AttachmentType.php @@ -23,7 +23,7 @@ declare(strict_types=1); namespace App\Entity\Attachments; -use App\Entity\Base\StructuralDBElement; +use App\Entity\Base\AbstractStructuralDBElement; use App\Validator\Constraints\ValidFileFilter; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; @@ -35,7 +35,7 @@ use Doctrine\ORM\Mapping as ORM; * @ORM\Entity(repositoryClass="App\Repository\StructuralDBElementRepository") * @ORM\Table(name="`attachment_types`") */ -class AttachmentType extends StructuralDBElement +class AttachmentType extends AbstractStructuralDBElement { /** * @ORM\OneToMany(targetEntity="AttachmentType", mappedBy="parent", cascade={"persist"}) diff --git a/src/Entity/Base/Company.php b/src/Entity/Base/AbstractCompany.php similarity index 98% rename from src/Entity/Base/Company.php rename to src/Entity/Base/AbstractCompany.php index 711695c6..57d7d48e 100644 --- a/src/Entity/Base/Company.php +++ b/src/Entity/Base/AbstractCompany.php @@ -52,7 +52,7 @@ use Symfony\Component\Validator\Constraints as Assert; * * @ORM\MappedSuperclass() */ -abstract class Company extends PartsContainingDBElement +abstract class AbstractCompany extends AbstractPartsContainingDBElement { /** * @var string The address of the company diff --git a/src/Entity/Base/DBElement.php b/src/Entity/Base/AbstractDBElement.php similarity index 99% rename from src/Entity/Base/DBElement.php rename to src/Entity/Base/AbstractDBElement.php index 4a0cf09c..b73987c9 100644 --- a/src/Entity/Base/DBElement.php +++ b/src/Entity/Base/AbstractDBElement.php @@ -56,7 +56,7 @@ use Symfony\Component\Serializer\Annotation\Groups; * "user" = "App\Entity\User" * }) */ -abstract class DBElement +abstract class AbstractDBElement { /** @var int|null The Identification number for this part. This value is unique for the element in this table. * Null if the element is not saved to DB yet. diff --git a/src/Entity/Base/NamedDBElement.php b/src/Entity/Base/AbstractNamedDBElement.php similarity index 97% rename from src/Entity/Base/NamedDBElement.php rename to src/Entity/Base/AbstractNamedDBElement.php index 7fd1a649..d1f8af1e 100644 --- a/src/Entity/Base/NamedDBElement.php +++ b/src/Entity/Base/AbstractNamedDBElement.php @@ -33,7 +33,7 @@ use Symfony\Component\Validator\Constraints as Assert; * @ORM\MappedSuperclass(repositoryClass="App\Repository\UserRepository") * @ORM\HasLifecycleCallbacks() */ -abstract class NamedDBElement extends DBElement +abstract class AbstractNamedDBElement extends AbstractDBElement { use TimestampTrait; diff --git a/src/Entity/Base/PartsContainingDBElement.php b/src/Entity/Base/AbstractPartsContainingDBElement.php similarity index 94% rename from src/Entity/Base/PartsContainingDBElement.php rename to src/Entity/Base/AbstractPartsContainingDBElement.php index ee9274ec..fc023273 100644 --- a/src/Entity/Base/PartsContainingDBElement.php +++ b/src/Entity/Base/AbstractPartsContainingDBElement.php @@ -33,7 +33,7 @@ use Doctrine\ORM\Mapping as ORM; * * @ORM\MappedSuperclass() */ -abstract class PartsContainingDBElement extends StructuralDBElement +abstract class AbstractPartsContainingDBElement extends AbstractStructuralDBElement { /** * @var Part[]|Collection diff --git a/src/Entity/Base/StructuralDBElement.php b/src/Entity/Base/AbstractStructuralDBElement.php similarity index 94% rename from src/Entity/Base/StructuralDBElement.php rename to src/Entity/Base/AbstractStructuralDBElement.php index b141d524..46ea08ea 100644 --- a/src/Entity/Base/StructuralDBElement.php +++ b/src/Entity/Base/AbstractStructuralDBElement.php @@ -49,7 +49,7 @@ use Symfony\Component\Serializer\Annotation\Groups; * * @UniqueEntity(fields={"name", "parent"}, ignoreNull=false, message="structural.entity.unique_name") */ -abstract class StructuralDBElement extends AttachmentContainingDBElement +abstract class AbstractStructuralDBElement extends AttachmentContainingDBElement { public const ID_ROOT_ELEMENT = 0; @@ -81,13 +81,13 @@ abstract class StructuralDBElement extends AttachmentContainingDBElement * We can not define the mapping here or we will get an exception. Unfortunately we have to do the mapping in the * subclasses. * - * @var StructuralDBElement[]|Collection + * @var AbstractStructuralDBElement[]|Collection * @Groups({"include_children"}) */ protected $children; /** - * @var StructuralDBElement + * @var AbstractStructuralDBElement * @NoneOfItsChildren() * @Groups({"include_parents"}) */ @@ -111,7 +111,7 @@ abstract class StructuralDBElement extends AttachmentContainingDBElement /** * Check if this element is a child of another element (recursive). * - * @param StructuralDBElement $another_element the object to compare + * @param AbstractStructuralDBElement $another_element the object to compare * 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. @@ -156,7 +156,7 @@ abstract class StructuralDBElement extends AttachmentContainingDBElement /** * Get the parent of this element. * - * @return StructuralDBElement|null The parent element. Null if this element, does not have a parent. + * @return AbstractStructuralDBElement|null The parent element. Null if this element, does not have a parent. */ public function getParent(): ?self { @@ -190,7 +190,7 @@ abstract class StructuralDBElement extends AttachmentContainingDBElement if (0 === $this->level && null !== $this->parent) { $element = $this->parent; while (null !== $element) { - /** @var StructuralDBElement $element */ + /** @var AbstractStructuralDBElement $element */ $element = $element->parent; ++$this->level; } @@ -284,7 +284,7 @@ abstract class StructuralDBElement extends AttachmentContainingDBElement * * @param self $new_parent The new parent object * - * @return StructuralDBElement + * @return AbstractStructuralDBElement */ public function setParent(?self $new_parent): self { @@ -303,7 +303,7 @@ abstract class StructuralDBElement extends AttachmentContainingDBElement * * @param string $new_comment the new comment * - * @return StructuralDBElement + * @return AbstractStructuralDBElement */ public function setComment(?string $new_comment): self { @@ -328,7 +328,7 @@ abstract class StructuralDBElement extends AttachmentContainingDBElement } /** - * @return StructuralDBElement + * @return AbstractStructuralDBElement */ public function setNotSelectable(bool $not_selectable): self { diff --git a/src/Entity/Devices/Device.php b/src/Entity/Devices/Device.php index 928b4c4c..f219c632 100644 --- a/src/Entity/Devices/Device.php +++ b/src/Entity/Devices/Device.php @@ -52,7 +52,7 @@ declare(strict_types=1); namespace App\Entity\Devices; use App\Entity\Attachments\DeviceAttachment; -use App\Entity\Base\PartsContainingDBElement; +use App\Entity\Base\AbstractPartsContainingDBElement; use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping as ORM; use InvalidArgumentException; @@ -63,7 +63,7 @@ use InvalidArgumentException; * @ORM\Entity(repositoryClass="App\Repository\StructuralDBElementRepository") * @ORM\Table(name="`devices`") */ -class Device extends PartsContainingDBElement +class Device extends AbstractPartsContainingDBElement { /** * @ORM\OneToMany(targetEntity="Device", mappedBy="parent") diff --git a/src/Entity/Devices/DevicePart.php b/src/Entity/Devices/DevicePart.php index 3bbcbbb1..60a11d73 100644 --- a/src/Entity/Devices/DevicePart.php +++ b/src/Entity/Devices/DevicePart.php @@ -51,7 +51,7 @@ declare(strict_types=1); namespace App\Entity\Devices; -use App\Entity\Base\DBElement; +use App\Entity\Base\AbstractDBElement; use App\Entity\Parts\Part; use Doctrine\ORM\Mapping as ORM; @@ -61,7 +61,7 @@ use Doctrine\ORM\Mapping as ORM; * @ORM\Table("`device_parts`") * @ORM\Entity() */ -class DevicePart extends DBElement +class DevicePart extends AbstractDBElement { /** * @var int diff --git a/src/Entity/LogSystem/AbstractLogEntry.php b/src/Entity/LogSystem/AbstractLogEntry.php index 15bd4b2c..432bea5e 100644 --- a/src/Entity/LogSystem/AbstractLogEntry.php +++ b/src/Entity/LogSystem/AbstractLogEntry.php @@ -26,7 +26,7 @@ namespace App\Entity\LogSystem; use App\Entity\Attachments\Attachment; use App\Entity\Attachments\AttachmentType; -use App\Entity\Base\DBElement; +use App\Entity\Base\AbstractDBElement; use App\Entity\Devices\Device; use App\Entity\Devices\DevicePart; use App\Entity\Parts\Category; @@ -61,7 +61,7 @@ use Psr\Log\LogLevel; * 10 = "DatabaseUpdatedLogEntry" * }) */ -abstract class AbstractLogEntry extends DBElement +abstract class AbstractLogEntry extends AbstractDBElement { public const LEVEL_EMERGENCY = 0; public const LEVEL_ALERT = 1; @@ -311,11 +311,11 @@ abstract class AbstractLogEntry extends DBElement /** * Sets the target element associated with this element. * - * @param DBElement $element The element that should be associated with this element. + * @param AbstractDBElement $element The element that should be associated with this element. * * @return $this */ - public function setTargetElement(?DBElement $element): self + public function setTargetElement(?AbstractDBElement $element): self { if (null === $element) { $this->target_id = 0; diff --git a/src/Entity/Parts/Category.php b/src/Entity/Parts/Category.php index 094bbe4b..6b9db3f4 100644 --- a/src/Entity/Parts/Category.php +++ b/src/Entity/Parts/Category.php @@ -24,7 +24,7 @@ declare(strict_types=1); namespace App\Entity\Parts; use App\Entity\Attachments\CategoryAttachment; -use App\Entity\Base\PartsContainingDBElement; +use App\Entity\Base\AbstractPartsContainingDBElement; use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping as ORM; @@ -34,7 +34,7 @@ use Doctrine\ORM\Mapping as ORM; * @ORM\Entity(repositoryClass="App\Repository\StructuralDBElementRepository") * @ORM\Table(name="`categories`") */ -class Category extends PartsContainingDBElement +class Category extends AbstractPartsContainingDBElement { /** * @ORM\OneToMany(targetEntity="Category", mappedBy="parent") diff --git a/src/Entity/Parts/Footprint.php b/src/Entity/Parts/Footprint.php index b63cbf22..0c8eead2 100644 --- a/src/Entity/Parts/Footprint.php +++ b/src/Entity/Parts/Footprint.php @@ -52,7 +52,7 @@ declare(strict_types=1); namespace App\Entity\Parts; use App\Entity\Attachments\FootprintAttachment; -use App\Entity\Base\PartsContainingDBElement; +use App\Entity\Base\AbstractPartsContainingDBElement; use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping as ORM; @@ -62,7 +62,7 @@ use Doctrine\ORM\Mapping as ORM; * @ORM\Entity(repositoryClass="App\Repository\StructuralDBElementRepository") * @ORM\Table("`footprints`") */ -class Footprint extends PartsContainingDBElement +class Footprint extends AbstractPartsContainingDBElement { /** * @ORM\ManyToOne(targetEntity="Footprint", inversedBy="children") diff --git a/src/Entity/Parts/Manufacturer.php b/src/Entity/Parts/Manufacturer.php index 45dcdc6c..ed66c1ae 100644 --- a/src/Entity/Parts/Manufacturer.php +++ b/src/Entity/Parts/Manufacturer.php @@ -52,7 +52,7 @@ declare(strict_types=1); namespace App\Entity\Parts; use App\Entity\Attachments\ManufacturerAttachment; -use App\Entity\Base\Company; +use App\Entity\Base\AbstractCompany; use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping as ORM; @@ -62,7 +62,7 @@ use Doctrine\ORM\Mapping as ORM; * @ORM\Entity(repositoryClass="App\Repository\StructuralDBElementRepository") * @ORM\Table("`manufacturers`") */ -class Manufacturer extends Company +class Manufacturer extends AbstractCompany { /** * @ORM\ManyToOne(targetEntity="Manufacturer", inversedBy="children") diff --git a/src/Entity/Parts/MeasurementUnit.php b/src/Entity/Parts/MeasurementUnit.php index 761ae8ba..d3d1d11d 100644 --- a/src/Entity/Parts/MeasurementUnit.php +++ b/src/Entity/Parts/MeasurementUnit.php @@ -25,7 +25,7 @@ declare(strict_types=1); namespace App\Entity\Parts; use App\Entity\Attachments\MeasurementUnitAttachment; -use App\Entity\Base\PartsContainingDBElement; +use App\Entity\Base\AbstractPartsContainingDBElement; use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping as ORM; use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity; @@ -39,7 +39,7 @@ use Symfony\Component\Validator\Constraints as Assert; * @ORM\Table(name="`measurement_units`") * @UniqueEntity("unit") */ -class MeasurementUnit extends PartsContainingDBElement +class MeasurementUnit extends AbstractPartsContainingDBElement { /** * @var string The unit symbol that should be used for the Unit. This could be something like "", g (for grams) diff --git a/src/Entity/Parts/PartLot.php b/src/Entity/Parts/PartLot.php index 7f6969fb..df383401 100644 --- a/src/Entity/Parts/PartLot.php +++ b/src/Entity/Parts/PartLot.php @@ -24,7 +24,7 @@ declare(strict_types=1); namespace App\Entity\Parts; -use App\Entity\Base\DBElement; +use App\Entity\Base\AbstractDBElement; use App\Entity\Base\TimestampTrait; use App\Entity\Parts\PartTraits\InstockTrait; use App\Validator\Constraints\Selectable; @@ -43,7 +43,7 @@ use Symfony\Component\Validator\Constraints as Assert; * @ORM\HasLifecycleCallbacks() * @ValidPartLot() */ -class PartLot extends DBElement +class PartLot extends AbstractDBElement { use TimestampTrait; diff --git a/src/Entity/Parts/Storelocation.php b/src/Entity/Parts/Storelocation.php index 7fcf083d..7be25944 100644 --- a/src/Entity/Parts/Storelocation.php +++ b/src/Entity/Parts/Storelocation.php @@ -52,7 +52,7 @@ declare(strict_types=1); namespace App\Entity\Parts; use App\Entity\Attachments\StorelocationAttachment; -use App\Entity\Base\PartsContainingDBElement; +use App\Entity\Base\AbstractPartsContainingDBElement; use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping as ORM; @@ -62,7 +62,7 @@ use Doctrine\ORM\Mapping as ORM; * @ORM\Entity(repositoryClass="App\Repository\StructuralDBElementRepository") * @ORM\Table("`storelocations`") */ -class Storelocation extends PartsContainingDBElement +class Storelocation extends AbstractPartsContainingDBElement { /** * @ORM\OneToMany(targetEntity="Storelocation", mappedBy="parent") diff --git a/src/Entity/Parts/Supplier.php b/src/Entity/Parts/Supplier.php index 0940755f..9cb340da 100644 --- a/src/Entity/Parts/Supplier.php +++ b/src/Entity/Parts/Supplier.php @@ -52,7 +52,7 @@ declare(strict_types=1); namespace App\Entity\Parts; use App\Entity\Attachments\SupplierAttachment; -use App\Entity\Base\Company; +use App\Entity\Base\AbstractCompany; use App\Entity\PriceInformations\Currency; use App\Validator\Constraints\Selectable; use Doctrine\Common\Collections\Collection; @@ -65,7 +65,7 @@ use Symfony\Component\Validator\Constraints as Assert; * @ORM\Entity(repositoryClass="App\Repository\StructuralDBElementRepository") * @ORM\Table("`suppliers`") */ -class Supplier extends Company +class Supplier extends AbstractCompany { /** * @ORM\OneToMany(targetEntity="Supplier", mappedBy="parent") diff --git a/src/Entity/PriceInformations/Currency.php b/src/Entity/PriceInformations/Currency.php index 860aa4a6..1da94052 100644 --- a/src/Entity/PriceInformations/Currency.php +++ b/src/Entity/PriceInformations/Currency.php @@ -25,7 +25,7 @@ declare(strict_types=1); namespace App\Entity\PriceInformations; use App\Entity\Attachments\CurrencyAttachment; -use App\Entity\Base\StructuralDBElement; +use App\Entity\Base\AbstractStructuralDBElement; use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping as ORM; use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity; @@ -38,7 +38,7 @@ use Symfony\Component\Validator\Constraints as Assert; * @ORM\Entity() * @ORM\Table(name="currencies") */ -class Currency extends StructuralDBElement +class Currency extends AbstractStructuralDBElement { public const PRICE_SCALE = 5; diff --git a/src/Entity/PriceInformations/Orderdetail.php b/src/Entity/PriceInformations/Orderdetail.php index 2214d34f..95954dad 100644 --- a/src/Entity/PriceInformations/Orderdetail.php +++ b/src/Entity/PriceInformations/Orderdetail.php @@ -51,7 +51,7 @@ declare(strict_types=1); namespace App\Entity\PriceInformations; -use App\Entity\Base\DBElement; +use App\Entity\Base\AbstractDBElement; use App\Entity\Base\TimestampTrait; use App\Entity\Parts\Part; use App\Entity\Parts\Supplier; @@ -67,7 +67,7 @@ use Symfony\Component\Validator\Constraints as Assert; * @ORM\Entity() * @ORM\HasLifecycleCallbacks() */ -class Orderdetail extends DBElement +class Orderdetail extends AbstractDBElement { use TimestampTrait; diff --git a/src/Entity/PriceInformations/Pricedetail.php b/src/Entity/PriceInformations/Pricedetail.php index 22ecac1d..4221274a 100644 --- a/src/Entity/PriceInformations/Pricedetail.php +++ b/src/Entity/PriceInformations/Pricedetail.php @@ -51,7 +51,7 @@ declare(strict_types=1); namespace App\Entity\PriceInformations; -use App\Entity\Base\DBElement; +use App\Entity\Base\AbstractDBElement; use App\Entity\Base\TimestampTrait; use App\Validator\Constraints\Selectable; use Doctrine\ORM\Mapping as ORM; @@ -66,7 +66,7 @@ use Symfony\Component\Validator\Constraints as Assert; * @ORM\HasLifecycleCallbacks() * @UniqueEntity(fields={"orderdetail", "min_discount_quantity"}) */ -class Pricedetail extends DBElement +class Pricedetail extends AbstractDBElement { use TimestampTrait; diff --git a/src/Entity/UserSystem/Group.php b/src/Entity/UserSystem/Group.php index 1e8fee0b..3fb0fa8d 100644 --- a/src/Entity/UserSystem/Group.php +++ b/src/Entity/UserSystem/Group.php @@ -25,7 +25,7 @@ declare(strict_types=1); namespace App\Entity\UserSystem; use App\Entity\Attachments\GroupAttachment; -use App\Entity\Base\StructuralDBElement; +use App\Entity\Base\AbstractStructuralDBElement; use App\Security\Interfaces\HasPermissionsInterface; use App\Validator\Constraints\ValidPermission; use Doctrine\Common\Collections\Collection; @@ -37,7 +37,7 @@ use Doctrine\ORM\Mapping as ORM; * @ORM\Entity() * @ORM\Table("`groups`") */ -class Group extends StructuralDBElement implements HasPermissionsInterface +class Group extends AbstractStructuralDBElement implements HasPermissionsInterface { /** * @ORM\OneToMany(targetEntity="Group", mappedBy="parent") diff --git a/src/Entity/UserSystem/User.php b/src/Entity/UserSystem/User.php index 3cdfe9e1..74e04437 100644 --- a/src/Entity/UserSystem/User.php +++ b/src/Entity/UserSystem/User.php @@ -54,7 +54,7 @@ namespace App\Entity\UserSystem; use App\Entity\Attachments\AttachmentContainingDBElement; use App\Entity\Attachments\UserAttachment; use App\Entity\Base\MasterAttachmentTrait; -use App\Entity\Base\NamedDBElement; +use App\Entity\Base\AbstractNamedDBElement; use App\Entity\PriceInformations\Currency; use App\Security\Interfaces\HasPermissionsInterface; use App\Validator\Constraints\Selectable; @@ -521,7 +521,7 @@ class User extends AttachmentContainingDBElement implements UserInterface, HasPe * * @return $this */ - public function setName(string $new_name): NamedDBElement + public function setName(string $new_name): AbstractNamedDBElement { // Anonymous user is not allowed to change its username if (! $this->isAnonymousUser()) { diff --git a/src/EntityListeners/TreeCacheInvalidationListener.php b/src/EntityListeners/TreeCacheInvalidationListener.php index 16ce3c8a..a686366c 100644 --- a/src/EntityListeners/TreeCacheInvalidationListener.php +++ b/src/EntityListeners/TreeCacheInvalidationListener.php @@ -24,8 +24,8 @@ declare(strict_types=1); namespace App\EntityListeners; -use App\Entity\Base\DBElement; -use App\Entity\Base\StructuralDBElement; +use App\Entity\Base\AbstractDBElement; +use App\Entity\Base\AbstractStructuralDBElement; use App\Entity\UserSystem\Group; use App\Entity\UserSystem\User; use App\Services\UserCacheKeyGenerator; @@ -50,10 +50,10 @@ class TreeCacheInvalidationListener * @ORM\PostPersist() * @ORM\PostRemove() */ - public function invalidate(DBElement $element, LifecycleEventArgs $event): void + public function invalidate(AbstractDBElement $element, LifecycleEventArgs $event): void { //If an element was changed, then invalidate all cached trees with this element class - if ($element instanceof StructuralDBElement) { + if ($element instanceof AbstractStructuralDBElement) { $secure_class_name = str_replace('\\', '_', get_class($element)); $this->cache->invalidateTags([$secure_class_name]); } diff --git a/src/Form/AdminPages/AttachmentTypeAdminForm.php b/src/Form/AdminPages/AttachmentTypeAdminForm.php index 14c6d91c..3ac37a22 100644 --- a/src/Form/AdminPages/AttachmentTypeAdminForm.php +++ b/src/Form/AdminPages/AttachmentTypeAdminForm.php @@ -24,7 +24,7 @@ declare(strict_types=1); namespace App\Form\AdminPages; -use App\Entity\Base\NamedDBElement; +use App\Entity\Base\AbstractNamedDBElement; use App\Services\Attachments\FileTypeFilterTools; use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; use Symfony\Component\Form\CallbackTransformer; @@ -42,7 +42,7 @@ class AttachmentTypeAdminForm extends BaseEntityAdminForm parent::__construct($security, $params); } - protected function additionalFormElements(FormBuilderInterface $builder, array $options, NamedDBElement $entity): void + protected function additionalFormElements(FormBuilderInterface $builder, array $options, AbstractNamedDBElement $entity): void { $is_new = null === $entity->getID(); diff --git a/src/Form/AdminPages/BaseEntityAdminForm.php b/src/Form/AdminPages/BaseEntityAdminForm.php index feff6641..21eafe85 100644 --- a/src/Form/AdminPages/BaseEntityAdminForm.php +++ b/src/Form/AdminPages/BaseEntityAdminForm.php @@ -25,8 +25,8 @@ declare(strict_types=1); namespace App\Form\AdminPages; use App\Entity\Attachments\Attachment; -use App\Entity\Base\NamedDBElement; -use App\Entity\Base\StructuralDBElement; +use App\Entity\Base\AbstractNamedDBElement; +use App\Entity\Base\AbstractStructuralDBElement; use App\Form\AttachmentFormType; use App\Form\Type\MasterPictureAttachmentType; use App\Form\Type\StructuralEntityType; @@ -62,7 +62,7 @@ class BaseEntityAdminForm extends AbstractType public function buildForm(FormBuilderInterface $builder, array $options): void { - /** @var StructuralDBElement $entity */ + /** @var AbstractStructuralDBElement $entity */ $entity = $options['data']; $is_new = null === $entity->getID(); @@ -140,7 +140,7 @@ class BaseEntityAdminForm extends AbstractType ]); } - protected function additionalFormElements(FormBuilderInterface $builder, array $options, NamedDBElement $entity): void + protected function additionalFormElements(FormBuilderInterface $builder, array $options, AbstractNamedDBElement $entity): void { //Empty for Base } diff --git a/src/Form/AdminPages/CategoryAdminForm.php b/src/Form/AdminPages/CategoryAdminForm.php index 1327ea56..08461417 100644 --- a/src/Form/AdminPages/CategoryAdminForm.php +++ b/src/Form/AdminPages/CategoryAdminForm.php @@ -24,14 +24,14 @@ declare(strict_types=1); namespace App\Form\AdminPages; -use App\Entity\Base\NamedDBElement; +use App\Entity\Base\AbstractNamedDBElement; use Symfony\Component\Form\Extension\Core\Type\CheckboxType; use Symfony\Component\Form\Extension\Core\Type\TextType; use Symfony\Component\Form\FormBuilderInterface; class CategoryAdminForm extends BaseEntityAdminForm { - protected function additionalFormElements(FormBuilderInterface $builder, array $options, NamedDBElement $entity): void + protected function additionalFormElements(FormBuilderInterface $builder, array $options, AbstractNamedDBElement $entity): void { $is_new = null === $entity->getID(); diff --git a/src/Form/AdminPages/CompanyForm.php b/src/Form/AdminPages/CompanyForm.php index cd568f43..e030e40c 100644 --- a/src/Form/AdminPages/CompanyForm.php +++ b/src/Form/AdminPages/CompanyForm.php @@ -24,7 +24,7 @@ declare(strict_types=1); namespace App\Form\AdminPages; -use App\Entity\Base\NamedDBElement; +use App\Entity\Base\AbstractNamedDBElement; use Symfony\Component\Form\Extension\Core\Type\EmailType; use Symfony\Component\Form\Extension\Core\Type\TelType; use Symfony\Component\Form\Extension\Core\Type\TextareaType; @@ -33,7 +33,7 @@ use Symfony\Component\Form\FormBuilderInterface; class CompanyForm extends BaseEntityAdminForm { - protected function additionalFormElements(FormBuilderInterface $builder, array $options, NamedDBElement $entity): void + protected function additionalFormElements(FormBuilderInterface $builder, array $options, AbstractNamedDBElement $entity): void { $is_new = null === $entity->getID(); diff --git a/src/Form/AdminPages/CurrencyAdminForm.php b/src/Form/AdminPages/CurrencyAdminForm.php index a8c47d7a..f508434a 100644 --- a/src/Form/AdminPages/CurrencyAdminForm.php +++ b/src/Form/AdminPages/CurrencyAdminForm.php @@ -24,14 +24,14 @@ declare(strict_types=1); namespace App\Form\AdminPages; -use App\Entity\Base\NamedDBElement; +use App\Entity\Base\AbstractNamedDBElement; use Symfony\Component\Form\Extension\Core\Type\CurrencyType; use Symfony\Component\Form\Extension\Core\Type\MoneyType; use Symfony\Component\Form\FormBuilderInterface; class CurrencyAdminForm extends BaseEntityAdminForm { - protected function additionalFormElements(FormBuilderInterface $builder, array $options, NamedDBElement $entity): void + protected function additionalFormElements(FormBuilderInterface $builder, array $options, AbstractNamedDBElement $entity): void { $is_new = null === $entity->getID(); diff --git a/src/Form/AdminPages/FootprintAdminForm.php b/src/Form/AdminPages/FootprintAdminForm.php index db3e0561..df6ab9c1 100644 --- a/src/Form/AdminPages/FootprintAdminForm.php +++ b/src/Form/AdminPages/FootprintAdminForm.php @@ -24,13 +24,13 @@ declare(strict_types=1); namespace App\Form\AdminPages; -use App\Entity\Base\NamedDBElement; +use App\Entity\Base\AbstractNamedDBElement; use App\Form\Type\MasterPictureAttachmentType; use Symfony\Component\Form\FormBuilderInterface; class FootprintAdminForm extends BaseEntityAdminForm { - public function additionalFormElements(FormBuilderInterface $builder, array $options, NamedDBElement $entity): void + public function additionalFormElements(FormBuilderInterface $builder, array $options, AbstractNamedDBElement $entity): void { $builder->add('footprint_3d', MasterPictureAttachmentType::class, [ 'required' => false, diff --git a/src/Form/AdminPages/GroupAdminForm.php b/src/Form/AdminPages/GroupAdminForm.php index 6a3a2f31..30a8055b 100644 --- a/src/Form/AdminPages/GroupAdminForm.php +++ b/src/Form/AdminPages/GroupAdminForm.php @@ -24,14 +24,14 @@ declare(strict_types=1); namespace App\Form\AdminPages; -use App\Entity\Base\NamedDBElement; +use App\Entity\Base\AbstractNamedDBElement; use App\Form\Permissions\PermissionsType; use Symfony\Component\Form\Extension\Core\Type\CheckboxType; use Symfony\Component\Form\FormBuilderInterface; class GroupAdminForm extends BaseEntityAdminForm { - protected function additionalFormElements(FormBuilderInterface $builder, array $options, NamedDBElement $entity): void + protected function additionalFormElements(FormBuilderInterface $builder, array $options, AbstractNamedDBElement $entity): void { $is_new = null === $entity->getID(); diff --git a/src/Form/AdminPages/ImportType.php b/src/Form/AdminPages/ImportType.php index 27f8c99a..de6e4f51 100644 --- a/src/Form/AdminPages/ImportType.php +++ b/src/Form/AdminPages/ImportType.php @@ -24,7 +24,7 @@ declare(strict_types=1); namespace App\Form\AdminPages; -use App\Entity\Base\StructuralDBElement; +use App\Entity\Base\AbstractStructuralDBElement; use App\Form\Type\StructuralEntityType; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\Extension\Core\Type\CheckboxType; @@ -71,7 +71,7 @@ class ImportType extends AbstractType 'disabled' => $disabled, ]); - if ($entity instanceof StructuralDBElement) { + if ($entity instanceof AbstractStructuralDBElement) { $builder->add('parent', StructuralEntityType::class, [ 'class' => $data['entity_class'], 'required' => false, diff --git a/src/Form/AdminPages/MassCreationForm.php b/src/Form/AdminPages/MassCreationForm.php index 076773ef..8f44fe39 100644 --- a/src/Form/AdminPages/MassCreationForm.php +++ b/src/Form/AdminPages/MassCreationForm.php @@ -24,7 +24,7 @@ declare(strict_types=1); namespace App\Form\AdminPages; -use App\Entity\Base\StructuralDBElement; +use App\Entity\Base\AbstractStructuralDBElement; use App\Form\Type\StructuralEntityType; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\Extension\Core\Type\SubmitType; @@ -61,7 +61,7 @@ class MassCreationForm extends AbstractType 'rows' => 10, ], ]); - if ($entity instanceof StructuralDBElement) { + if ($entity instanceof AbstractStructuralDBElement) { $builder->add('parent', StructuralEntityType::class, [ 'class' => $data['entity_class'], 'required' => false, diff --git a/src/Form/AdminPages/MeasurementUnitAdminForm.php b/src/Form/AdminPages/MeasurementUnitAdminForm.php index affabe18..7fd5d9bf 100644 --- a/src/Form/AdminPages/MeasurementUnitAdminForm.php +++ b/src/Form/AdminPages/MeasurementUnitAdminForm.php @@ -24,14 +24,14 @@ declare(strict_types=1); namespace App\Form\AdminPages; -use App\Entity\Base\NamedDBElement; +use App\Entity\Base\AbstractNamedDBElement; use Symfony\Component\Form\Extension\Core\Type\CheckboxType; use Symfony\Component\Form\Extension\Core\Type\TextType; use Symfony\Component\Form\FormBuilderInterface; class MeasurementUnitAdminForm extends BaseEntityAdminForm { - protected function additionalFormElements(FormBuilderInterface $builder, array $options, NamedDBElement $entity): void + protected function additionalFormElements(FormBuilderInterface $builder, array $options, AbstractNamedDBElement $entity): void { $is_new = null === $entity->getID(); diff --git a/src/Form/AdminPages/StorelocationAdminForm.php b/src/Form/AdminPages/StorelocationAdminForm.php index 29f1b420..fe6aae34 100644 --- a/src/Form/AdminPages/StorelocationAdminForm.php +++ b/src/Form/AdminPages/StorelocationAdminForm.php @@ -24,7 +24,7 @@ declare(strict_types=1); namespace App\Form\AdminPages; -use App\Entity\Base\NamedDBElement; +use App\Entity\Base\AbstractNamedDBElement; use App\Entity\Parts\MeasurementUnit; use App\Form\Type\StructuralEntityType; use Symfony\Component\Form\Extension\Core\Type\CheckboxType; @@ -32,7 +32,7 @@ use Symfony\Component\Form\FormBuilderInterface; class StorelocationAdminForm extends BaseEntityAdminForm { - protected function additionalFormElements(FormBuilderInterface $builder, array $options, NamedDBElement $entity): void + protected function additionalFormElements(FormBuilderInterface $builder, array $options, AbstractNamedDBElement $entity): void { $is_new = null === $entity->getID(); diff --git a/src/Form/AdminPages/SupplierForm.php b/src/Form/AdminPages/SupplierForm.php index 2210e7c6..a1476630 100644 --- a/src/Form/AdminPages/SupplierForm.php +++ b/src/Form/AdminPages/SupplierForm.php @@ -24,7 +24,7 @@ declare(strict_types=1); namespace App\Form\AdminPages; -use App\Entity\Base\NamedDBElement; +use App\Entity\Base\AbstractNamedDBElement; use App\Entity\PriceInformations\Currency; use App\Form\Type\StructuralEntityType; use Symfony\Component\Form\Extension\Core\Type\MoneyType; @@ -32,7 +32,7 @@ use Symfony\Component\Form\FormBuilderInterface; class SupplierForm extends CompanyForm { - protected function additionalFormElements(FormBuilderInterface $builder, array $options, NamedDBElement $entity): void + protected function additionalFormElements(FormBuilderInterface $builder, array $options, AbstractNamedDBElement $entity): void { $is_new = null === $entity->getID(); diff --git a/src/Form/Type/CurrencyEntityType.php b/src/Form/Type/CurrencyEntityType.php index 1b290ba4..3ff45b07 100644 --- a/src/Form/Type/CurrencyEntityType.php +++ b/src/Form/Type/CurrencyEntityType.php @@ -24,7 +24,7 @@ declare(strict_types=1); namespace App\Form\Type; -use App\Entity\Base\StructuralDBElement; +use App\Entity\Base\AbstractStructuralDBElement; use App\Entity\PriceInformations\Currency; use App\Services\Trees\NodesListBuilder; use Doctrine\ORM\EntityManagerInterface; @@ -65,7 +65,7 @@ class CurrencyEntityType extends StructuralEntityType }); } - public function generateChoiceLabels(StructuralDBElement $choice, $key, $value): string + public function generateChoiceLabels(AbstractStructuralDBElement $choice, $key, $value): string { //Similar to StructuralEntityType, but we use the currency symbol instead if available @@ -73,7 +73,7 @@ class CurrencyEntityType extends StructuralEntityType throw new \InvalidArgumentException('$choice must be an currency object!'); } - /** @var StructuralDBElement|null $parent */ + /** @var AbstractStructuralDBElement|null $parent */ $parent = $this->options['subentities_of']; /*** @var Currency $choice */ @@ -93,7 +93,7 @@ class CurrencyEntityType extends StructuralEntityType return $tmp; } - protected function generateChoiceAttr(StructuralDBElement $choice, $key, $value): array + protected function generateChoiceAttr(AbstractStructuralDBElement $choice, $key, $value): array { /** @var Currency $choice */ $tmp = []; diff --git a/src/Form/Type/StructuralEntityType.php b/src/Form/Type/StructuralEntityType.php index 5e1b9d27..2c913ea3 100644 --- a/src/Form/Type/StructuralEntityType.php +++ b/src/Form/Type/StructuralEntityType.php @@ -25,7 +25,7 @@ declare(strict_types=1); namespace App\Form\Type; use App\Entity\Attachments\AttachmentType; -use App\Entity\Base\StructuralDBElement; +use App\Entity\Base\AbstractStructuralDBElement; use App\Repository\StructuralDBElementRepository; use App\Services\Trees\NodesListBuilder; use Doctrine\ORM\EntityManagerInterface; @@ -221,7 +221,7 @@ class StructuralEntityType extends AbstractType return $this->em->find($options['class'], $value->getID()); } - protected function generateChoiceAttr(StructuralDBElement $choice, $key, $value): array + protected function generateChoiceAttr(AbstractStructuralDBElement $choice, $key, $value): array { $tmp = []; @@ -241,12 +241,12 @@ class StructuralEntityType extends AbstractType return $tmp; } - protected function generateChoiceLabels(StructuralDBElement $choice, $key, $value): string + protected function generateChoiceLabels(AbstractStructuralDBElement $choice, $key, $value): string { - /** @var StructuralDBElement|null $parent */ + /** @var AbstractStructuralDBElement|null $parent */ $parent = $this->options['subentities_of']; - /*** @var StructuralDBElement $choice */ + /*** @var AbstractStructuralDBElement $choice */ $level = $choice->getLevel(); //If our base entity is not the root level, we need to change the level, to get zero position if (null !== $this->options['subentities_of']) { diff --git a/src/Form/UserAdminForm.php b/src/Form/UserAdminForm.php index 9cc0ebbe..548e8c6e 100644 --- a/src/Form/UserAdminForm.php +++ b/src/Form/UserAdminForm.php @@ -24,8 +24,8 @@ declare(strict_types=1); namespace App\Form; -use App\Entity\Base\NamedDBElement; -use App\Entity\Base\StructuralDBElement; +use App\Entity\Base\AbstractNamedDBElement; +use App\Entity\Base\AbstractStructuralDBElement; use App\Entity\UserSystem\Group; use App\Entity\UserSystem\User; use App\Form\Permissions\PermissionsType; @@ -65,7 +65,7 @@ class UserAdminForm extends AbstractType public function buildForm(FormBuilderInterface $builder, array $options): void { - /** @var StructuralDBElement $entity */ + /** @var AbstractStructuralDBElement $entity */ $entity = $options['data']; $is_new = null === $entity->getID(); @@ -244,7 +244,7 @@ class UserAdminForm extends AbstractType ]); } - protected function additionalFormElements(FormBuilderInterface $builder, array $options, NamedDBElement $entity): void + protected function additionalFormElements(FormBuilderInterface $builder, array $options, AbstractNamedDBElement $entity): void { //Empty for Base } diff --git a/src/Helpers/Trees/StructuralDBElementIterator.php b/src/Helpers/Trees/StructuralDBElementIterator.php index fe0ab0d4..cb6728f4 100644 --- a/src/Helpers/Trees/StructuralDBElementIterator.php +++ b/src/Helpers/Trees/StructuralDBElementIterator.php @@ -24,7 +24,7 @@ declare(strict_types=1); namespace App\Helpers\Trees; -use App\Entity\Base\StructuralDBElement; +use App\Entity\Base\AbstractStructuralDBElement; use ArrayIterator; use Doctrine\Common\Collections\Collection; use RecursiveIterator; @@ -38,7 +38,7 @@ final class StructuralDBElementIterator extends ArrayIterator implements Recursi public function hasChildren() { - /** @var StructuralDBElement $element */ + /** @var AbstractStructuralDBElement $element */ $element = $this->current(); return ! empty($element->getSubelements()); @@ -46,7 +46,7 @@ final class StructuralDBElementIterator extends ArrayIterator implements Recursi public function getChildren() { - /** @var StructuralDBElement $element */ + /** @var AbstractStructuralDBElement $element */ $element = $this->current(); $subelements = $element->getSubelements(); diff --git a/src/Repository/LogEntryRepository.php b/src/Repository/LogEntryRepository.php index 7b67ec14..48c07719 100644 --- a/src/Repository/LogEntryRepository.php +++ b/src/Repository/LogEntryRepository.php @@ -24,7 +24,7 @@ declare(strict_types=1); namespace App\Repository; -use App\Entity\Base\DBElement; +use App\Entity\Base\AbstractDBElement; use App\Entity\LogSystem\AbstractLogEntry; use Doctrine\ORM\EntityRepository; @@ -33,7 +33,7 @@ class LogEntryRepository extends EntityRepository public function findBy(array $criteria, ?array $orderBy = null, $limit = null, $offset = null) { //Emulate a target element criteria by splitting it manually in the needed criterias - if (isset($criteria['target']) && $criteria['target'] instanceof DBElement) { + if (isset($criteria['target']) && $criteria['target'] instanceof AbstractDBElement) { $element = $criteria['target']; $criteria['target_id'] = $element; $criteria['target_type'] = AbstractLogEntry::targetTypeClassToID(get_class($element)); @@ -46,14 +46,14 @@ class LogEntryRepository extends EntityRepository /** * Find log entries associated with the given element (the history of the element). * - * @param DBElement $element The element for which the history should be generated + * @param AbstractDBElement $element The element for which the history should be generated * @param string $order By default newest entries are shown first. Change this to ASC to show oldest entries first. * @param null $limit * @param null $offset * * @return AbstractLogEntry[] */ - public function getElementHistory(DBElement $element, $order = 'DESC', $limit = null, $offset = null) + public function getElementHistory(AbstractDBElement $element, $order = 'DESC', $limit = null, $offset = null) { return $this->findBy(['element' => $element], ['timestamp' => $order], $limit, $offset); } @@ -75,10 +75,10 @@ class LogEntryRepository extends EntityRepository /** * Gets the target element associated with the logentry. * - * @return DBElement|null Returns the associated DBElement or null if the log either has no target or the element + * @return AbstractDBElement|null Returns the associated DBElement or null if the log either has no target or the element * was deleted from DB. */ - public function getTargetElement(AbstractLogEntry $logEntry): ?DBElement + public function getTargetElement(AbstractLogEntry $logEntry): ?AbstractDBElement { $class = $logEntry->getTargetClass(); $id = $logEntry->getTargetID(); diff --git a/src/Repository/NamedDBElementRepository.php b/src/Repository/NamedDBElementRepository.php index ad4ec7e5..82f150ba 100644 --- a/src/Repository/NamedDBElementRepository.php +++ b/src/Repository/NamedDBElementRepository.php @@ -24,7 +24,7 @@ declare(strict_types=1); namespace App\Repository; -use App\Entity\Base\NamedDBElement; +use App\Entity\Base\AbstractNamedDBElement; use App\Helpers\Trees\TreeViewNode; use Doctrine\ORM\EntityRepository; @@ -42,7 +42,7 @@ class NamedDBElementRepository extends EntityRepository $entities = $this->findBy([], ['name' => 'ASC']); foreach ($entities as $entity) { - /** @var NamedDBElement $entity */ + /** @var AbstractNamedDBElement $entity */ $node = new TreeViewNode($entity->getName(), null, null); $node->setId($entity->getID()); $result[] = $node; diff --git a/src/Repository/StructuralDBElementRepository.php b/src/Repository/StructuralDBElementRepository.php index 6e7f9b8c..ec6ac8b7 100644 --- a/src/Repository/StructuralDBElementRepository.php +++ b/src/Repository/StructuralDBElementRepository.php @@ -24,7 +24,7 @@ declare(strict_types=1); namespace App\Repository; -use App\Entity\Base\StructuralDBElement; +use App\Entity\Base\AbstractStructuralDBElement; use App\Helpers\Trees\StructuralDBElementIterator; use App\Helpers\Trees\TreeViewNode; use RecursiveIteratorIterator; @@ -34,7 +34,7 @@ class StructuralDBElementRepository extends NamedDBElementRepository /** * Finds all nodes without a parent node. They are our root nodes. * - * @return StructuralDBElement[] + * @return AbstractStructuralDBElement[] */ public function findRootNodes(): array { @@ -45,17 +45,17 @@ class StructuralDBElementRepository extends NamedDBElementRepository * Gets a tree of TreeViewNode elements. The root elements has $parent as parent. * The treeview is generic, that means the href are null and ID values are set. * - * @param StructuralDBElement|null $parent The parent the root elements should have. + * @param AbstractStructuralDBElement|null $parent The parent the root elements should have. * * @return TreeViewNode[] */ - public function getGenericNodeTree(?StructuralDBElement $parent = null): array + public function getGenericNodeTree(?AbstractStructuralDBElement $parent = null): array { $result = []; $entities = $this->findBy(['parent' => $parent], ['name' => 'ASC']); foreach ($entities as $entity) { - /** @var StructuralDBElement $entity */ + /** @var AbstractStructuralDBElement $entity */ //Make a recursive call to find all children nodes $children = $this->getGenericNodeTree($entity); $node = new TreeViewNode($entity->getName(), null, $children); @@ -70,11 +70,11 @@ class StructuralDBElementRepository extends NamedDBElementRepository /** * Gets a flattened hierarchical tree. Useful for generating option lists. * - * @param StructuralDBElement|null $parent This entity will be used as root element. Set to null, to use global root + * @param AbstractStructuralDBElement|null $parent This entity will be used as root element. Set to null, to use global root * - * @return StructuralDBElement[] A flattened list containing the tree elements. + * @return AbstractStructuralDBElement[] A flattened list containing the tree elements. */ - public function toNodesList(?StructuralDBElement $parent = null): array + public function toNodesList(?AbstractStructuralDBElement $parent = null): array { $result = []; diff --git a/src/Security/Annotations/ColumnSecurity.php b/src/Security/Annotations/ColumnSecurity.php index bd16c11d..b852d67e 100644 --- a/src/Security/Annotations/ColumnSecurity.php +++ b/src/Security/Annotations/ColumnSecurity.php @@ -24,7 +24,7 @@ declare(strict_types=1); namespace App\Security\Annotations; -use App\Entity\Base\NamedDBElement; +use App\Entity\Base\AbstractNamedDBElement; use DateTime; use Doctrine\Common\Annotations\Annotation; use Doctrine\Common\Collections\ArrayCollection; @@ -91,7 +91,7 @@ class ColumnSecurity //Check if a class name was specified if (class_exists($this->type)) { $object = new $this->type(); - if ($object instanceof NamedDBElement) { + if ($object instanceof AbstractNamedDBElement) { if (is_string($this->placeholder) && '' !== $this->placeholder) { $object->setName($this->placeholder); } else { diff --git a/src/Security/EntityListeners/ElementPermissionListener.php b/src/Security/EntityListeners/ElementPermissionListener.php index 3cbfd53a..57f0d53e 100644 --- a/src/Security/EntityListeners/ElementPermissionListener.php +++ b/src/Security/EntityListeners/ElementPermissionListener.php @@ -24,7 +24,7 @@ declare(strict_types=1); namespace App\Security\EntityListeners; -use App\Entity\Base\DBElement; +use App\Entity\Base\AbstractDBElement; use App\Entity\UserSystem\User; use App\Security\Annotations\ColumnSecurity; use function count; @@ -78,7 +78,7 @@ class ElementPermissionListener * This function is also called after an entity was updated, so we dont show the original data to user, * after an update. */ - public function postLoadHandler(DBElement $element, LifecycleEventArgs $event): void + public function postLoadHandler(AbstractDBElement $element, LifecycleEventArgs $event): void { //Do nothing if security is disabled if ($this->disabled) { @@ -102,7 +102,7 @@ class ElementPermissionListener $value = $annotation->getPlaceholder(); //Detach placeholder entities, so we dont get cascade errors - if ($value instanceof DBElement) { + if ($value instanceof AbstractDBElement) { $this->em->detach($value); } @@ -117,7 +117,7 @@ class ElementPermissionListener * We do it here and not in preupdate, because this is called before calculating the changeset, * and so we dont get problems with orphan removal. */ - public function preFlushHandler(DBElement $element, PreFlushEventArgs $eventArgs): void + public function preFlushHandler(AbstractDBElement $element, PreFlushEventArgs $eventArgs): void { //Do nothing if security is disabled if ($this->disabled) { @@ -182,11 +182,11 @@ class ElementPermissionListener * * @param string $mode What operation should be checked. Must be 'read' or 'edit' * @param ColumnSecurity $annotation The annotation of the property that should be checked - * @param DBElement $element The element that should for which should be checked + * @param AbstractDBElement $element The element that should for which should be checked * * @return bool True if the user is allowed to read that property */ - protected function isGranted(string $mode, ColumnSecurity $annotation, DBElement $element): bool + protected function isGranted(string $mode, ColumnSecurity $annotation, AbstractDBElement $element): bool { if ('read' === $mode) { $operation = $annotation->getReadOperationName(); diff --git a/src/Services/ElementTypeNameGenerator.php b/src/Services/ElementTypeNameGenerator.php index b7f488f0..72e4c205 100644 --- a/src/Services/ElementTypeNameGenerator.php +++ b/src/Services/ElementTypeNameGenerator.php @@ -26,8 +26,8 @@ namespace App\Services; use App\Entity\Attachments\Attachment; use App\Entity\Attachments\AttachmentType; -use App\Entity\Base\DBElement; -use App\Entity\Base\NamedDBElement; +use App\Entity\Base\AbstractDBElement; +use App\Entity\Base\AbstractNamedDBElement; use App\Entity\Devices\Device; use App\Entity\Parts\Category; use App\Entity\Parts\Footprint; @@ -82,7 +82,7 @@ class ElementTypeNameGenerator * Useful when the type should be shown to user. * Throws an exception if the class is not supported. * - * @param DBElement|string $entity The element or class for which the label should be generated + * @param AbstractDBElement|string $entity The element or class for which the label should be generated * * @return string the localized label for the entity type * @@ -113,14 +113,14 @@ class ElementTypeNameGenerator * For example this could be something like: "Part: BC547". * It uses getLocalizedLabel to determine the type. * - * @param NamedDBElement $entity the entity for which the string should be generated + * @param AbstractNamedDBElement $entity the entity for which the string should be generated * @param bool $use_html If set to true, a html string is returned, where the type is set italic * * @return string The localized string * * @throws EntityNotSupportedException when the passed entity is not supported */ - public function getTypeNameCombination(NamedDBElement $entity, bool $use_html = false): string + public function getTypeNameCombination(AbstractNamedDBElement $entity, bool $use_html = false): string { $type = $this->getLocalizedTypeLabel($entity); if ($use_html) { diff --git a/src/Services/EntityExporter.php b/src/Services/EntityExporter.php index 0cf63c45..6fc483e6 100644 --- a/src/Services/EntityExporter.php +++ b/src/Services/EntityExporter.php @@ -24,7 +24,7 @@ declare(strict_types=1); namespace App\Services; -use App\Entity\Base\NamedDBElement; +use App\Entity\Base\AbstractNamedDBElement; use function in_array; use InvalidArgumentException; use function is_array; @@ -114,7 +114,7 @@ class EntityExporter //If view option is not specified, then download the file. if (! $request->get('view')) { - if ($entity instanceof NamedDBElement) { + if ($entity instanceof AbstractNamedDBElement) { $entity_name = $entity->getName(); } elseif (is_array($entity)) { if (empty($entity)) { diff --git a/src/Services/EntityImporter.php b/src/Services/EntityImporter.php index 7cfb7a7a..183cc750 100644 --- a/src/Services/EntityImporter.php +++ b/src/Services/EntityImporter.php @@ -24,7 +24,7 @@ declare(strict_types=1); namespace App\Services; -use App\Entity\Base\StructuralDBElement; +use App\Entity\Base\AbstractStructuralDBElement; use Symfony\Bundle\MakerBundle\Str; use function count; use Doctrine\ORM\EntityManagerInterface; @@ -54,17 +54,17 @@ class EntityImporter * * @param string $lines The list of names seperated by \n * @param string $class_name The name of the class for which the entities should be created - * @param StructuralDBElement|null $parent the element which will be used as parent element for new elements + * @param AbstractStructuralDBElement|null $parent the element which will be used as parent element for new elements * @param array $errors an associative array containing all validation errors * - * @return StructuralDBElement[] An array containing all valid imported entities (with the type $class_name) + * @return AbstractStructuralDBElement[] An array containing all valid imported entities (with the type $class_name) */ - public function massCreation(string $lines, string $class_name, ?StructuralDBElement $parent = null, array &$errors = []): array + public function massCreation(string $lines, string $class_name, ?AbstractStructuralDBElement $parent = null, array &$errors = []): array { //Expand every line to a single entry: $names = explode("\n", $lines); - if (! is_a($class_name, StructuralDBElement::class, true)) { + if (! is_a($class_name, AbstractStructuralDBElement::class, true)) { throw new InvalidArgumentException('$class_name must be a StructuralDBElement type!'); } if (null !== $parent && ! is_a($parent, $class_name)) { @@ -80,7 +80,7 @@ class EntityImporter //Skip empty lines (StrucuralDBElements must have a name) continue; } - /** @var StructuralDBElement $entity */ + /** @var AbstractStructuralDBElement $entity */ //Create new element with given name $entity = new $class_name(); $entity->setName($name); @@ -126,7 +126,7 @@ class EntityImporter //Iterate over each $entity write it to DB. foreach ($entities as $entity) { - /** @var StructuralDBElement $entity */ + /** @var AbstractStructuralDBElement $entity */ //Move every imported entity to the selected parent $entity->setParent($options['parent']); @@ -189,7 +189,7 @@ class EntityImporter } //The serializer has only set the children attributes. We also have to change the parent value (the real value in DB) - if ($entities[0] instanceof StructuralDBElement) { + if ($entities[0] instanceof AbstractStructuralDBElement) { $this->correctParentEntites($entities, null); } @@ -211,12 +211,12 @@ class EntityImporter * This functions corrects the parent setting based on the children value of the parent. * * @param iterable $entities the list of entities that should be fixed - * @param null|StructuralDBElement $parent the parent, to which the entity should be set + * @param null|AbstractStructuralDBElement $parent the parent, to which the entity should be set */ protected function correctParentEntites(iterable $entities, $parent = null): void { foreach ($entities as $entity) { - /** @var StructuralDBElement $entity */ + /** @var AbstractStructuralDBElement $entity */ $entity->setParent($parent); //Do the same for the children of entity $this->correctParentEntites($entity->getChildren(), $entity); diff --git a/src/Services/EntityURLGenerator.php b/src/Services/EntityURLGenerator.php index 64de8f7b..cabccbcf 100644 --- a/src/Services/EntityURLGenerator.php +++ b/src/Services/EntityURLGenerator.php @@ -26,7 +26,7 @@ namespace App\Services; use App\Entity\Attachments\Attachment; use App\Entity\Attachments\AttachmentType; -use App\Entity\Base\DBElement; +use App\Entity\Base\AbstractDBElement; use App\Entity\Devices\Device; use App\Entity\Parts\Category; use App\Entity\Parts\Footprint; @@ -133,13 +133,13 @@ class EntityURLGenerator /** * Generates an URL to a page, where info about this entity can be viewed. * - * @param DBElement $entity The entity for which the info should be generated + * @param AbstractDBElement $entity The entity for which the info should be generated * * @return string The URL to the info page * * @throws EntityNotSupportedException If the method is not supported for the given Entity */ - public function infoURL(DBElement $entity): string + public function infoURL(AbstractDBElement $entity): string { $map = [ Part::class => 'part_info', @@ -223,13 +223,13 @@ class EntityURLGenerator * Generates an URL to a page, where a new entity can be created, that has the same informations as the * given entity (element cloning). * - * @param DBElement $entity The entity for which the link should be generated + * @param AbstractDBElement $entity The entity for which the link should be generated * * @return string the URL to the page * * @throws EntityNotSupportedException If the method is not supported for the given Entity */ - public function cloneURL(DBElement $entity): string + public function cloneURL(AbstractDBElement $entity): string { $map = [ Part::class => 'part_clone', @@ -241,13 +241,13 @@ class EntityURLGenerator /** * Generates an URL to a page, where all parts are listed, which are contained in the given element. * - * @param DBElement $entity The entity for which the link should be generated + * @param AbstractDBElement $entity The entity for which the link should be generated * * @return string the URL to the page * * @throws EntityNotSupportedException If the method is not supported for the given Entity */ - public function listPartsURL(DBElement $entity): string + public function listPartsURL(AbstractDBElement $entity): string { $map = [ Category::class => 'part_list_category', @@ -260,7 +260,7 @@ class EntityURLGenerator return $this->urlGenerator->generate($this->mapToController($map, $entity), ['id' => $entity->getID()]); } - public function deleteURL(DBElement $entity): string + public function deleteURL(AbstractDBElement $entity): string { $map = [ Part::class => 'part_delete', diff --git a/src/Services/StructuralElementRecursionHelper.php b/src/Services/StructuralElementRecursionHelper.php index 8d3e43c1..7cc69f54 100644 --- a/src/Services/StructuralElementRecursionHelper.php +++ b/src/Services/StructuralElementRecursionHelper.php @@ -24,7 +24,7 @@ declare(strict_types=1); namespace App\Services; -use App\Entity\Base\StructuralDBElement; +use App\Entity\Base\AbstractStructuralDBElement; use Doctrine\ORM\EntityManagerInterface; class StructuralElementRecursionHelper @@ -39,7 +39,7 @@ class StructuralElementRecursionHelper /** * Executes an function (callable) recursivly for $element and every of its children. * - * @param StructuralDBElement $element The element on which the func should be executed + * @param AbstractStructuralDBElement $element The element on which the func should be executed * @param callable $func The function which should be executed for each element. * $func has the signature function(StructuralDBElement $element) : void * @param int $max_depth The maximum depth for which should be recursivly called. So if this is set to 5, after the @@ -47,7 +47,7 @@ class StructuralElementRecursionHelper * @param bool $call_from_bottom If set to true the bottom elements (elements with high level) will be called first. * Set to false if you want to call the top elements first. */ - public function execute(StructuralDBElement $element, callable $func, int $max_depth = -1, $call_from_bottom = true): void + public function execute(AbstractStructuralDBElement $element, callable $func, int $max_depth = -1, $call_from_bottom = true): void { //Cancel if we reached our maximal allowed level. Must be zero because -1 is infinity levels if (0 === $max_depth) { @@ -75,15 +75,15 @@ class StructuralElementRecursionHelper /** * Deletes the $element and all its subelements recursivly. * - * @param StructuralDBElement $element the element which should be deleted + * @param AbstractStructuralDBElement $element the element which should be deleted * @param bool $flush When set to true the changes will also be flushed to DB. Set to false if you want to flush * later. */ - public function delete(StructuralDBElement $element, bool $flush = true): void + public function delete(AbstractStructuralDBElement $element, bool $flush = true): void { $em = $this->em; - $this->execute($element, static function (StructuralDBElement $element) use ($em): void { + $this->execute($element, static function (AbstractStructuralDBElement $element) use ($em): void { $em->remove($element); }); diff --git a/src/Services/Trees/NodesListBuilder.php b/src/Services/Trees/NodesListBuilder.php index 25171026..1cc35313 100644 --- a/src/Services/Trees/NodesListBuilder.php +++ b/src/Services/Trees/NodesListBuilder.php @@ -24,7 +24,7 @@ declare(strict_types=1); namespace App\Services\Trees; -use App\Entity\Base\StructuralDBElement; +use App\Entity\Base\AbstractStructuralDBElement; use App\Repository\StructuralDBElementRepository; use App\Services\UserCacheKeyGenerator; use Doctrine\ORM\EntityManagerInterface; @@ -52,11 +52,11 @@ class NodesListBuilder * In difference to the Repository Function, the results here are cached. * * @param string $class_name The class name of the entity you want to retrieve. - * @param StructuralDBElement|null $parent This entity will be used as root element. Set to null, to use global root + * @param AbstractStructuralDBElement|null $parent This entity will be used as root element. Set to null, to use global root * - * @return StructuralDBElement[] A flattened list containing the tree elements. + * @return AbstractStructuralDBElement[] A flattened list containing the tree elements. */ - public function typeToNodesList(string $class_name, ?StructuralDBElement $parent = null): array + public function typeToNodesList(string $class_name, ?AbstractStructuralDBElement $parent = null): array { $parent_id = null !== $parent ? $parent->getID() : '0'; // Backslashes are not allowed in cache keys diff --git a/src/Services/Trees/TreeViewGenerator.php b/src/Services/Trees/TreeViewGenerator.php index 63664396..88ad3172 100644 --- a/src/Services/Trees/TreeViewGenerator.php +++ b/src/Services/Trees/TreeViewGenerator.php @@ -24,9 +24,9 @@ declare(strict_types=1); namespace App\Services\Trees; -use App\Entity\Base\DBElement; -use App\Entity\Base\NamedDBElement; -use App\Entity\Base\StructuralDBElement; +use App\Entity\Base\AbstractDBElement; +use App\Entity\Base\AbstractNamedDBElement; +use App\Entity\Base\AbstractStructuralDBElement; use App\Helpers\Trees\TreeViewNode; use App\Helpers\Trees\TreeViewNodeIterator; use App\Repository\StructuralDBElementRepository; @@ -59,14 +59,14 @@ class TreeViewGenerator * Gets a TreeView list for the entities of the given class. * * @param string $class The class for which the treeView should be generated - * @param StructuralDBElement|null $parent The root nodes in the tree should have this element as parent (use null, if you want to get all entities) + * @param AbstractStructuralDBElement|null $parent The root nodes in the tree should have this element as parent (use null, if you want to get all entities) * @param string $href_type The link type that will be generated for the hyperlink section of each node (see EntityURLGenerator for possible values). * Set to empty string, to disable href field. - * @param DBElement|null $selectedElement The element that should be selected. If set to null, no element will be selected. + * @param AbstractDBElement|null $selectedElement The element that should be selected. If set to null, no element will be selected. * * @return TreeViewNode[] An array of TreeViewNode[] elements of the root elements. */ - public function getTreeView(string $class, ?StructuralDBElement $parent = null, string $href_type = 'list_parts', ?DBElement $selectedElement = null): array + public function getTreeView(string $class, ?AbstractStructuralDBElement $parent = null, string $href_type = 'list_parts', ?AbstractDBElement $selectedElement = null): array { $head = []; @@ -115,13 +115,13 @@ class TreeViewGenerator * The treeview is generic, that means the href are null and ID values are set. * * @param string $class The class for which the tree should be generated - * @param StructuralDBElement|null $parent The parent the root elements should have. + * @param AbstractStructuralDBElement|null $parent The parent the root elements should have. * * @return TreeViewNode[] */ - public function getGenericTree(string $class, ?StructuralDBElement $parent = null): array + public function getGenericTree(string $class, ?AbstractStructuralDBElement $parent = null): array { - if (! is_a($class, NamedDBElement::class, true)) { + if (! is_a($class, AbstractNamedDBElement::class, true)) { throw new \InvalidArgumentException('$class must be a class string that implements StructuralDBElement or NamedDBElement!'); } if (null !== $parent && ! is_a($parent, $class)) { diff --git a/src/Twig/AppExtension.php b/src/Twig/AppExtension.php index 4db01dca..31705b66 100644 --- a/src/Twig/AppExtension.php +++ b/src/Twig/AppExtension.php @@ -24,7 +24,7 @@ declare(strict_types=1); namespace App\Twig; -use App\Entity\Base\DBElement; +use App\Entity\Base\AbstractDBElement; use App\Entity\Parts\MeasurementUnit; use App\Entity\PriceInformations\Currency; use App\Services\AmountFormatter; @@ -107,7 +107,7 @@ class AppExtension extends AbstractExtension ]; } - public function treeData(DBElement $element, string $type = 'newEdit'): string + public function treeData(AbstractDBElement $element, string $type = 'newEdit'): string { $tree = $this->treeBuilder->getTreeView(\get_class($element), null, $type, $element); @@ -128,7 +128,7 @@ class AppExtension extends AbstractExtension return implode('/', $parts); } - public function generateEntityURL(DBElement $entity, string $method = 'info'): string + public function generateEntityURL(AbstractDBElement $entity, string $method = 'info'): string { return $this->entityURLGenerator->getURL($entity, $method); } diff --git a/src/Validator/Constraints/NoneOfItsChildrenValidator.php b/src/Validator/Constraints/NoneOfItsChildrenValidator.php index c6dfddf8..dca04c67 100644 --- a/src/Validator/Constraints/NoneOfItsChildrenValidator.php +++ b/src/Validator/Constraints/NoneOfItsChildrenValidator.php @@ -24,7 +24,7 @@ declare(strict_types=1); namespace App\Validator\Constraints; -use App\Entity\Base\StructuralDBElement; +use App\Entity\Base\AbstractStructuralDBElement; use Symfony\Component\Form\Exception\UnexpectedTypeException; use Symfony\Component\Validator\Constraint; use Symfony\Component\Validator\ConstraintValidator; @@ -54,14 +54,14 @@ class NoneOfItsChildrenValidator extends ConstraintValidator } //Check type of value. Validating only works for StructuralDBElements - if (! $value instanceof StructuralDBElement) { + if (! $value instanceof AbstractStructuralDBElement) { throw new UnexpectedValueException($value, 'StructuralDBElement'); } //Check if the object is assigned to itself - /** @var StructuralDBElement $entity */ + /** @var AbstractStructuralDBElement $entity */ $entity = $this->context->getObject(); - /** @var StructuralDBElement $value */ + /** @var AbstractStructuralDBElement $value */ // Check if the targeted parent is the object itself: $entity_id = $entity->getID(); diff --git a/src/Validator/Constraints/SelectableValidator.php b/src/Validator/Constraints/SelectableValidator.php index 317e1871..9eb65a82 100644 --- a/src/Validator/Constraints/SelectableValidator.php +++ b/src/Validator/Constraints/SelectableValidator.php @@ -24,7 +24,7 @@ declare(strict_types=1); namespace App\Validator\Constraints; -use App\Entity\Base\StructuralDBElement; +use App\Entity\Base\AbstractStructuralDBElement; use Symfony\Component\Form\Exception\UnexpectedTypeException; use Symfony\Component\Validator\Constraint; use Symfony\Component\Validator\ConstraintValidator; @@ -54,7 +54,7 @@ class SelectableValidator extends ConstraintValidator } //Check type of value. Validating only works for StructuralDBElements - if (! $value instanceof StructuralDBElement) { + if (! $value instanceof AbstractStructuralDBElement) { throw new UnexpectedValueException($value, 'StructuralDBElement'); } diff --git a/tests/Services/ElementTypeNameGeneratorTest.php b/tests/Services/ElementTypeNameGeneratorTest.php index ab2f2f41..772b35fb 100644 --- a/tests/Services/ElementTypeNameGeneratorTest.php +++ b/tests/Services/ElementTypeNameGeneratorTest.php @@ -25,8 +25,8 @@ declare(strict_types=1); namespace App\Tests\Services; use App\Entity\Attachments\PartAttachment; -use App\Entity\Base\DBElement; -use App\Entity\Base\NamedDBElement; +use App\Entity\Base\AbstractDBElement; +use App\Entity\Base\AbstractNamedDBElement; use App\Entity\Parts\Category; use App\Entity\Parts\Part; use App\Exceptions\EntityNotSupportedException; @@ -64,7 +64,7 @@ class ElementTypeNameGeneratorTest extends WebTestCase //Test exception for unknpwn type $this->expectException(EntityNotSupportedException::class); - $this->service->getLocalizedTypeLabel(new class() extends DBElement { + $this->service->getLocalizedTypeLabel(new class() extends AbstractDBElement { public function getIDString(): string { return 'Stub'; @@ -83,7 +83,7 @@ class ElementTypeNameGeneratorTest extends WebTestCase //Test exception $this->expectException(EntityNotSupportedException::class); - $this->service->getTypeNameCombination(new class() extends NamedDBElement { + $this->service->getTypeNameCombination(new class() extends AbstractNamedDBElement { public function getIDString(): string { return 'Stub';