mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-23 18:28:49 +02:00
Renamed the base DBElement classes to AbstractDBElement to comply with symfony recommendations.
This commit is contained in:
parent
da72f5b3ec
commit
594c694ee0
62 changed files with 203 additions and 203 deletions
|
@ -25,7 +25,7 @@ declare(strict_types=1);
|
||||||
namespace App\Command;
|
namespace App\Command;
|
||||||
|
|
||||||
use App\Entity\Attachments\AttachmentType;
|
use App\Entity\Attachments\AttachmentType;
|
||||||
use App\Entity\Base\NamedDBElement;
|
use App\Entity\Base\AbstractNamedDBElement;
|
||||||
use App\Entity\Devices\Device;
|
use App\Entity\Devices\Device;
|
||||||
use App\Entity\Parts\Category;
|
use App\Entity\Parts\Category;
|
||||||
use App\Entity\Parts\Manufacturer;
|
use App\Entity\Parts\Manufacturer;
|
||||||
|
@ -134,7 +134,7 @@ class ConvertBBCodeCommand extends Command
|
||||||
|
|
||||||
//In verbose mode print the names of the entities
|
//In verbose mode print the names of the entities
|
||||||
foreach ($results as $result) {
|
foreach ($results as $result) {
|
||||||
/** @var NamedDBElement $result */
|
/** @var AbstractNamedDBElement $result */
|
||||||
$io->writeln(
|
$io->writeln(
|
||||||
'Convert entity: '.$result->getName().' ('.$result->getIDString().')',
|
'Convert entity: '.$result->getName().' ('.$result->getIDString().')',
|
||||||
OutputInterface::VERBOSITY_VERBOSE
|
OutputInterface::VERBOSITY_VERBOSE
|
||||||
|
|
|
@ -24,7 +24,7 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Command;
|
namespace App\Command;
|
||||||
|
|
||||||
use App\Entity\Base\NamedDBElement;
|
use App\Entity\Base\AbstractNamedDBElement;
|
||||||
use App\Entity\LogSystem\AbstractLogEntry;
|
use App\Entity\LogSystem\AbstractLogEntry;
|
||||||
use App\Services\ElementTypeNameGenerator;
|
use App\Services\ElementTypeNameGenerator;
|
||||||
use App\Services\LogSystem\LogEntryExtraFormatter;
|
use App\Services\LogSystem\LogEntryExtraFormatter;
|
||||||
|
@ -133,7 +133,7 @@ class ShowEventLogCommand extends Command
|
||||||
{
|
{
|
||||||
$target = $this->repo->getTargetElement($entry);
|
$target = $this->repo->getTargetElement($entry);
|
||||||
$target_name = '';
|
$target_name = '';
|
||||||
if ($target instanceof NamedDBElement) {
|
if ($target instanceof AbstractNamedDBElement) {
|
||||||
$target_name = $target->getName().' <info>('.$target->getID().')</info>';
|
$target_name = $target->getName().' <info>('.$target->getID().')</info>';
|
||||||
} elseif ($entry->getTargetID()) {
|
} elseif ($entry->getTargetID()) {
|
||||||
$target_name = '<info>('.$entry->getTargetID().')</info>';
|
$target_name = '<info>('.$entry->getTargetID().')</info>';
|
||||||
|
|
|
@ -24,8 +24,8 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Controller\AdminPages;
|
namespace App\Controller\AdminPages;
|
||||||
|
|
||||||
use App\Entity\Base\NamedDBElement;
|
use App\Entity\Base\AbstractNamedDBElement;
|
||||||
use App\Entity\Base\StructuralDBElement;
|
use App\Entity\Base\AbstractStructuralDBElement;
|
||||||
use App\Entity\UserSystem\User;
|
use App\Entity\UserSystem\User;
|
||||||
use App\Exceptions\AttachmentDownloadException;
|
use App\Exceptions\AttachmentDownloadException;
|
||||||
use App\Form\AdminPages\ImportType;
|
use App\Form\AdminPages\ImportType;
|
||||||
|
@ -75,7 +75,7 @@ abstract class BaseAdminController extends AbstractController
|
||||||
$this->attachmentSubmitHandler = $attachmentSubmitHandler;
|
$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);
|
$this->denyAccessUnlessGranted('read', $entity);
|
||||||
|
|
||||||
|
@ -130,7 +130,7 @@ abstract class BaseAdminController extends AbstractController
|
||||||
|
|
||||||
protected function _new(Request $request, EntityManagerInterface $em, EntityImporter $importer)
|
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();
|
$new_entity = new $this->entity_class();
|
||||||
|
|
||||||
$this->denyAccessUnlessGranted('read', $new_entity);
|
$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);
|
$this->denyAccessUnlessGranted('delete', $entity);
|
||||||
|
|
||||||
|
@ -242,10 +242,10 @@ abstract class BaseAdminController extends AbstractController
|
||||||
$entityManager = $this->getDoctrine()->getManager();
|
$entityManager = $this->getDoctrine()->getManager();
|
||||||
|
|
||||||
//Check if we need to remove recursively
|
//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);
|
$recursionHelper->delete($entity, false);
|
||||||
} else {
|
} else {
|
||||||
if ($entity instanceof StructuralDBElement) {
|
if ($entity instanceof AbstractStructuralDBElement) {
|
||||||
$parent = $entity->getParent();
|
$parent = $entity->getParent();
|
||||||
|
|
||||||
//Move all sub entities to the current parent
|
//Move all sub entities to the current parent
|
||||||
|
@ -281,7 +281,7 @@ abstract class BaseAdminController extends AbstractController
|
||||||
return $exporter->exportEntityFromRequest($entities, $request);
|
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);
|
$this->denyAccessUnlessGranted('read', $entity);
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,7 @@ declare(strict_types=1);
|
||||||
namespace App\DataFixtures;
|
namespace App\DataFixtures;
|
||||||
|
|
||||||
use App\Entity\Attachments\AttachmentType;
|
use App\Entity\Attachments\AttachmentType;
|
||||||
use App\Entity\Base\StructuralDBElement;
|
use App\Entity\Base\AbstractStructuralDBElement;
|
||||||
use App\Entity\Devices\Device;
|
use App\Entity\Devices\Device;
|
||||||
use App\Entity\Parts\Category;
|
use App\Entity\Parts\Category;
|
||||||
use App\Entity\Parts\Footprint;
|
use App\Entity\Parts\Footprint;
|
||||||
|
@ -71,22 +71,22 @@ class DataStructureFixtures extends Fixture
|
||||||
*/
|
*/
|
||||||
public function createNodesForClass(string $class, ObjectManager $manager): void
|
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!');
|
throw new InvalidArgumentException('$class must be a StructuralDBElement!');
|
||||||
}
|
}
|
||||||
|
|
||||||
$table_name = $this->em->getClassMetadata($class)->getTableName();
|
$table_name = $this->em->getClassMetadata($class)->getTableName();
|
||||||
$this->em->getConnection()->exec("ALTER TABLE `${table_name}` AUTO_INCREMENT = 1;");
|
$this->em->getConnection()->exec("ALTER TABLE `${table_name}` AUTO_INCREMENT = 1;");
|
||||||
|
|
||||||
/** @var StructuralDBElement $node1 */
|
/** @var AbstractStructuralDBElement $node1 */
|
||||||
$node1 = new $class();
|
$node1 = new $class();
|
||||||
$node1->setName('Node 1');
|
$node1->setName('Node 1');
|
||||||
|
|
||||||
/** @var StructuralDBElement $node2 */
|
/** @var AbstractStructuralDBElement $node2 */
|
||||||
$node2 = new $class();
|
$node2 = new $class();
|
||||||
$node2->setName('Node 2');
|
$node2->setName('Node 2');
|
||||||
|
|
||||||
/** @var StructuralDBElement $node3 */
|
/** @var AbstractStructuralDBElement $node3 */
|
||||||
$node3 = new $class();
|
$node3 = new $class();
|
||||||
$node3->setName('Node 3');
|
$node3->setName('Node 3');
|
||||||
|
|
||||||
|
|
|
@ -24,8 +24,8 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\DataTables\Column;
|
namespace App\DataTables\Column;
|
||||||
|
|
||||||
use App\Entity\Base\DBElement;
|
use App\Entity\Base\AbstractDBElement;
|
||||||
use App\Entity\Base\NamedDBElement;
|
use App\Entity\Base\AbstractNamedDBElement;
|
||||||
use App\Entity\Parts\Part;
|
use App\Entity\Parts\Part;
|
||||||
use App\Services\EntityURLGenerator;
|
use App\Services\EntityURLGenerator;
|
||||||
use Omines\DataTablesBundle\Column\AbstractColumn;
|
use Omines\DataTablesBundle\Column\AbstractColumn;
|
||||||
|
@ -53,7 +53,7 @@ class EntityColumn extends AbstractColumn
|
||||||
*/
|
*/
|
||||||
public function normalize($value)
|
public function normalize($value)
|
||||||
{
|
{
|
||||||
/** @var NamedDBElement $value */
|
/** @var AbstractNamedDBElement $value */
|
||||||
return $value;
|
return $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,7 +69,7 @@ class EntityColumn extends AbstractColumn
|
||||||
|
|
||||||
$resolver->setDefault('render', function (Options $options) {
|
$resolver->setDefault('render', function (Options $options) {
|
||||||
return function ($value, Part $context) use ($options) {
|
return function ($value, Part $context) use ($options) {
|
||||||
/** @var DBElement|null $entity */
|
/** @var AbstractDBElement|null $entity */
|
||||||
$entity = $this->accessor->getValue($context, $options['property']);
|
$entity = $this->accessor->getValue($context, $options['property']);
|
||||||
|
|
||||||
if ($entity) {
|
if ($entity) {
|
||||||
|
|
|
@ -24,8 +24,8 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\DataTables\Column;
|
namespace App\DataTables\Column;
|
||||||
|
|
||||||
use App\Entity\Base\DBElement;
|
use App\Entity\Base\AbstractDBElement;
|
||||||
use App\Entity\Base\NamedDBElement;
|
use App\Entity\Base\AbstractNamedDBElement;
|
||||||
use App\Entity\LogSystem\AbstractLogEntry;
|
use App\Entity\LogSystem\AbstractLogEntry;
|
||||||
use App\Services\ElementTypeNameGenerator;
|
use App\Services\ElementTypeNameGenerator;
|
||||||
use App\Services\EntityURLGenerator;
|
use App\Services\EntityURLGenerator;
|
||||||
|
@ -70,7 +70,7 @@ class LogEntryTargetColumn extends AbstractColumn
|
||||||
$target = $this->entryRepository->getTargetElement($context);
|
$target = $this->entryRepository->getTargetElement($context);
|
||||||
|
|
||||||
//The element is existing
|
//The element is existing
|
||||||
if ($target instanceof NamedDBElement) {
|
if ($target instanceof AbstractNamedDBElement) {
|
||||||
return sprintf(
|
return sprintf(
|
||||||
'<a href="%s">%s</a>',
|
'<a href="%s">%s</a>',
|
||||||
$this->entityURLGenerator->infoURL($target),
|
$this->entityURLGenerator->infoURL($target),
|
||||||
|
@ -79,7 +79,7 @@ class LogEntryTargetColumn extends AbstractColumn
|
||||||
}
|
}
|
||||||
|
|
||||||
//Target does not have a name
|
//Target does not have a name
|
||||||
if ($target instanceof DBElement) {
|
if ($target instanceof AbstractDBElement) {
|
||||||
return sprintf(
|
return sprintf(
|
||||||
'<i>%s</i>: %s',
|
'<i>%s</i>: %s',
|
||||||
$this->elementTypeNameGenerator->getLocalizedTypeLabel($target),
|
$this->elementTypeNameGenerator->getLocalizedTypeLabel($target),
|
||||||
|
|
|
@ -23,7 +23,7 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Entity\Attachments;
|
namespace App\Entity\Attachments;
|
||||||
|
|
||||||
use App\Entity\Base\NamedDBElement;
|
use App\Entity\Base\AbstractNamedDBElement;
|
||||||
use App\Validator\Constraints\Selectable;
|
use App\Validator\Constraints\Selectable;
|
||||||
use Doctrine\ORM\Mapping as ORM;
|
use Doctrine\ORM\Mapping as ORM;
|
||||||
use function in_array;
|
use function in_array;
|
||||||
|
@ -48,7 +48,7 @@ use LogicException;
|
||||||
* })
|
* })
|
||||||
* @ORM\EntityListeners({"App\EntityListeners\AttachmentDeleteListener"})
|
* @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.
|
* A list of file extensions, that browsers can show directly as image.
|
||||||
|
|
|
@ -24,7 +24,7 @@ declare(strict_types=1);
|
||||||
namespace App\Entity\Attachments;
|
namespace App\Entity\Attachments;
|
||||||
|
|
||||||
use App\Entity\Base\MasterAttachmentTrait;
|
use App\Entity\Base\MasterAttachmentTrait;
|
||||||
use App\Entity\Base\NamedDBElement;
|
use App\Entity\Base\AbstractNamedDBElement;
|
||||||
use Doctrine\Common\Collections\ArrayCollection;
|
use Doctrine\Common\Collections\ArrayCollection;
|
||||||
use Doctrine\Common\Collections\Collection;
|
use Doctrine\Common\Collections\Collection;
|
||||||
use Doctrine\ORM\Mapping as ORM;
|
use Doctrine\ORM\Mapping as ORM;
|
||||||
|
@ -32,7 +32,7 @@ use Doctrine\ORM\Mapping as ORM;
|
||||||
/**
|
/**
|
||||||
* @ORM\MappedSuperclass()
|
* @ORM\MappedSuperclass()
|
||||||
*/
|
*/
|
||||||
abstract class AttachmentContainingDBElement extends NamedDBElement
|
abstract class AttachmentContainingDBElement extends AbstractNamedDBElement
|
||||||
{
|
{
|
||||||
use MasterAttachmentTrait;
|
use MasterAttachmentTrait;
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Entity\Attachments;
|
namespace App\Entity\Attachments;
|
||||||
|
|
||||||
use App\Entity\Base\StructuralDBElement;
|
use App\Entity\Base\AbstractStructuralDBElement;
|
||||||
use App\Validator\Constraints\ValidFileFilter;
|
use App\Validator\Constraints\ValidFileFilter;
|
||||||
use Doctrine\Common\Collections\ArrayCollection;
|
use Doctrine\Common\Collections\ArrayCollection;
|
||||||
use Doctrine\Common\Collections\Collection;
|
use Doctrine\Common\Collections\Collection;
|
||||||
|
@ -35,7 +35,7 @@ use Doctrine\ORM\Mapping as ORM;
|
||||||
* @ORM\Entity(repositoryClass="App\Repository\StructuralDBElementRepository")
|
* @ORM\Entity(repositoryClass="App\Repository\StructuralDBElementRepository")
|
||||||
* @ORM\Table(name="`attachment_types`")
|
* @ORM\Table(name="`attachment_types`")
|
||||||
*/
|
*/
|
||||||
class AttachmentType extends StructuralDBElement
|
class AttachmentType extends AbstractStructuralDBElement
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @ORM\OneToMany(targetEntity="AttachmentType", mappedBy="parent", cascade={"persist"})
|
* @ORM\OneToMany(targetEntity="AttachmentType", mappedBy="parent", cascade={"persist"})
|
||||||
|
|
|
@ -52,7 +52,7 @@ use Symfony\Component\Validator\Constraints as Assert;
|
||||||
*
|
*
|
||||||
* @ORM\MappedSuperclass()
|
* @ORM\MappedSuperclass()
|
||||||
*/
|
*/
|
||||||
abstract class Company extends PartsContainingDBElement
|
abstract class AbstractCompany extends AbstractPartsContainingDBElement
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var string The address of the company
|
* @var string The address of the company
|
|
@ -56,7 +56,7 @@ use Symfony\Component\Serializer\Annotation\Groups;
|
||||||
* "user" = "App\Entity\User"
|
* "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.
|
/** @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.
|
* Null if the element is not saved to DB yet.
|
|
@ -33,7 +33,7 @@ use Symfony\Component\Validator\Constraints as Assert;
|
||||||
* @ORM\MappedSuperclass(repositoryClass="App\Repository\UserRepository")
|
* @ORM\MappedSuperclass(repositoryClass="App\Repository\UserRepository")
|
||||||
* @ORM\HasLifecycleCallbacks()
|
* @ORM\HasLifecycleCallbacks()
|
||||||
*/
|
*/
|
||||||
abstract class NamedDBElement extends DBElement
|
abstract class AbstractNamedDBElement extends AbstractDBElement
|
||||||
{
|
{
|
||||||
use TimestampTrait;
|
use TimestampTrait;
|
||||||
|
|
|
@ -33,7 +33,7 @@ use Doctrine\ORM\Mapping as ORM;
|
||||||
*
|
*
|
||||||
* @ORM\MappedSuperclass()
|
* @ORM\MappedSuperclass()
|
||||||
*/
|
*/
|
||||||
abstract class PartsContainingDBElement extends StructuralDBElement
|
abstract class AbstractPartsContainingDBElement extends AbstractStructuralDBElement
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var Part[]|Collection
|
* @var Part[]|Collection
|
|
@ -49,7 +49,7 @@ use Symfony\Component\Serializer\Annotation\Groups;
|
||||||
*
|
*
|
||||||
* @UniqueEntity(fields={"name", "parent"}, ignoreNull=false, message="structural.entity.unique_name")
|
* @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;
|
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
|
* We can not define the mapping here or we will get an exception. Unfortunately we have to do the mapping in the
|
||||||
* subclasses.
|
* subclasses.
|
||||||
*
|
*
|
||||||
* @var StructuralDBElement[]|Collection
|
* @var AbstractStructuralDBElement[]|Collection
|
||||||
* @Groups({"include_children"})
|
* @Groups({"include_children"})
|
||||||
*/
|
*/
|
||||||
protected $children;
|
protected $children;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var StructuralDBElement
|
* @var AbstractStructuralDBElement
|
||||||
* @NoneOfItsChildren()
|
* @NoneOfItsChildren()
|
||||||
* @Groups({"include_parents"})
|
* @Groups({"include_parents"})
|
||||||
*/
|
*/
|
||||||
|
@ -111,7 +111,7 @@ abstract class StructuralDBElement extends AttachmentContainingDBElement
|
||||||
/**
|
/**
|
||||||
* Check if this element is a child of another element (recursive).
|
* 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)!
|
* 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.
|
* @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.
|
* 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
|
public function getParent(): ?self
|
||||||
{
|
{
|
||||||
|
@ -190,7 +190,7 @@ abstract class StructuralDBElement extends AttachmentContainingDBElement
|
||||||
if (0 === $this->level && null !== $this->parent) {
|
if (0 === $this->level && null !== $this->parent) {
|
||||||
$element = $this->parent;
|
$element = $this->parent;
|
||||||
while (null !== $element) {
|
while (null !== $element) {
|
||||||
/** @var StructuralDBElement $element */
|
/** @var AbstractStructuralDBElement $element */
|
||||||
$element = $element->parent;
|
$element = $element->parent;
|
||||||
++$this->level;
|
++$this->level;
|
||||||
}
|
}
|
||||||
|
@ -284,7 +284,7 @@ abstract class StructuralDBElement extends AttachmentContainingDBElement
|
||||||
*
|
*
|
||||||
* @param self $new_parent The new parent object
|
* @param self $new_parent The new parent object
|
||||||
*
|
*
|
||||||
* @return StructuralDBElement
|
* @return AbstractStructuralDBElement
|
||||||
*/
|
*/
|
||||||
public function setParent(?self $new_parent): self
|
public function setParent(?self $new_parent): self
|
||||||
{
|
{
|
||||||
|
@ -303,7 +303,7 @@ abstract class StructuralDBElement extends AttachmentContainingDBElement
|
||||||
*
|
*
|
||||||
* @param string $new_comment the new comment
|
* @param string $new_comment the new comment
|
||||||
*
|
*
|
||||||
* @return StructuralDBElement
|
* @return AbstractStructuralDBElement
|
||||||
*/
|
*/
|
||||||
public function setComment(?string $new_comment): self
|
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
|
public function setNotSelectable(bool $not_selectable): self
|
||||||
{
|
{
|
|
@ -52,7 +52,7 @@ declare(strict_types=1);
|
||||||
namespace App\Entity\Devices;
|
namespace App\Entity\Devices;
|
||||||
|
|
||||||
use App\Entity\Attachments\DeviceAttachment;
|
use App\Entity\Attachments\DeviceAttachment;
|
||||||
use App\Entity\Base\PartsContainingDBElement;
|
use App\Entity\Base\AbstractPartsContainingDBElement;
|
||||||
use Doctrine\Common\Collections\Collection;
|
use Doctrine\Common\Collections\Collection;
|
||||||
use Doctrine\ORM\Mapping as ORM;
|
use Doctrine\ORM\Mapping as ORM;
|
||||||
use InvalidArgumentException;
|
use InvalidArgumentException;
|
||||||
|
@ -63,7 +63,7 @@ use InvalidArgumentException;
|
||||||
* @ORM\Entity(repositoryClass="App\Repository\StructuralDBElementRepository")
|
* @ORM\Entity(repositoryClass="App\Repository\StructuralDBElementRepository")
|
||||||
* @ORM\Table(name="`devices`")
|
* @ORM\Table(name="`devices`")
|
||||||
*/
|
*/
|
||||||
class Device extends PartsContainingDBElement
|
class Device extends AbstractPartsContainingDBElement
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @ORM\OneToMany(targetEntity="Device", mappedBy="parent")
|
* @ORM\OneToMany(targetEntity="Device", mappedBy="parent")
|
||||||
|
|
|
@ -51,7 +51,7 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Entity\Devices;
|
namespace App\Entity\Devices;
|
||||||
|
|
||||||
use App\Entity\Base\DBElement;
|
use App\Entity\Base\AbstractDBElement;
|
||||||
use App\Entity\Parts\Part;
|
use App\Entity\Parts\Part;
|
||||||
use Doctrine\ORM\Mapping as ORM;
|
use Doctrine\ORM\Mapping as ORM;
|
||||||
|
|
||||||
|
@ -61,7 +61,7 @@ use Doctrine\ORM\Mapping as ORM;
|
||||||
* @ORM\Table("`device_parts`")
|
* @ORM\Table("`device_parts`")
|
||||||
* @ORM\Entity()
|
* @ORM\Entity()
|
||||||
*/
|
*/
|
||||||
class DevicePart extends DBElement
|
class DevicePart extends AbstractDBElement
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var int
|
* @var int
|
||||||
|
|
|
@ -26,7 +26,7 @@ namespace App\Entity\LogSystem;
|
||||||
|
|
||||||
use App\Entity\Attachments\Attachment;
|
use App\Entity\Attachments\Attachment;
|
||||||
use App\Entity\Attachments\AttachmentType;
|
use App\Entity\Attachments\AttachmentType;
|
||||||
use App\Entity\Base\DBElement;
|
use App\Entity\Base\AbstractDBElement;
|
||||||
use App\Entity\Devices\Device;
|
use App\Entity\Devices\Device;
|
||||||
use App\Entity\Devices\DevicePart;
|
use App\Entity\Devices\DevicePart;
|
||||||
use App\Entity\Parts\Category;
|
use App\Entity\Parts\Category;
|
||||||
|
@ -61,7 +61,7 @@ use Psr\Log\LogLevel;
|
||||||
* 10 = "DatabaseUpdatedLogEntry"
|
* 10 = "DatabaseUpdatedLogEntry"
|
||||||
* })
|
* })
|
||||||
*/
|
*/
|
||||||
abstract class AbstractLogEntry extends DBElement
|
abstract class AbstractLogEntry extends AbstractDBElement
|
||||||
{
|
{
|
||||||
public const LEVEL_EMERGENCY = 0;
|
public const LEVEL_EMERGENCY = 0;
|
||||||
public const LEVEL_ALERT = 1;
|
public const LEVEL_ALERT = 1;
|
||||||
|
@ -311,11 +311,11 @@ abstract class AbstractLogEntry extends DBElement
|
||||||
/**
|
/**
|
||||||
* Sets the target element associated with this element.
|
* 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
|
* @return $this
|
||||||
*/
|
*/
|
||||||
public function setTargetElement(?DBElement $element): self
|
public function setTargetElement(?AbstractDBElement $element): self
|
||||||
{
|
{
|
||||||
if (null === $element) {
|
if (null === $element) {
|
||||||
$this->target_id = 0;
|
$this->target_id = 0;
|
||||||
|
|
|
@ -24,7 +24,7 @@ declare(strict_types=1);
|
||||||
namespace App\Entity\Parts;
|
namespace App\Entity\Parts;
|
||||||
|
|
||||||
use App\Entity\Attachments\CategoryAttachment;
|
use App\Entity\Attachments\CategoryAttachment;
|
||||||
use App\Entity\Base\PartsContainingDBElement;
|
use App\Entity\Base\AbstractPartsContainingDBElement;
|
||||||
use Doctrine\Common\Collections\Collection;
|
use Doctrine\Common\Collections\Collection;
|
||||||
use Doctrine\ORM\Mapping as ORM;
|
use Doctrine\ORM\Mapping as ORM;
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ use Doctrine\ORM\Mapping as ORM;
|
||||||
* @ORM\Entity(repositoryClass="App\Repository\StructuralDBElementRepository")
|
* @ORM\Entity(repositoryClass="App\Repository\StructuralDBElementRepository")
|
||||||
* @ORM\Table(name="`categories`")
|
* @ORM\Table(name="`categories`")
|
||||||
*/
|
*/
|
||||||
class Category extends PartsContainingDBElement
|
class Category extends AbstractPartsContainingDBElement
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @ORM\OneToMany(targetEntity="Category", mappedBy="parent")
|
* @ORM\OneToMany(targetEntity="Category", mappedBy="parent")
|
||||||
|
|
|
@ -52,7 +52,7 @@ declare(strict_types=1);
|
||||||
namespace App\Entity\Parts;
|
namespace App\Entity\Parts;
|
||||||
|
|
||||||
use App\Entity\Attachments\FootprintAttachment;
|
use App\Entity\Attachments\FootprintAttachment;
|
||||||
use App\Entity\Base\PartsContainingDBElement;
|
use App\Entity\Base\AbstractPartsContainingDBElement;
|
||||||
use Doctrine\Common\Collections\Collection;
|
use Doctrine\Common\Collections\Collection;
|
||||||
use Doctrine\ORM\Mapping as ORM;
|
use Doctrine\ORM\Mapping as ORM;
|
||||||
|
|
||||||
|
@ -62,7 +62,7 @@ use Doctrine\ORM\Mapping as ORM;
|
||||||
* @ORM\Entity(repositoryClass="App\Repository\StructuralDBElementRepository")
|
* @ORM\Entity(repositoryClass="App\Repository\StructuralDBElementRepository")
|
||||||
* @ORM\Table("`footprints`")
|
* @ORM\Table("`footprints`")
|
||||||
*/
|
*/
|
||||||
class Footprint extends PartsContainingDBElement
|
class Footprint extends AbstractPartsContainingDBElement
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @ORM\ManyToOne(targetEntity="Footprint", inversedBy="children")
|
* @ORM\ManyToOne(targetEntity="Footprint", inversedBy="children")
|
||||||
|
|
|
@ -52,7 +52,7 @@ declare(strict_types=1);
|
||||||
namespace App\Entity\Parts;
|
namespace App\Entity\Parts;
|
||||||
|
|
||||||
use App\Entity\Attachments\ManufacturerAttachment;
|
use App\Entity\Attachments\ManufacturerAttachment;
|
||||||
use App\Entity\Base\Company;
|
use App\Entity\Base\AbstractCompany;
|
||||||
use Doctrine\Common\Collections\Collection;
|
use Doctrine\Common\Collections\Collection;
|
||||||
use Doctrine\ORM\Mapping as ORM;
|
use Doctrine\ORM\Mapping as ORM;
|
||||||
|
|
||||||
|
@ -62,7 +62,7 @@ use Doctrine\ORM\Mapping as ORM;
|
||||||
* @ORM\Entity(repositoryClass="App\Repository\StructuralDBElementRepository")
|
* @ORM\Entity(repositoryClass="App\Repository\StructuralDBElementRepository")
|
||||||
* @ORM\Table("`manufacturers`")
|
* @ORM\Table("`manufacturers`")
|
||||||
*/
|
*/
|
||||||
class Manufacturer extends Company
|
class Manufacturer extends AbstractCompany
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @ORM\ManyToOne(targetEntity="Manufacturer", inversedBy="children")
|
* @ORM\ManyToOne(targetEntity="Manufacturer", inversedBy="children")
|
||||||
|
|
|
@ -25,7 +25,7 @@ declare(strict_types=1);
|
||||||
namespace App\Entity\Parts;
|
namespace App\Entity\Parts;
|
||||||
|
|
||||||
use App\Entity\Attachments\MeasurementUnitAttachment;
|
use App\Entity\Attachments\MeasurementUnitAttachment;
|
||||||
use App\Entity\Base\PartsContainingDBElement;
|
use App\Entity\Base\AbstractPartsContainingDBElement;
|
||||||
use Doctrine\Common\Collections\Collection;
|
use Doctrine\Common\Collections\Collection;
|
||||||
use Doctrine\ORM\Mapping as ORM;
|
use Doctrine\ORM\Mapping as ORM;
|
||||||
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
|
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
|
||||||
|
@ -39,7 +39,7 @@ use Symfony\Component\Validator\Constraints as Assert;
|
||||||
* @ORM\Table(name="`measurement_units`")
|
* @ORM\Table(name="`measurement_units`")
|
||||||
* @UniqueEntity("unit")
|
* @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)
|
* @var string The unit symbol that should be used for the Unit. This could be something like "", g (for grams)
|
||||||
|
|
|
@ -24,7 +24,7 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Entity\Parts;
|
namespace App\Entity\Parts;
|
||||||
|
|
||||||
use App\Entity\Base\DBElement;
|
use App\Entity\Base\AbstractDBElement;
|
||||||
use App\Entity\Base\TimestampTrait;
|
use App\Entity\Base\TimestampTrait;
|
||||||
use App\Entity\Parts\PartTraits\InstockTrait;
|
use App\Entity\Parts\PartTraits\InstockTrait;
|
||||||
use App\Validator\Constraints\Selectable;
|
use App\Validator\Constraints\Selectable;
|
||||||
|
@ -43,7 +43,7 @@ use Symfony\Component\Validator\Constraints as Assert;
|
||||||
* @ORM\HasLifecycleCallbacks()
|
* @ORM\HasLifecycleCallbacks()
|
||||||
* @ValidPartLot()
|
* @ValidPartLot()
|
||||||
*/
|
*/
|
||||||
class PartLot extends DBElement
|
class PartLot extends AbstractDBElement
|
||||||
{
|
{
|
||||||
use TimestampTrait;
|
use TimestampTrait;
|
||||||
|
|
||||||
|
|
|
@ -52,7 +52,7 @@ declare(strict_types=1);
|
||||||
namespace App\Entity\Parts;
|
namespace App\Entity\Parts;
|
||||||
|
|
||||||
use App\Entity\Attachments\StorelocationAttachment;
|
use App\Entity\Attachments\StorelocationAttachment;
|
||||||
use App\Entity\Base\PartsContainingDBElement;
|
use App\Entity\Base\AbstractPartsContainingDBElement;
|
||||||
use Doctrine\Common\Collections\Collection;
|
use Doctrine\Common\Collections\Collection;
|
||||||
use Doctrine\ORM\Mapping as ORM;
|
use Doctrine\ORM\Mapping as ORM;
|
||||||
|
|
||||||
|
@ -62,7 +62,7 @@ use Doctrine\ORM\Mapping as ORM;
|
||||||
* @ORM\Entity(repositoryClass="App\Repository\StructuralDBElementRepository")
|
* @ORM\Entity(repositoryClass="App\Repository\StructuralDBElementRepository")
|
||||||
* @ORM\Table("`storelocations`")
|
* @ORM\Table("`storelocations`")
|
||||||
*/
|
*/
|
||||||
class Storelocation extends PartsContainingDBElement
|
class Storelocation extends AbstractPartsContainingDBElement
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @ORM\OneToMany(targetEntity="Storelocation", mappedBy="parent")
|
* @ORM\OneToMany(targetEntity="Storelocation", mappedBy="parent")
|
||||||
|
|
|
@ -52,7 +52,7 @@ declare(strict_types=1);
|
||||||
namespace App\Entity\Parts;
|
namespace App\Entity\Parts;
|
||||||
|
|
||||||
use App\Entity\Attachments\SupplierAttachment;
|
use App\Entity\Attachments\SupplierAttachment;
|
||||||
use App\Entity\Base\Company;
|
use App\Entity\Base\AbstractCompany;
|
||||||
use App\Entity\PriceInformations\Currency;
|
use App\Entity\PriceInformations\Currency;
|
||||||
use App\Validator\Constraints\Selectable;
|
use App\Validator\Constraints\Selectable;
|
||||||
use Doctrine\Common\Collections\Collection;
|
use Doctrine\Common\Collections\Collection;
|
||||||
|
@ -65,7 +65,7 @@ use Symfony\Component\Validator\Constraints as Assert;
|
||||||
* @ORM\Entity(repositoryClass="App\Repository\StructuralDBElementRepository")
|
* @ORM\Entity(repositoryClass="App\Repository\StructuralDBElementRepository")
|
||||||
* @ORM\Table("`suppliers`")
|
* @ORM\Table("`suppliers`")
|
||||||
*/
|
*/
|
||||||
class Supplier extends Company
|
class Supplier extends AbstractCompany
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @ORM\OneToMany(targetEntity="Supplier", mappedBy="parent")
|
* @ORM\OneToMany(targetEntity="Supplier", mappedBy="parent")
|
||||||
|
|
|
@ -25,7 +25,7 @@ declare(strict_types=1);
|
||||||
namespace App\Entity\PriceInformations;
|
namespace App\Entity\PriceInformations;
|
||||||
|
|
||||||
use App\Entity\Attachments\CurrencyAttachment;
|
use App\Entity\Attachments\CurrencyAttachment;
|
||||||
use App\Entity\Base\StructuralDBElement;
|
use App\Entity\Base\AbstractStructuralDBElement;
|
||||||
use Doctrine\Common\Collections\Collection;
|
use Doctrine\Common\Collections\Collection;
|
||||||
use Doctrine\ORM\Mapping as ORM;
|
use Doctrine\ORM\Mapping as ORM;
|
||||||
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
|
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
|
||||||
|
@ -38,7 +38,7 @@ use Symfony\Component\Validator\Constraints as Assert;
|
||||||
* @ORM\Entity()
|
* @ORM\Entity()
|
||||||
* @ORM\Table(name="currencies")
|
* @ORM\Table(name="currencies")
|
||||||
*/
|
*/
|
||||||
class Currency extends StructuralDBElement
|
class Currency extends AbstractStructuralDBElement
|
||||||
{
|
{
|
||||||
public const PRICE_SCALE = 5;
|
public const PRICE_SCALE = 5;
|
||||||
|
|
||||||
|
|
|
@ -51,7 +51,7 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Entity\PriceInformations;
|
namespace App\Entity\PriceInformations;
|
||||||
|
|
||||||
use App\Entity\Base\DBElement;
|
use App\Entity\Base\AbstractDBElement;
|
||||||
use App\Entity\Base\TimestampTrait;
|
use App\Entity\Base\TimestampTrait;
|
||||||
use App\Entity\Parts\Part;
|
use App\Entity\Parts\Part;
|
||||||
use App\Entity\Parts\Supplier;
|
use App\Entity\Parts\Supplier;
|
||||||
|
@ -67,7 +67,7 @@ use Symfony\Component\Validator\Constraints as Assert;
|
||||||
* @ORM\Entity()
|
* @ORM\Entity()
|
||||||
* @ORM\HasLifecycleCallbacks()
|
* @ORM\HasLifecycleCallbacks()
|
||||||
*/
|
*/
|
||||||
class Orderdetail extends DBElement
|
class Orderdetail extends AbstractDBElement
|
||||||
{
|
{
|
||||||
use TimestampTrait;
|
use TimestampTrait;
|
||||||
|
|
||||||
|
|
|
@ -51,7 +51,7 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Entity\PriceInformations;
|
namespace App\Entity\PriceInformations;
|
||||||
|
|
||||||
use App\Entity\Base\DBElement;
|
use App\Entity\Base\AbstractDBElement;
|
||||||
use App\Entity\Base\TimestampTrait;
|
use App\Entity\Base\TimestampTrait;
|
||||||
use App\Validator\Constraints\Selectable;
|
use App\Validator\Constraints\Selectable;
|
||||||
use Doctrine\ORM\Mapping as ORM;
|
use Doctrine\ORM\Mapping as ORM;
|
||||||
|
@ -66,7 +66,7 @@ use Symfony\Component\Validator\Constraints as Assert;
|
||||||
* @ORM\HasLifecycleCallbacks()
|
* @ORM\HasLifecycleCallbacks()
|
||||||
* @UniqueEntity(fields={"orderdetail", "min_discount_quantity"})
|
* @UniqueEntity(fields={"orderdetail", "min_discount_quantity"})
|
||||||
*/
|
*/
|
||||||
class Pricedetail extends DBElement
|
class Pricedetail extends AbstractDBElement
|
||||||
{
|
{
|
||||||
use TimestampTrait;
|
use TimestampTrait;
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,7 @@ declare(strict_types=1);
|
||||||
namespace App\Entity\UserSystem;
|
namespace App\Entity\UserSystem;
|
||||||
|
|
||||||
use App\Entity\Attachments\GroupAttachment;
|
use App\Entity\Attachments\GroupAttachment;
|
||||||
use App\Entity\Base\StructuralDBElement;
|
use App\Entity\Base\AbstractStructuralDBElement;
|
||||||
use App\Security\Interfaces\HasPermissionsInterface;
|
use App\Security\Interfaces\HasPermissionsInterface;
|
||||||
use App\Validator\Constraints\ValidPermission;
|
use App\Validator\Constraints\ValidPermission;
|
||||||
use Doctrine\Common\Collections\Collection;
|
use Doctrine\Common\Collections\Collection;
|
||||||
|
@ -37,7 +37,7 @@ use Doctrine\ORM\Mapping as ORM;
|
||||||
* @ORM\Entity()
|
* @ORM\Entity()
|
||||||
* @ORM\Table("`groups`")
|
* @ORM\Table("`groups`")
|
||||||
*/
|
*/
|
||||||
class Group extends StructuralDBElement implements HasPermissionsInterface
|
class Group extends AbstractStructuralDBElement implements HasPermissionsInterface
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @ORM\OneToMany(targetEntity="Group", mappedBy="parent")
|
* @ORM\OneToMany(targetEntity="Group", mappedBy="parent")
|
||||||
|
|
|
@ -54,7 +54,7 @@ namespace App\Entity\UserSystem;
|
||||||
use App\Entity\Attachments\AttachmentContainingDBElement;
|
use App\Entity\Attachments\AttachmentContainingDBElement;
|
||||||
use App\Entity\Attachments\UserAttachment;
|
use App\Entity\Attachments\UserAttachment;
|
||||||
use App\Entity\Base\MasterAttachmentTrait;
|
use App\Entity\Base\MasterAttachmentTrait;
|
||||||
use App\Entity\Base\NamedDBElement;
|
use App\Entity\Base\AbstractNamedDBElement;
|
||||||
use App\Entity\PriceInformations\Currency;
|
use App\Entity\PriceInformations\Currency;
|
||||||
use App\Security\Interfaces\HasPermissionsInterface;
|
use App\Security\Interfaces\HasPermissionsInterface;
|
||||||
use App\Validator\Constraints\Selectable;
|
use App\Validator\Constraints\Selectable;
|
||||||
|
@ -521,7 +521,7 @@ class User extends AttachmentContainingDBElement implements UserInterface, HasPe
|
||||||
*
|
*
|
||||||
* @return $this
|
* @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
|
// Anonymous user is not allowed to change its username
|
||||||
if (! $this->isAnonymousUser()) {
|
if (! $this->isAnonymousUser()) {
|
||||||
|
|
|
@ -24,8 +24,8 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\EntityListeners;
|
namespace App\EntityListeners;
|
||||||
|
|
||||||
use App\Entity\Base\DBElement;
|
use App\Entity\Base\AbstractDBElement;
|
||||||
use App\Entity\Base\StructuralDBElement;
|
use App\Entity\Base\AbstractStructuralDBElement;
|
||||||
use App\Entity\UserSystem\Group;
|
use App\Entity\UserSystem\Group;
|
||||||
use App\Entity\UserSystem\User;
|
use App\Entity\UserSystem\User;
|
||||||
use App\Services\UserCacheKeyGenerator;
|
use App\Services\UserCacheKeyGenerator;
|
||||||
|
@ -50,10 +50,10 @@ class TreeCacheInvalidationListener
|
||||||
* @ORM\PostPersist()
|
* @ORM\PostPersist()
|
||||||
* @ORM\PostRemove()
|
* @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 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));
|
$secure_class_name = str_replace('\\', '_', get_class($element));
|
||||||
$this->cache->invalidateTags([$secure_class_name]);
|
$this->cache->invalidateTags([$secure_class_name]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,7 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Form\AdminPages;
|
namespace App\Form\AdminPages;
|
||||||
|
|
||||||
use App\Entity\Base\NamedDBElement;
|
use App\Entity\Base\AbstractNamedDBElement;
|
||||||
use App\Services\Attachments\FileTypeFilterTools;
|
use App\Services\Attachments\FileTypeFilterTools;
|
||||||
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
|
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
|
||||||
use Symfony\Component\Form\CallbackTransformer;
|
use Symfony\Component\Form\CallbackTransformer;
|
||||||
|
@ -42,7 +42,7 @@ class AttachmentTypeAdminForm extends BaseEntityAdminForm
|
||||||
parent::__construct($security, $params);
|
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();
|
$is_new = null === $entity->getID();
|
||||||
|
|
||||||
|
|
|
@ -25,8 +25,8 @@ declare(strict_types=1);
|
||||||
namespace App\Form\AdminPages;
|
namespace App\Form\AdminPages;
|
||||||
|
|
||||||
use App\Entity\Attachments\Attachment;
|
use App\Entity\Attachments\Attachment;
|
||||||
use App\Entity\Base\NamedDBElement;
|
use App\Entity\Base\AbstractNamedDBElement;
|
||||||
use App\Entity\Base\StructuralDBElement;
|
use App\Entity\Base\AbstractStructuralDBElement;
|
||||||
use App\Form\AttachmentFormType;
|
use App\Form\AttachmentFormType;
|
||||||
use App\Form\Type\MasterPictureAttachmentType;
|
use App\Form\Type\MasterPictureAttachmentType;
|
||||||
use App\Form\Type\StructuralEntityType;
|
use App\Form\Type\StructuralEntityType;
|
||||||
|
@ -62,7 +62,7 @@ class BaseEntityAdminForm extends AbstractType
|
||||||
|
|
||||||
public function buildForm(FormBuilderInterface $builder, array $options): void
|
public function buildForm(FormBuilderInterface $builder, array $options): void
|
||||||
{
|
{
|
||||||
/** @var StructuralDBElement $entity */
|
/** @var AbstractStructuralDBElement $entity */
|
||||||
$entity = $options['data'];
|
$entity = $options['data'];
|
||||||
$is_new = null === $entity->getID();
|
$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
|
//Empty for Base
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,14 +24,14 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Form\AdminPages;
|
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\CheckboxType;
|
||||||
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||||||
use Symfony\Component\Form\FormBuilderInterface;
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
|
|
||||||
class CategoryAdminForm extends BaseEntityAdminForm
|
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();
|
$is_new = null === $entity->getID();
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,7 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Form\AdminPages;
|
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\EmailType;
|
||||||
use Symfony\Component\Form\Extension\Core\Type\TelType;
|
use Symfony\Component\Form\Extension\Core\Type\TelType;
|
||||||
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
|
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
|
||||||
|
@ -33,7 +33,7 @@ use Symfony\Component\Form\FormBuilderInterface;
|
||||||
|
|
||||||
class CompanyForm extends BaseEntityAdminForm
|
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();
|
$is_new = null === $entity->getID();
|
||||||
|
|
||||||
|
|
|
@ -24,14 +24,14 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Form\AdminPages;
|
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\CurrencyType;
|
||||||
use Symfony\Component\Form\Extension\Core\Type\MoneyType;
|
use Symfony\Component\Form\Extension\Core\Type\MoneyType;
|
||||||
use Symfony\Component\Form\FormBuilderInterface;
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
|
|
||||||
class CurrencyAdminForm extends BaseEntityAdminForm
|
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();
|
$is_new = null === $entity->getID();
|
||||||
|
|
||||||
|
|
|
@ -24,13 +24,13 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Form\AdminPages;
|
namespace App\Form\AdminPages;
|
||||||
|
|
||||||
use App\Entity\Base\NamedDBElement;
|
use App\Entity\Base\AbstractNamedDBElement;
|
||||||
use App\Form\Type\MasterPictureAttachmentType;
|
use App\Form\Type\MasterPictureAttachmentType;
|
||||||
use Symfony\Component\Form\FormBuilderInterface;
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
|
|
||||||
class FootprintAdminForm extends BaseEntityAdminForm
|
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, [
|
$builder->add('footprint_3d', MasterPictureAttachmentType::class, [
|
||||||
'required' => false,
|
'required' => false,
|
||||||
|
|
|
@ -24,14 +24,14 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Form\AdminPages;
|
namespace App\Form\AdminPages;
|
||||||
|
|
||||||
use App\Entity\Base\NamedDBElement;
|
use App\Entity\Base\AbstractNamedDBElement;
|
||||||
use App\Form\Permissions\PermissionsType;
|
use App\Form\Permissions\PermissionsType;
|
||||||
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
|
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
|
||||||
use Symfony\Component\Form\FormBuilderInterface;
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
|
|
||||||
class GroupAdminForm extends BaseEntityAdminForm
|
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();
|
$is_new = null === $entity->getID();
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,7 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Form\AdminPages;
|
namespace App\Form\AdminPages;
|
||||||
|
|
||||||
use App\Entity\Base\StructuralDBElement;
|
use App\Entity\Base\AbstractStructuralDBElement;
|
||||||
use App\Form\Type\StructuralEntityType;
|
use App\Form\Type\StructuralEntityType;
|
||||||
use Symfony\Component\Form\AbstractType;
|
use Symfony\Component\Form\AbstractType;
|
||||||
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
|
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
|
||||||
|
@ -71,7 +71,7 @@ class ImportType extends AbstractType
|
||||||
'disabled' => $disabled,
|
'disabled' => $disabled,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
if ($entity instanceof StructuralDBElement) {
|
if ($entity instanceof AbstractStructuralDBElement) {
|
||||||
$builder->add('parent', StructuralEntityType::class, [
|
$builder->add('parent', StructuralEntityType::class, [
|
||||||
'class' => $data['entity_class'],
|
'class' => $data['entity_class'],
|
||||||
'required' => false,
|
'required' => false,
|
||||||
|
|
|
@ -24,7 +24,7 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Form\AdminPages;
|
namespace App\Form\AdminPages;
|
||||||
|
|
||||||
use App\Entity\Base\StructuralDBElement;
|
use App\Entity\Base\AbstractStructuralDBElement;
|
||||||
use App\Form\Type\StructuralEntityType;
|
use App\Form\Type\StructuralEntityType;
|
||||||
use Symfony\Component\Form\AbstractType;
|
use Symfony\Component\Form\AbstractType;
|
||||||
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
||||||
|
@ -61,7 +61,7 @@ class MassCreationForm extends AbstractType
|
||||||
'rows' => 10,
|
'rows' => 10,
|
||||||
],
|
],
|
||||||
]);
|
]);
|
||||||
if ($entity instanceof StructuralDBElement) {
|
if ($entity instanceof AbstractStructuralDBElement) {
|
||||||
$builder->add('parent', StructuralEntityType::class, [
|
$builder->add('parent', StructuralEntityType::class, [
|
||||||
'class' => $data['entity_class'],
|
'class' => $data['entity_class'],
|
||||||
'required' => false,
|
'required' => false,
|
||||||
|
|
|
@ -24,14 +24,14 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Form\AdminPages;
|
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\CheckboxType;
|
||||||
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||||||
use Symfony\Component\Form\FormBuilderInterface;
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
|
|
||||||
class MeasurementUnitAdminForm extends BaseEntityAdminForm
|
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();
|
$is_new = null === $entity->getID();
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,7 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Form\AdminPages;
|
namespace App\Form\AdminPages;
|
||||||
|
|
||||||
use App\Entity\Base\NamedDBElement;
|
use App\Entity\Base\AbstractNamedDBElement;
|
||||||
use App\Entity\Parts\MeasurementUnit;
|
use App\Entity\Parts\MeasurementUnit;
|
||||||
use App\Form\Type\StructuralEntityType;
|
use App\Form\Type\StructuralEntityType;
|
||||||
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
|
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
|
||||||
|
@ -32,7 +32,7 @@ use Symfony\Component\Form\FormBuilderInterface;
|
||||||
|
|
||||||
class StorelocationAdminForm extends BaseEntityAdminForm
|
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();
|
$is_new = null === $entity->getID();
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,7 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Form\AdminPages;
|
namespace App\Form\AdminPages;
|
||||||
|
|
||||||
use App\Entity\Base\NamedDBElement;
|
use App\Entity\Base\AbstractNamedDBElement;
|
||||||
use App\Entity\PriceInformations\Currency;
|
use App\Entity\PriceInformations\Currency;
|
||||||
use App\Form\Type\StructuralEntityType;
|
use App\Form\Type\StructuralEntityType;
|
||||||
use Symfony\Component\Form\Extension\Core\Type\MoneyType;
|
use Symfony\Component\Form\Extension\Core\Type\MoneyType;
|
||||||
|
@ -32,7 +32,7 @@ use Symfony\Component\Form\FormBuilderInterface;
|
||||||
|
|
||||||
class SupplierForm extends CompanyForm
|
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();
|
$is_new = null === $entity->getID();
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,7 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Form\Type;
|
namespace App\Form\Type;
|
||||||
|
|
||||||
use App\Entity\Base\StructuralDBElement;
|
use App\Entity\Base\AbstractStructuralDBElement;
|
||||||
use App\Entity\PriceInformations\Currency;
|
use App\Entity\PriceInformations\Currency;
|
||||||
use App\Services\Trees\NodesListBuilder;
|
use App\Services\Trees\NodesListBuilder;
|
||||||
use Doctrine\ORM\EntityManagerInterface;
|
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
|
//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!');
|
throw new \InvalidArgumentException('$choice must be an currency object!');
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @var StructuralDBElement|null $parent */
|
/** @var AbstractStructuralDBElement|null $parent */
|
||||||
$parent = $this->options['subentities_of'];
|
$parent = $this->options['subentities_of'];
|
||||||
|
|
||||||
/*** @var Currency $choice */
|
/*** @var Currency $choice */
|
||||||
|
@ -93,7 +93,7 @@ class CurrencyEntityType extends StructuralEntityType
|
||||||
return $tmp;
|
return $tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function generateChoiceAttr(StructuralDBElement $choice, $key, $value): array
|
protected function generateChoiceAttr(AbstractStructuralDBElement $choice, $key, $value): array
|
||||||
{
|
{
|
||||||
/** @var Currency $choice */
|
/** @var Currency $choice */
|
||||||
$tmp = [];
|
$tmp = [];
|
||||||
|
|
|
@ -25,7 +25,7 @@ declare(strict_types=1);
|
||||||
namespace App\Form\Type;
|
namespace App\Form\Type;
|
||||||
|
|
||||||
use App\Entity\Attachments\AttachmentType;
|
use App\Entity\Attachments\AttachmentType;
|
||||||
use App\Entity\Base\StructuralDBElement;
|
use App\Entity\Base\AbstractStructuralDBElement;
|
||||||
use App\Repository\StructuralDBElementRepository;
|
use App\Repository\StructuralDBElementRepository;
|
||||||
use App\Services\Trees\NodesListBuilder;
|
use App\Services\Trees\NodesListBuilder;
|
||||||
use Doctrine\ORM\EntityManagerInterface;
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
|
@ -221,7 +221,7 @@ class StructuralEntityType extends AbstractType
|
||||||
return $this->em->find($options['class'], $value->getID());
|
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 = [];
|
$tmp = [];
|
||||||
|
|
||||||
|
@ -241,12 +241,12 @@ class StructuralEntityType extends AbstractType
|
||||||
return $tmp;
|
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'];
|
$parent = $this->options['subentities_of'];
|
||||||
|
|
||||||
/*** @var StructuralDBElement $choice */
|
/*** @var AbstractStructuralDBElement $choice */
|
||||||
$level = $choice->getLevel();
|
$level = $choice->getLevel();
|
||||||
//If our base entity is not the root level, we need to change the level, to get zero position
|
//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']) {
|
if (null !== $this->options['subentities_of']) {
|
||||||
|
|
|
@ -24,8 +24,8 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Form;
|
namespace App\Form;
|
||||||
|
|
||||||
use App\Entity\Base\NamedDBElement;
|
use App\Entity\Base\AbstractNamedDBElement;
|
||||||
use App\Entity\Base\StructuralDBElement;
|
use App\Entity\Base\AbstractStructuralDBElement;
|
||||||
use App\Entity\UserSystem\Group;
|
use App\Entity\UserSystem\Group;
|
||||||
use App\Entity\UserSystem\User;
|
use App\Entity\UserSystem\User;
|
||||||
use App\Form\Permissions\PermissionsType;
|
use App\Form\Permissions\PermissionsType;
|
||||||
|
@ -65,7 +65,7 @@ class UserAdminForm extends AbstractType
|
||||||
|
|
||||||
public function buildForm(FormBuilderInterface $builder, array $options): void
|
public function buildForm(FormBuilderInterface $builder, array $options): void
|
||||||
{
|
{
|
||||||
/** @var StructuralDBElement $entity */
|
/** @var AbstractStructuralDBElement $entity */
|
||||||
$entity = $options['data'];
|
$entity = $options['data'];
|
||||||
$is_new = null === $entity->getID();
|
$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
|
//Empty for Base
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,7 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Helpers\Trees;
|
namespace App\Helpers\Trees;
|
||||||
|
|
||||||
use App\Entity\Base\StructuralDBElement;
|
use App\Entity\Base\AbstractStructuralDBElement;
|
||||||
use ArrayIterator;
|
use ArrayIterator;
|
||||||
use Doctrine\Common\Collections\Collection;
|
use Doctrine\Common\Collections\Collection;
|
||||||
use RecursiveIterator;
|
use RecursiveIterator;
|
||||||
|
@ -38,7 +38,7 @@ final class StructuralDBElementIterator extends ArrayIterator implements Recursi
|
||||||
|
|
||||||
public function hasChildren()
|
public function hasChildren()
|
||||||
{
|
{
|
||||||
/** @var StructuralDBElement $element */
|
/** @var AbstractStructuralDBElement $element */
|
||||||
$element = $this->current();
|
$element = $this->current();
|
||||||
|
|
||||||
return ! empty($element->getSubelements());
|
return ! empty($element->getSubelements());
|
||||||
|
@ -46,7 +46,7 @@ final class StructuralDBElementIterator extends ArrayIterator implements Recursi
|
||||||
|
|
||||||
public function getChildren()
|
public function getChildren()
|
||||||
{
|
{
|
||||||
/** @var StructuralDBElement $element */
|
/** @var AbstractStructuralDBElement $element */
|
||||||
$element = $this->current();
|
$element = $this->current();
|
||||||
|
|
||||||
$subelements = $element->getSubelements();
|
$subelements = $element->getSubelements();
|
||||||
|
|
|
@ -24,7 +24,7 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Repository;
|
namespace App\Repository;
|
||||||
|
|
||||||
use App\Entity\Base\DBElement;
|
use App\Entity\Base\AbstractDBElement;
|
||||||
use App\Entity\LogSystem\AbstractLogEntry;
|
use App\Entity\LogSystem\AbstractLogEntry;
|
||||||
use Doctrine\ORM\EntityRepository;
|
use Doctrine\ORM\EntityRepository;
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ class LogEntryRepository extends EntityRepository
|
||||||
public function findBy(array $criteria, ?array $orderBy = null, $limit = null, $offset = null)
|
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
|
//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'];
|
$element = $criteria['target'];
|
||||||
$criteria['target_id'] = $element;
|
$criteria['target_id'] = $element;
|
||||||
$criteria['target_type'] = AbstractLogEntry::targetTypeClassToID(get_class($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).
|
* 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 string $order By default newest entries are shown first. Change this to ASC to show oldest entries first.
|
||||||
* @param null $limit
|
* @param null $limit
|
||||||
* @param null $offset
|
* @param null $offset
|
||||||
*
|
*
|
||||||
* @return AbstractLogEntry[]
|
* @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);
|
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.
|
* 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.
|
* was deleted from DB.
|
||||||
*/
|
*/
|
||||||
public function getTargetElement(AbstractLogEntry $logEntry): ?DBElement
|
public function getTargetElement(AbstractLogEntry $logEntry): ?AbstractDBElement
|
||||||
{
|
{
|
||||||
$class = $logEntry->getTargetClass();
|
$class = $logEntry->getTargetClass();
|
||||||
$id = $logEntry->getTargetID();
|
$id = $logEntry->getTargetID();
|
||||||
|
|
|
@ -24,7 +24,7 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Repository;
|
namespace App\Repository;
|
||||||
|
|
||||||
use App\Entity\Base\NamedDBElement;
|
use App\Entity\Base\AbstractNamedDBElement;
|
||||||
use App\Helpers\Trees\TreeViewNode;
|
use App\Helpers\Trees\TreeViewNode;
|
||||||
use Doctrine\ORM\EntityRepository;
|
use Doctrine\ORM\EntityRepository;
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@ class NamedDBElementRepository extends EntityRepository
|
||||||
|
|
||||||
$entities = $this->findBy([], ['name' => 'ASC']);
|
$entities = $this->findBy([], ['name' => 'ASC']);
|
||||||
foreach ($entities as $entity) {
|
foreach ($entities as $entity) {
|
||||||
/** @var NamedDBElement $entity */
|
/** @var AbstractNamedDBElement $entity */
|
||||||
$node = new TreeViewNode($entity->getName(), null, null);
|
$node = new TreeViewNode($entity->getName(), null, null);
|
||||||
$node->setId($entity->getID());
|
$node->setId($entity->getID());
|
||||||
$result[] = $node;
|
$result[] = $node;
|
||||||
|
|
|
@ -24,7 +24,7 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Repository;
|
namespace App\Repository;
|
||||||
|
|
||||||
use App\Entity\Base\StructuralDBElement;
|
use App\Entity\Base\AbstractStructuralDBElement;
|
||||||
use App\Helpers\Trees\StructuralDBElementIterator;
|
use App\Helpers\Trees\StructuralDBElementIterator;
|
||||||
use App\Helpers\Trees\TreeViewNode;
|
use App\Helpers\Trees\TreeViewNode;
|
||||||
use RecursiveIteratorIterator;
|
use RecursiveIteratorIterator;
|
||||||
|
@ -34,7 +34,7 @@ class StructuralDBElementRepository extends NamedDBElementRepository
|
||||||
/**
|
/**
|
||||||
* Finds all nodes without a parent node. They are our root nodes.
|
* Finds all nodes without a parent node. They are our root nodes.
|
||||||
*
|
*
|
||||||
* @return StructuralDBElement[]
|
* @return AbstractStructuralDBElement[]
|
||||||
*/
|
*/
|
||||||
public function findRootNodes(): array
|
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.
|
* 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.
|
* 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[]
|
* @return TreeViewNode[]
|
||||||
*/
|
*/
|
||||||
public function getGenericNodeTree(?StructuralDBElement $parent = null): array
|
public function getGenericNodeTree(?AbstractStructuralDBElement $parent = null): array
|
||||||
{
|
{
|
||||||
$result = [];
|
$result = [];
|
||||||
|
|
||||||
$entities = $this->findBy(['parent' => $parent], ['name' => 'ASC']);
|
$entities = $this->findBy(['parent' => $parent], ['name' => 'ASC']);
|
||||||
foreach ($entities as $entity) {
|
foreach ($entities as $entity) {
|
||||||
/** @var StructuralDBElement $entity */
|
/** @var AbstractStructuralDBElement $entity */
|
||||||
//Make a recursive call to find all children nodes
|
//Make a recursive call to find all children nodes
|
||||||
$children = $this->getGenericNodeTree($entity);
|
$children = $this->getGenericNodeTree($entity);
|
||||||
$node = new TreeViewNode($entity->getName(), null, $children);
|
$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.
|
* 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 = [];
|
$result = [];
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,7 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Security\Annotations;
|
namespace App\Security\Annotations;
|
||||||
|
|
||||||
use App\Entity\Base\NamedDBElement;
|
use App\Entity\Base\AbstractNamedDBElement;
|
||||||
use DateTime;
|
use DateTime;
|
||||||
use Doctrine\Common\Annotations\Annotation;
|
use Doctrine\Common\Annotations\Annotation;
|
||||||
use Doctrine\Common\Collections\ArrayCollection;
|
use Doctrine\Common\Collections\ArrayCollection;
|
||||||
|
@ -91,7 +91,7 @@ class ColumnSecurity
|
||||||
//Check if a class name was specified
|
//Check if a class name was specified
|
||||||
if (class_exists($this->type)) {
|
if (class_exists($this->type)) {
|
||||||
$object = new $this->type();
|
$object = new $this->type();
|
||||||
if ($object instanceof NamedDBElement) {
|
if ($object instanceof AbstractNamedDBElement) {
|
||||||
if (is_string($this->placeholder) && '' !== $this->placeholder) {
|
if (is_string($this->placeholder) && '' !== $this->placeholder) {
|
||||||
$object->setName($this->placeholder);
|
$object->setName($this->placeholder);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -24,7 +24,7 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Security\EntityListeners;
|
namespace App\Security\EntityListeners;
|
||||||
|
|
||||||
use App\Entity\Base\DBElement;
|
use App\Entity\Base\AbstractDBElement;
|
||||||
use App\Entity\UserSystem\User;
|
use App\Entity\UserSystem\User;
|
||||||
use App\Security\Annotations\ColumnSecurity;
|
use App\Security\Annotations\ColumnSecurity;
|
||||||
use function count;
|
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,
|
* This function is also called after an entity was updated, so we dont show the original data to user,
|
||||||
* after an update.
|
* 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
|
//Do nothing if security is disabled
|
||||||
if ($this->disabled) {
|
if ($this->disabled) {
|
||||||
|
@ -102,7 +102,7 @@ class ElementPermissionListener
|
||||||
$value = $annotation->getPlaceholder();
|
$value = $annotation->getPlaceholder();
|
||||||
|
|
||||||
//Detach placeholder entities, so we dont get cascade errors
|
//Detach placeholder entities, so we dont get cascade errors
|
||||||
if ($value instanceof DBElement) {
|
if ($value instanceof AbstractDBElement) {
|
||||||
$this->em->detach($value);
|
$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,
|
* 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.
|
* 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
|
//Do nothing if security is disabled
|
||||||
if ($this->disabled) {
|
if ($this->disabled) {
|
||||||
|
@ -182,11 +182,11 @@ class ElementPermissionListener
|
||||||
*
|
*
|
||||||
* @param string $mode What operation should be checked. Must be 'read' or 'edit'
|
* @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 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
|
* @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) {
|
if ('read' === $mode) {
|
||||||
$operation = $annotation->getReadOperationName();
|
$operation = $annotation->getReadOperationName();
|
||||||
|
|
|
@ -26,8 +26,8 @@ namespace App\Services;
|
||||||
|
|
||||||
use App\Entity\Attachments\Attachment;
|
use App\Entity\Attachments\Attachment;
|
||||||
use App\Entity\Attachments\AttachmentType;
|
use App\Entity\Attachments\AttachmentType;
|
||||||
use App\Entity\Base\DBElement;
|
use App\Entity\Base\AbstractDBElement;
|
||||||
use App\Entity\Base\NamedDBElement;
|
use App\Entity\Base\AbstractNamedDBElement;
|
||||||
use App\Entity\Devices\Device;
|
use App\Entity\Devices\Device;
|
||||||
use App\Entity\Parts\Category;
|
use App\Entity\Parts\Category;
|
||||||
use App\Entity\Parts\Footprint;
|
use App\Entity\Parts\Footprint;
|
||||||
|
@ -82,7 +82,7 @@ class ElementTypeNameGenerator
|
||||||
* Useful when the type should be shown to user.
|
* Useful when the type should be shown to user.
|
||||||
* Throws an exception if the class is not supported.
|
* 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
|
* @return string the localized label for the entity type
|
||||||
*
|
*
|
||||||
|
@ -113,14 +113,14 @@ class ElementTypeNameGenerator
|
||||||
* For example this could be something like: "Part: BC547".
|
* For example this could be something like: "Part: BC547".
|
||||||
* It uses getLocalizedLabel to determine the type.
|
* 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
|
* @param bool $use_html If set to true, a html string is returned, where the type is set italic
|
||||||
*
|
*
|
||||||
* @return string The localized string
|
* @return string The localized string
|
||||||
*
|
*
|
||||||
* @throws EntityNotSupportedException when the passed entity is not supported
|
* @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);
|
$type = $this->getLocalizedTypeLabel($entity);
|
||||||
if ($use_html) {
|
if ($use_html) {
|
||||||
|
|
|
@ -24,7 +24,7 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Services;
|
namespace App\Services;
|
||||||
|
|
||||||
use App\Entity\Base\NamedDBElement;
|
use App\Entity\Base\AbstractNamedDBElement;
|
||||||
use function in_array;
|
use function in_array;
|
||||||
use InvalidArgumentException;
|
use InvalidArgumentException;
|
||||||
use function is_array;
|
use function is_array;
|
||||||
|
@ -114,7 +114,7 @@ class EntityExporter
|
||||||
|
|
||||||
//If view option is not specified, then download the file.
|
//If view option is not specified, then download the file.
|
||||||
if (! $request->get('view')) {
|
if (! $request->get('view')) {
|
||||||
if ($entity instanceof NamedDBElement) {
|
if ($entity instanceof AbstractNamedDBElement) {
|
||||||
$entity_name = $entity->getName();
|
$entity_name = $entity->getName();
|
||||||
} elseif (is_array($entity)) {
|
} elseif (is_array($entity)) {
|
||||||
if (empty($entity)) {
|
if (empty($entity)) {
|
||||||
|
|
|
@ -24,7 +24,7 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Services;
|
namespace App\Services;
|
||||||
|
|
||||||
use App\Entity\Base\StructuralDBElement;
|
use App\Entity\Base\AbstractStructuralDBElement;
|
||||||
use Symfony\Bundle\MakerBundle\Str;
|
use Symfony\Bundle\MakerBundle\Str;
|
||||||
use function count;
|
use function count;
|
||||||
use Doctrine\ORM\EntityManagerInterface;
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
|
@ -54,17 +54,17 @@ class EntityImporter
|
||||||
*
|
*
|
||||||
* @param string $lines The list of names seperated by \n
|
* @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 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
|
* @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:
|
//Expand every line to a single entry:
|
||||||
$names = explode("\n", $lines);
|
$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!');
|
throw new InvalidArgumentException('$class_name must be a StructuralDBElement type!');
|
||||||
}
|
}
|
||||||
if (null !== $parent && ! is_a($parent, $class_name)) {
|
if (null !== $parent && ! is_a($parent, $class_name)) {
|
||||||
|
@ -80,7 +80,7 @@ class EntityImporter
|
||||||
//Skip empty lines (StrucuralDBElements must have a name)
|
//Skip empty lines (StrucuralDBElements must have a name)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
/** @var StructuralDBElement $entity */
|
/** @var AbstractStructuralDBElement $entity */
|
||||||
//Create new element with given name
|
//Create new element with given name
|
||||||
$entity = new $class_name();
|
$entity = new $class_name();
|
||||||
$entity->setName($name);
|
$entity->setName($name);
|
||||||
|
@ -126,7 +126,7 @@ class EntityImporter
|
||||||
|
|
||||||
//Iterate over each $entity write it to DB.
|
//Iterate over each $entity write it to DB.
|
||||||
foreach ($entities as $entity) {
|
foreach ($entities as $entity) {
|
||||||
/** @var StructuralDBElement $entity */
|
/** @var AbstractStructuralDBElement $entity */
|
||||||
//Move every imported entity to the selected parent
|
//Move every imported entity to the selected parent
|
||||||
$entity->setParent($options['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)
|
//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);
|
$this->correctParentEntites($entities, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -211,12 +211,12 @@ class EntityImporter
|
||||||
* This functions corrects the parent setting based on the children value of the parent.
|
* 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 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
|
protected function correctParentEntites(iterable $entities, $parent = null): void
|
||||||
{
|
{
|
||||||
foreach ($entities as $entity) {
|
foreach ($entities as $entity) {
|
||||||
/** @var StructuralDBElement $entity */
|
/** @var AbstractStructuralDBElement $entity */
|
||||||
$entity->setParent($parent);
|
$entity->setParent($parent);
|
||||||
//Do the same for the children of entity
|
//Do the same for the children of entity
|
||||||
$this->correctParentEntites($entity->getChildren(), $entity);
|
$this->correctParentEntites($entity->getChildren(), $entity);
|
||||||
|
|
|
@ -26,7 +26,7 @@ namespace App\Services;
|
||||||
|
|
||||||
use App\Entity\Attachments\Attachment;
|
use App\Entity\Attachments\Attachment;
|
||||||
use App\Entity\Attachments\AttachmentType;
|
use App\Entity\Attachments\AttachmentType;
|
||||||
use App\Entity\Base\DBElement;
|
use App\Entity\Base\AbstractDBElement;
|
||||||
use App\Entity\Devices\Device;
|
use App\Entity\Devices\Device;
|
||||||
use App\Entity\Parts\Category;
|
use App\Entity\Parts\Category;
|
||||||
use App\Entity\Parts\Footprint;
|
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.
|
* 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
|
* @return string The URL to the info page
|
||||||
*
|
*
|
||||||
* @throws EntityNotSupportedException If the method is not supported for the given Entity
|
* @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 = [
|
$map = [
|
||||||
Part::class => 'part_info',
|
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
|
* Generates an URL to a page, where a new entity can be created, that has the same informations as the
|
||||||
* given entity (element cloning).
|
* 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
|
* @return string the URL to the page
|
||||||
*
|
*
|
||||||
* @throws EntityNotSupportedException If the method is not supported for the given Entity
|
* @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 = [
|
$map = [
|
||||||
Part::class => 'part_clone',
|
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.
|
* 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
|
* @return string the URL to the page
|
||||||
*
|
*
|
||||||
* @throws EntityNotSupportedException If the method is not supported for the given Entity
|
* @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 = [
|
$map = [
|
||||||
Category::class => 'part_list_category',
|
Category::class => 'part_list_category',
|
||||||
|
@ -260,7 +260,7 @@ class EntityURLGenerator
|
||||||
return $this->urlGenerator->generate($this->mapToController($map, $entity), ['id' => $entity->getID()]);
|
return $this->urlGenerator->generate($this->mapToController($map, $entity), ['id' => $entity->getID()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function deleteURL(DBElement $entity): string
|
public function deleteURL(AbstractDBElement $entity): string
|
||||||
{
|
{
|
||||||
$map = [
|
$map = [
|
||||||
Part::class => 'part_delete',
|
Part::class => 'part_delete',
|
||||||
|
|
|
@ -24,7 +24,7 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Services;
|
namespace App\Services;
|
||||||
|
|
||||||
use App\Entity\Base\StructuralDBElement;
|
use App\Entity\Base\AbstractStructuralDBElement;
|
||||||
use Doctrine\ORM\EntityManagerInterface;
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
|
|
||||||
class StructuralElementRecursionHelper
|
class StructuralElementRecursionHelper
|
||||||
|
@ -39,7 +39,7 @@ class StructuralElementRecursionHelper
|
||||||
/**
|
/**
|
||||||
* Executes an function (callable) recursivly for $element and every of its children.
|
* 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.
|
* @param callable $func The function which should be executed for each element.
|
||||||
* $func has the signature function(StructuralDBElement $element) : void
|
* $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
|
* @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.
|
* @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.
|
* 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
|
//Cancel if we reached our maximal allowed level. Must be zero because -1 is infinity levels
|
||||||
if (0 === $max_depth) {
|
if (0 === $max_depth) {
|
||||||
|
@ -75,15 +75,15 @@ class StructuralElementRecursionHelper
|
||||||
/**
|
/**
|
||||||
* Deletes the $element and all its subelements recursivly.
|
* 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
|
* @param bool $flush When set to true the changes will also be flushed to DB. Set to false if you want to flush
|
||||||
* later.
|
* later.
|
||||||
*/
|
*/
|
||||||
public function delete(StructuralDBElement $element, bool $flush = true): void
|
public function delete(AbstractStructuralDBElement $element, bool $flush = true): void
|
||||||
{
|
{
|
||||||
$em = $this->em;
|
$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);
|
$em->remove($element);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,7 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Services\Trees;
|
namespace App\Services\Trees;
|
||||||
|
|
||||||
use App\Entity\Base\StructuralDBElement;
|
use App\Entity\Base\AbstractStructuralDBElement;
|
||||||
use App\Repository\StructuralDBElementRepository;
|
use App\Repository\StructuralDBElementRepository;
|
||||||
use App\Services\UserCacheKeyGenerator;
|
use App\Services\UserCacheKeyGenerator;
|
||||||
use Doctrine\ORM\EntityManagerInterface;
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
|
@ -52,11 +52,11 @@ class NodesListBuilder
|
||||||
* In difference to the Repository Function, the results here are cached.
|
* 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 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';
|
$parent_id = null !== $parent ? $parent->getID() : '0';
|
||||||
// Backslashes are not allowed in cache keys
|
// Backslashes are not allowed in cache keys
|
||||||
|
|
|
@ -24,9 +24,9 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Services\Trees;
|
namespace App\Services\Trees;
|
||||||
|
|
||||||
use App\Entity\Base\DBElement;
|
use App\Entity\Base\AbstractDBElement;
|
||||||
use App\Entity\Base\NamedDBElement;
|
use App\Entity\Base\AbstractNamedDBElement;
|
||||||
use App\Entity\Base\StructuralDBElement;
|
use App\Entity\Base\AbstractStructuralDBElement;
|
||||||
use App\Helpers\Trees\TreeViewNode;
|
use App\Helpers\Trees\TreeViewNode;
|
||||||
use App\Helpers\Trees\TreeViewNodeIterator;
|
use App\Helpers\Trees\TreeViewNodeIterator;
|
||||||
use App\Repository\StructuralDBElementRepository;
|
use App\Repository\StructuralDBElementRepository;
|
||||||
|
@ -59,14 +59,14 @@ class TreeViewGenerator
|
||||||
* Gets a TreeView list for the entities of the given class.
|
* Gets a TreeView list for the entities of the given class.
|
||||||
*
|
*
|
||||||
* @param string $class The class for which the treeView should be generated
|
* @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).
|
* @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.
|
* 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.
|
* @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 = [];
|
$head = [];
|
||||||
|
|
||||||
|
@ -115,13 +115,13 @@ class TreeViewGenerator
|
||||||
* The treeview is generic, that means the href are null and ID values are set.
|
* 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 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[]
|
* @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!');
|
throw new \InvalidArgumentException('$class must be a class string that implements StructuralDBElement or NamedDBElement!');
|
||||||
}
|
}
|
||||||
if (null !== $parent && ! is_a($parent, $class)) {
|
if (null !== $parent && ! is_a($parent, $class)) {
|
||||||
|
|
|
@ -24,7 +24,7 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Twig;
|
namespace App\Twig;
|
||||||
|
|
||||||
use App\Entity\Base\DBElement;
|
use App\Entity\Base\AbstractDBElement;
|
||||||
use App\Entity\Parts\MeasurementUnit;
|
use App\Entity\Parts\MeasurementUnit;
|
||||||
use App\Entity\PriceInformations\Currency;
|
use App\Entity\PriceInformations\Currency;
|
||||||
use App\Services\AmountFormatter;
|
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);
|
$tree = $this->treeBuilder->getTreeView(\get_class($element), null, $type, $element);
|
||||||
|
|
||||||
|
@ -128,7 +128,7 @@ class AppExtension extends AbstractExtension
|
||||||
return implode('/', $parts);
|
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);
|
return $this->entityURLGenerator->getURL($entity, $method);
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,7 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Validator\Constraints;
|
namespace App\Validator\Constraints;
|
||||||
|
|
||||||
use App\Entity\Base\StructuralDBElement;
|
use App\Entity\Base\AbstractStructuralDBElement;
|
||||||
use Symfony\Component\Form\Exception\UnexpectedTypeException;
|
use Symfony\Component\Form\Exception\UnexpectedTypeException;
|
||||||
use Symfony\Component\Validator\Constraint;
|
use Symfony\Component\Validator\Constraint;
|
||||||
use Symfony\Component\Validator\ConstraintValidator;
|
use Symfony\Component\Validator\ConstraintValidator;
|
||||||
|
@ -54,14 +54,14 @@ class NoneOfItsChildrenValidator extends ConstraintValidator
|
||||||
}
|
}
|
||||||
|
|
||||||
//Check type of value. Validating only works for StructuralDBElements
|
//Check type of value. Validating only works for StructuralDBElements
|
||||||
if (! $value instanceof StructuralDBElement) {
|
if (! $value instanceof AbstractStructuralDBElement) {
|
||||||
throw new UnexpectedValueException($value, 'StructuralDBElement');
|
throw new UnexpectedValueException($value, 'StructuralDBElement');
|
||||||
}
|
}
|
||||||
|
|
||||||
//Check if the object is assigned to itself
|
//Check if the object is assigned to itself
|
||||||
/** @var StructuralDBElement $entity */
|
/** @var AbstractStructuralDBElement $entity */
|
||||||
$entity = $this->context->getObject();
|
$entity = $this->context->getObject();
|
||||||
/** @var StructuralDBElement $value */
|
/** @var AbstractStructuralDBElement $value */
|
||||||
|
|
||||||
// Check if the targeted parent is the object itself:
|
// Check if the targeted parent is the object itself:
|
||||||
$entity_id = $entity->getID();
|
$entity_id = $entity->getID();
|
||||||
|
|
|
@ -24,7 +24,7 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Validator\Constraints;
|
namespace App\Validator\Constraints;
|
||||||
|
|
||||||
use App\Entity\Base\StructuralDBElement;
|
use App\Entity\Base\AbstractStructuralDBElement;
|
||||||
use Symfony\Component\Form\Exception\UnexpectedTypeException;
|
use Symfony\Component\Form\Exception\UnexpectedTypeException;
|
||||||
use Symfony\Component\Validator\Constraint;
|
use Symfony\Component\Validator\Constraint;
|
||||||
use Symfony\Component\Validator\ConstraintValidator;
|
use Symfony\Component\Validator\ConstraintValidator;
|
||||||
|
@ -54,7 +54,7 @@ class SelectableValidator extends ConstraintValidator
|
||||||
}
|
}
|
||||||
|
|
||||||
//Check type of value. Validating only works for StructuralDBElements
|
//Check type of value. Validating only works for StructuralDBElements
|
||||||
if (! $value instanceof StructuralDBElement) {
|
if (! $value instanceof AbstractStructuralDBElement) {
|
||||||
throw new UnexpectedValueException($value, 'StructuralDBElement');
|
throw new UnexpectedValueException($value, 'StructuralDBElement');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,8 +25,8 @@ declare(strict_types=1);
|
||||||
namespace App\Tests\Services;
|
namespace App\Tests\Services;
|
||||||
|
|
||||||
use App\Entity\Attachments\PartAttachment;
|
use App\Entity\Attachments\PartAttachment;
|
||||||
use App\Entity\Base\DBElement;
|
use App\Entity\Base\AbstractDBElement;
|
||||||
use App\Entity\Base\NamedDBElement;
|
use App\Entity\Base\AbstractNamedDBElement;
|
||||||
use App\Entity\Parts\Category;
|
use App\Entity\Parts\Category;
|
||||||
use App\Entity\Parts\Part;
|
use App\Entity\Parts\Part;
|
||||||
use App\Exceptions\EntityNotSupportedException;
|
use App\Exceptions\EntityNotSupportedException;
|
||||||
|
@ -64,7 +64,7 @@ class ElementTypeNameGeneratorTest extends WebTestCase
|
||||||
|
|
||||||
//Test exception for unknpwn type
|
//Test exception for unknpwn type
|
||||||
$this->expectException(EntityNotSupportedException::class);
|
$this->expectException(EntityNotSupportedException::class);
|
||||||
$this->service->getLocalizedTypeLabel(new class() extends DBElement {
|
$this->service->getLocalizedTypeLabel(new class() extends AbstractDBElement {
|
||||||
public function getIDString(): string
|
public function getIDString(): string
|
||||||
{
|
{
|
||||||
return 'Stub';
|
return 'Stub';
|
||||||
|
@ -83,7 +83,7 @@ class ElementTypeNameGeneratorTest extends WebTestCase
|
||||||
|
|
||||||
//Test exception
|
//Test exception
|
||||||
$this->expectException(EntityNotSupportedException::class);
|
$this->expectException(EntityNotSupportedException::class);
|
||||||
$this->service->getTypeNameCombination(new class() extends NamedDBElement {
|
$this->service->getTypeNameCombination(new class() extends AbstractNamedDBElement {
|
||||||
public function getIDString(): string
|
public function getIDString(): string
|
||||||
{
|
{
|
||||||
return 'Stub';
|
return 'Stub';
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue