Renamed the base DBElement classes to AbstractDBElement to comply with symfony recommendations.

This commit is contained in:
Jan Böhmer 2020-02-01 19:48:07 +01:00
parent da72f5b3ec
commit 594c694ee0
62 changed files with 203 additions and 203 deletions

View file

@ -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

View file

@ -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().' <info>('.$target->getID().')</info>';
} elseif ($entry->getTargetID()) {
$target_name = '<info>('.$entry->getTargetID().')</info>';

View file

@ -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);

View file

@ -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');

View file

@ -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) {

View file

@ -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(
'<a href="%s">%s</a>',
$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(
'<i>%s</i>: %s',
$this->elementTypeNameGenerator->getLocalizedTypeLabel($target),

View file

@ -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.

View file

@ -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;

View file

@ -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"})

View file

@ -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

View file

@ -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.

View file

@ -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;

View file

@ -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

View file

@ -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
{

View file

@ -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")

View file

@ -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

View file

@ -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;

View file

@ -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")

View file

@ -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")

View file

@ -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")

View file

@ -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)

View file

@ -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;

View file

@ -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")

View file

@ -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")

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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")

View file

@ -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()) {

View file

@ -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]);
}

View file

@ -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();

View file

@ -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
}

View file

@ -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();

View file

@ -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();

View file

@ -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();

View file

@ -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,

View file

@ -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();

View file

@ -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,

View file

@ -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,

View file

@ -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();

View file

@ -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();

View file

@ -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();

View file

@ -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 = [];

View file

@ -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']) {

View file

@ -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
}

View file

@ -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();

View file

@ -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();

View file

@ -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;

View file

@ -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 = [];

View file

@ -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 {

View file

@ -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();

View file

@ -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) {

View file

@ -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)) {

View file

@ -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);

View file

@ -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',

View file

@ -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);
});

View file

@ -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

View file

@ -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)) {

View file

@ -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);
}

View file

@ -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();

View file

@ -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');
}

View file

@ -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';