diff --git a/src/Controller/AdminPages/AttachmentTypeController.php b/src/Controller/AdminPages/AttachmentTypeController.php index d9585a2d..25341828 100644 --- a/src/Controller/AdminPages/AttachmentTypeController.php +++ b/src/Controller/AdminPages/AttachmentTypeController.php @@ -53,11 +53,15 @@ class AttachmentTypeController extends BaseAdminController protected $entity_class = AttachmentType::class; protected $twig_template = 'AdminPages/AttachmentTypeAdmin.html.twig'; protected $form_class = BaseEntityAdminForm::class; - protected $route_base = "attachment_type"; + protected $route_base = 'attachment_type'; /** * @Route("/{id}/edit", requirements={"id"="\d+"}, name="attachment_type_edit") * @Route("/{id}/", requirements={"id"="\d+"}) + * @param AttachmentType $entity + * @param Request $request + * @param EntityManagerInterface $em + * @return Response */ public function edit(AttachmentType $entity, Request $request, EntityManagerInterface $em) { @@ -68,7 +72,10 @@ class AttachmentTypeController extends BaseAdminController * @Route("/new", name="attachment_type_new") * @Route("/") * - * @return \Symfony\Component\HttpFoundation\Response + * @param Request $request + * @param EntityManagerInterface $em + * @param EntityImporter $importer + * @return Response */ public function new(Request $request, EntityManagerInterface $em, EntityImporter $importer) { @@ -77,6 +84,10 @@ class AttachmentTypeController extends BaseAdminController /** * @Route("/{id}", name="attachment_type_delete", methods={"DELETE"}) + * @param Request $request + * @param AttachmentType $entity + * @param StructuralElementRecursionHelper $recursionHelper + * @return \Symfony\Component\HttpFoundation\RedirectResponse */ public function delete(Request $request, AttachmentType $entity, StructuralElementRecursionHelper $recursionHelper) { @@ -86,7 +97,6 @@ class AttachmentTypeController extends BaseAdminController /** * @Route("/export", name="attachment_type_export_all") * @param Request $request - * @param SerializerInterface $serializer * @param EntityManagerInterface $em * @return Response */ @@ -99,6 +109,7 @@ class AttachmentTypeController extends BaseAdminController * @Route("/{id}/export", name="attachment_type_export") * @param Request $request * @param AttachmentType $entity + * @return Response */ public function exportEntity(AttachmentType $entity, EntityExporter $exporter, Request $request) { diff --git a/src/Controller/AdminPages/BaseAdminController.php b/src/Controller/AdminPages/BaseAdminController.php index fe04cda0..2b48c0a6 100644 --- a/src/Controller/AdminPages/BaseAdminController.php +++ b/src/Controller/AdminPages/BaseAdminController.php @@ -33,7 +33,6 @@ namespace App\Controller\AdminPages; use App\Entity\Base\NamedDBElement; use App\Entity\Base\StructuralDBElement; -use App\Form\AdminPages\BaseEntityAdminForm; use App\Form\AdminPages\ImportType; use App\Form\AdminPages\MassCreationForm; use App\Services\EntityExporter; @@ -48,14 +47,14 @@ use Symfony\Component\Validator\ConstraintViolationList; abstract class BaseAdminController extends AbstractController { - protected $entity_class = ""; - protected $form_class = ""; - protected $twig_template = ""; - protected $route_base = ""; + protected $entity_class = ''; + protected $form_class = ''; + protected $twig_template = ''; + protected $route_base = ''; public function __construct() { - if ($this->entity_class === "" || $this->form_class === "" || $this->twig_template === "" || $this->route_base === "") { + if ($this->entity_class === '' || $this->form_class === '' || $this->twig_template === '' || $this->route_base === '') { throw new \InvalidArgumentException('You have to override the $entity_class, $form_class, $route_base and $twig_template value in your subclasss!'); } } @@ -115,7 +114,7 @@ abstract class BaseAdminController extends AbstractController foreach ($errors as $name => $error) { /** @var $error ConstraintViolationList */ - $this->addFlash('error', $name . ":" . $error); + $this->addFlash('error', $name . ':' . $error); } } @@ -134,7 +133,7 @@ abstract class BaseAdminController extends AbstractController //Show errors to user: foreach ($errors as $name => $error) { /** @var $error ConstraintViolationList */ - $this->addFlash('error', $name . ":" . $error); + $this->addFlash('error', $name . ':' . $error); } } diff --git a/src/Controller/AdminPages/CategoryController.php b/src/Controller/AdminPages/CategoryController.php index 11098663..468272ee 100644 --- a/src/Controller/AdminPages/CategoryController.php +++ b/src/Controller/AdminPages/CategoryController.php @@ -34,7 +34,6 @@ namespace App\Controller\AdminPages; use App\Entity\Attachments\AttachmentType; use App\Entity\Parts\Category; -use App\Form\AdminPages\BaseEntityAdminForm; use App\Form\AdminPages\CategoryAdminForm; use App\Services\EntityExporter; use App\Services\EntityImporter; @@ -55,11 +54,15 @@ class CategoryController extends BaseAdminController protected $entity_class = Category::class; protected $twig_template = 'AdminPages/CategoryAdmin.html.twig'; protected $form_class = CategoryAdminForm::class; - protected $route_base = "category"; + protected $route_base = 'category'; /** * @Route("/{id}/edit", requirements={"id"="\d+"}, name="category_edit") * @Route("/{id}/", requirements={"id"="\d+"}) + * @param Category $entity + * @param Request $request + * @param EntityManagerInterface $em + * @return Response */ public function edit(Category $entity, Request $request, EntityManagerInterface $em) { @@ -70,7 +73,10 @@ class CategoryController extends BaseAdminController * @Route("/new", name="category_new") * @Route("/") * - * @return \Symfony\Component\HttpFoundation\Response + * @param Request $request + * @param EntityManagerInterface $em + * @param EntityImporter $importer + * @return Response */ public function new(Request $request, EntityManagerInterface $em, EntityImporter $importer) { @@ -79,6 +85,10 @@ class CategoryController extends BaseAdminController /** * @Route("/{id}", name="category_delete", methods={"DELETE"}) + * @param Request $request + * @param Category $entity + * @param StructuralElementRecursionHelper $recursionHelper + * @return \Symfony\Component\HttpFoundation\RedirectResponse */ public function delete(Request $request, Category $entity, StructuralElementRecursionHelper $recursionHelper) { @@ -87,9 +97,9 @@ class CategoryController extends BaseAdminController /** * @Route("/export", name="category_export_all") - * @param Request $request - * @param SerializerInterface $serializer * @param EntityManagerInterface $em + * @param EntityExporter $exporter + * @param Request $request * @return Response */ public function exportAll(EntityManagerInterface $em, EntityExporter $exporter, Request $request) @@ -99,8 +109,10 @@ class CategoryController extends BaseAdminController /** * @Route("/{id}/export", name="category_export") + * @param Category $entity + * @param EntityExporter $exporter * @param Request $request - * @param AttachmentType $entity + * @return Response */ public function exportEntity(Category $entity, EntityExporter $exporter, Request $request) { diff --git a/src/Controller/AdminPages/CurrencyController.php b/src/Controller/AdminPages/CurrencyController.php index 8702c147..a95b5218 100644 --- a/src/Controller/AdminPages/CurrencyController.php +++ b/src/Controller/AdminPages/CurrencyController.php @@ -33,10 +33,7 @@ namespace App\Controller\AdminPages; use App\Entity\Attachments\AttachmentType; -use App\Entity\Parts\Category; use App\Entity\PriceInformations\Currency; -use App\Form\AdminPages\BaseEntityAdminForm; -use App\Form\AdminPages\CategoryAdminForm; use App\Form\AdminPages\CurrencyAdminForm; use App\Services\EntityExporter; use App\Services\EntityImporter; @@ -58,11 +55,15 @@ class CurrencyController extends BaseAdminController protected $entity_class = Currency::class; protected $twig_template = 'AdminPages/CurrencyAdmin.html.twig'; protected $form_class = CurrencyAdminForm::class; - protected $route_base = "currency"; + protected $route_base = 'currency'; /** * @Route("/{id}/edit", requirements={"id"="\d+"}, name="currency_edit") * @Route("/{id}/", requirements={"id"="\d+"}) + * @param Currency $entity + * @param Request $request + * @param EntityManagerInterface $em + * @return Response */ public function edit(Currency $entity, Request $request, EntityManagerInterface $em) { @@ -73,7 +74,10 @@ class CurrencyController extends BaseAdminController * @Route("/new", name="currency_new") * @Route("/") * - * @return \Symfony\Component\HttpFoundation\Response + * @param Request $request + * @param EntityManagerInterface $em + * @param EntityImporter $importer + * @return Response */ public function new(Request $request, EntityManagerInterface $em, EntityImporter $importer) { @@ -82,6 +86,10 @@ class CurrencyController extends BaseAdminController /** * @Route("/{id}", name="currency_delete", methods={"DELETE"}) + * @param Request $request + * @param Currency $entity + * @param StructuralElementRecursionHelper $recursionHelper + * @return \Symfony\Component\HttpFoundation\RedirectResponse */ public function delete(Request $request, Currency $entity, StructuralElementRecursionHelper $recursionHelper) { @@ -90,9 +98,9 @@ class CurrencyController extends BaseAdminController /** * @Route("/export", name="currency_export_all") - * @param Request $request - * @param SerializerInterface $serializer * @param EntityManagerInterface $em + * @param EntityExporter $exporter + * @param Request $request * @return Response */ public function exportAll(EntityManagerInterface $em, EntityExporter $exporter, Request $request) @@ -102,8 +110,10 @@ class CurrencyController extends BaseAdminController /** * @Route("/{id}/export", name="currency_export") + * @param Currency $entity + * @param EntityExporter $exporter * @param Request $request - * @param AttachmentType $entity + * @return Response */ public function exportEntity(Currency $entity, EntityExporter $exporter, Request $request) { diff --git a/src/Controller/AdminPages/DeviceController.php b/src/Controller/AdminPages/DeviceController.php index 06d15fd2..02820efd 100644 --- a/src/Controller/AdminPages/DeviceController.php +++ b/src/Controller/AdminPages/DeviceController.php @@ -55,11 +55,15 @@ class DeviceController extends BaseAdminController protected $entity_class = Device::class; protected $twig_template = 'AdminPages/DeviceAdmin.html.twig'; protected $form_class = BaseEntityAdminForm::class; - protected $route_base = "device"; + protected $route_base = 'device'; /** * @Route("/{id}/edit", requirements={"id"="\d+"}, name="device_edit") * @Route("/{id}/", requirements={"id"="\d+"}) + * @param Device $entity + * @param Request $request + * @param EntityManagerInterface $em + * @return Response */ public function edit(Device $entity, Request $request, EntityManagerInterface $em) { @@ -70,7 +74,10 @@ class DeviceController extends BaseAdminController * @Route("/new", name="device_new") * @Route("/") * - * @return \Symfony\Component\HttpFoundation\Response + * @param Request $request + * @param EntityManagerInterface $em + * @param EntityImporter $importer + * @return Response */ public function new(Request $request, EntityManagerInterface $em, EntityImporter $importer) { @@ -79,6 +86,10 @@ class DeviceController extends BaseAdminController /** * @Route("/{id}", name="device_delete", methods={"DELETE"}) + * @param Request $request + * @param Device $entity + * @param StructuralElementRecursionHelper $recursionHelper + * @return \Symfony\Component\HttpFoundation\RedirectResponse */ public function delete(Request $request, Device $entity, StructuralElementRecursionHelper $recursionHelper) { @@ -87,9 +98,9 @@ class DeviceController extends BaseAdminController /** * @Route("/export", name="device_export_all") - * @param Request $request - * @param SerializerInterface $serializer * @param EntityManagerInterface $em + * @param EntityExporter $exporter + * @param Request $request * @return Response */ public function exportAll(EntityManagerInterface $em, EntityExporter $exporter, Request $request) @@ -99,8 +110,10 @@ class DeviceController extends BaseAdminController /** * @Route("/{id}/export", name="device_export") + * @param Device $entity + * @param EntityExporter $exporter * @param Request $request - * @param AttachmentType $entity + * @return Response */ public function exportEntity(Device $entity, EntityExporter $exporter, Request $request) { diff --git a/src/Controller/AdminPages/FootprintController.php b/src/Controller/AdminPages/FootprintController.php index 666980c2..903e42a0 100644 --- a/src/Controller/AdminPages/FootprintController.php +++ b/src/Controller/AdminPages/FootprintController.php @@ -55,7 +55,7 @@ class FootprintController extends BaseAdminController protected $entity_class = Footprint::class; protected $twig_template = 'AdminPages/FootprintAdmin.html.twig'; protected $form_class = BaseEntityAdminForm::class; - protected $route_base = "footprint"; + protected $route_base = 'footprint'; /** * @Route("/{id}/edit", requirements={"id"="\d+"}, name="footprint_edit") @@ -70,7 +70,7 @@ class FootprintController extends BaseAdminController * @Route("/new", name="footprint_new") * @Route("/") * - * @return \Symfony\Component\HttpFoundation\Response + * @return Response */ public function new(Request $request, EntityManagerInterface $em, EntityImporter $importer) { @@ -101,6 +101,7 @@ class FootprintController extends BaseAdminController * @Route("/{id}/export", name="footprint_export") * @param Request $request * @param AttachmentType $entity + * @return Response */ public function exportEntity(AttachmentType $entity, EntityExporter $exporter, Request $request) { diff --git a/src/Controller/AdminPages/ManufacturerController.php b/src/Controller/AdminPages/ManufacturerController.php index 6e4f4aba..5f23c13e 100644 --- a/src/Controller/AdminPages/ManufacturerController.php +++ b/src/Controller/AdminPages/ManufacturerController.php @@ -32,11 +32,8 @@ namespace App\Controller\AdminPages; -use App\Entity\Attachments\AttachmentType; - use App\Entity\Parts\Manufacturer; use App\Entity\Parts\Supplier; -use App\Form\AdminPages\BaseEntityAdminForm; use App\Form\AdminPages\CompanyForm; use App\Services\EntityExporter; use App\Services\EntityImporter; @@ -72,7 +69,7 @@ class ManufacturerController extends BaseAdminController * @Route("/new", name="manufacturer_new") * @Route("/") * - * @return \Symfony\Component\HttpFoundation\Response + * @return Response */ public function new(Request $request, EntityManagerInterface $em, EntityImporter $importer) { @@ -103,6 +100,7 @@ class ManufacturerController extends BaseAdminController * @Route("/{id}/export", name="manufacturer_export") * @param Request $request * @param Supplier $entity + * @return Response */ public function exportEntity(Manufacturer $entity, EntityExporter $exporter, Request $request) { diff --git a/src/Controller/AdminPages/MeasurementUnitController.php b/src/Controller/AdminPages/MeasurementUnitController.php index 86f8f49b..ee63d71d 100644 --- a/src/Controller/AdminPages/MeasurementUnitController.php +++ b/src/Controller/AdminPages/MeasurementUnitController.php @@ -34,7 +34,6 @@ namespace App\Controller\AdminPages; use App\Entity\Attachments\AttachmentType; use App\Entity\Parts\MeasurementUnit; -use App\Form\AdminPages\BaseEntityAdminForm; use App\Form\AdminPages\MeasurementUnitAdminForm; use App\Services\EntityExporter; use App\Services\EntityImporter; @@ -55,7 +54,7 @@ class MeasurementUnitController extends BaseAdminController protected $entity_class = MeasurementUnit::class; protected $twig_template = 'AdminPages/MeasurementUnitAdmin.html.twig'; protected $form_class = MeasurementUnitAdminForm::class; - protected $route_base = "measurement_unit"; + protected $route_base = 'measurement_unit'; /** * @Route("/{id}/edit", requirements={"id"="\d+"}, name="measurement_unit_edit") @@ -70,7 +69,7 @@ class MeasurementUnitController extends BaseAdminController * @Route("/new", name="measurement_unit_new") * @Route("/") * - * @return \Symfony\Component\HttpFoundation\Response + * @return Response */ public function new(Request $request, EntityManagerInterface $em, EntityImporter $importer) { @@ -101,6 +100,7 @@ class MeasurementUnitController extends BaseAdminController * @Route("/{id}/export", name="measurement_unit_export") * @param Request $request * @param AttachmentType $entity + * @return Response */ public function exportEntity(AttachmentType $entity, EntityExporter $exporter, Request $request) { diff --git a/src/Controller/AdminPages/StorelocationController.php b/src/Controller/AdminPages/StorelocationController.php index 5e28b001..be6fb869 100644 --- a/src/Controller/AdminPages/StorelocationController.php +++ b/src/Controller/AdminPages/StorelocationController.php @@ -34,7 +34,6 @@ namespace App\Controller\AdminPages; use App\Entity\Attachments\AttachmentType; use App\Entity\Parts\Storelocation; -use App\Form\AdminPages\BaseEntityAdminForm; use App\Form\AdminPages\StorelocationAdminForm; use App\Services\EntityExporter; use App\Services\EntityImporter; @@ -42,7 +41,6 @@ use App\Services\StructuralElementRecursionHelper; use Doctrine\ORM\EntityManagerInterface; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\HttpKernel\HttpCache\Store; use Symfony\Component\Routing\Annotation\Route; use Symfony\Component\Serializer\SerializerInterface; @@ -56,7 +54,7 @@ class StorelocationController extends BaseAdminController protected $entity_class = Storelocation::class; protected $twig_template = 'AdminPages/StorelocationAdmin.html.twig'; protected $form_class = StorelocationAdminForm::class; - protected $route_base = "store_location"; + protected $route_base = 'store_location'; /** * @Route("/{id}/edit", requirements={"id"="\d+"}, name="store_location_edit") @@ -71,7 +69,7 @@ class StorelocationController extends BaseAdminController * @Route("/new", name="store_location_new") * @Route("/") * - * @return \Symfony\Component\HttpFoundation\Response + * @return Response */ public function new(Request $request, EntityManagerInterface $em, EntityImporter $importer) { @@ -102,6 +100,7 @@ class StorelocationController extends BaseAdminController * @Route("/{id}/export", name="store_location_export") * @param Request $request * @param AttachmentType $entity + * @return Response */ public function exportEntity(Storelocation $entity, EntityExporter $exporter, Request $request) { diff --git a/src/Controller/AdminPages/SupplierController.php b/src/Controller/AdminPages/SupplierController.php index 82f371a3..86d42eea 100644 --- a/src/Controller/AdminPages/SupplierController.php +++ b/src/Controller/AdminPages/SupplierController.php @@ -32,11 +32,7 @@ namespace App\Controller\AdminPages; -use App\Entity\Attachments\AttachmentType; - use App\Entity\Parts\Supplier; -use App\Form\AdminPages\BaseEntityAdminForm; -use App\Form\AdminPages\CompanyForm; use App\Form\AdminPages\SupplierForm; use App\Services\EntityExporter; use App\Services\EntityImporter; @@ -57,7 +53,7 @@ class SupplierController extends BaseAdminController protected $entity_class = Supplier::class; protected $twig_template = 'AdminPages/SupplierAdmin.html.twig'; protected $form_class = SupplierForm::class; - protected $route_base = "supplier"; + protected $route_base = 'supplier'; /** * @Route("/{id}/edit", requirements={"id"="\d+"}, name="supplier_edit") @@ -72,7 +68,7 @@ class SupplierController extends BaseAdminController * @Route("/new", name="supplier_new") * @Route("/") * - * @return \Symfony\Component\HttpFoundation\Response + * @return Response */ public function new(Request $request, EntityManagerInterface $em, EntityImporter $importer) { @@ -103,6 +99,7 @@ class SupplierController extends BaseAdminController * @Route("/{id}/export", name="supplier_export") * @param Request $request * @param Supplier $entity + * @return Response */ public function exportEntity(Supplier $entity, EntityExporter $exporter, Request $request) { diff --git a/src/Controller/AttachmentFileController.php b/src/Controller/AttachmentFileController.php index c7b17bbc..bdaf1ebc 100644 --- a/src/Controller/AttachmentFileController.php +++ b/src/Controller/AttachmentFileController.php @@ -47,17 +47,20 @@ class AttachmentFileController extends AbstractController * * @Route("/attachment/{id}/download", name="attachment_download") * @param Attachment $attachment + * @param AttachmentHelper $helper + * @return BinaryFileResponse + * @throws \Exception */ public function download(Attachment $attachment, AttachmentHelper $helper) { - $this->denyAccessUnlessGranted("read", $attachment); + $this->denyAccessUnlessGranted('read', $attachment); if ($attachment->isExternal()) { - throw new \Exception("You can not download external attachments!"); + throw new \RuntimeException('You can not download external attachments!'); } if (!$helper->isFileExisting($attachment)) { - throw new \Exception("The file associated with the attachment is not existing!"); + throw new \RuntimeException('The file associated with the attachment is not existing!'); } @@ -75,17 +78,20 @@ class AttachmentFileController extends AbstractController * * @Route("/attachment/{id}/view", name="attachment_view") * @param Attachment $attachment + * @param AttachmentHelper $helper + * @return BinaryFileResponse + * @throws \Exception */ public function view(Attachment $attachment, AttachmentHelper $helper) { - $this->denyAccessUnlessGranted("read", $attachment); + $this->denyAccessUnlessGranted('read', $attachment); if ($attachment->isExternal()) { - throw new \Exception("You can not download external attachments!"); + throw new \RuntimeException('You can not download external attachments!'); } if (!$helper->isFileExisting($attachment)) { - throw new \Exception("The file associated with the attachment is not existing!"); + throw new \RuntimeException('The file associated with the attachment is not existing!'); } diff --git a/src/Controller/PartController.php b/src/Controller/PartController.php index 4f34a4c6..c04c6174 100644 --- a/src/Controller/PartController.php +++ b/src/Controller/PartController.php @@ -33,7 +33,6 @@ namespace App\Controller; use App\Entity\Parts\Category; use App\Entity\Parts\Part; use App\Form\Part\PartBaseType; -use App\Services\AttachmentFilenameService; use App\Services\AttachmentHelper; use Doctrine\ORM\EntityManagerInterface; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; @@ -46,6 +45,9 @@ class PartController extends AbstractController /** * @Route("/part/{id}/info", name="part_info") * @Route("/part/{id}", requirements={"id"="\d+"}) + * @param Part $part + * @param AttachmentHelper $attachmentHelper + * @return \Symfony\Component\HttpFoundation\Response */ public function show(Part $part, AttachmentHelper $attachmentHelper) { @@ -64,6 +66,8 @@ class PartController extends AbstractController * * @param Part $part * + * @param Request $request + * @param EntityManagerInterface $em * @return \Symfony\Component\HttpFoundation\Response */ public function edit(Part $part, Request $request, EntityManagerInterface $em) @@ -89,6 +93,9 @@ class PartController extends AbstractController /** * @Route("/part/new", name="part_new") * + * @param Request $request + * @param EntityManagerInterface $em + * @param TranslatorInterface $translator * @return \Symfony\Component\HttpFoundation\Response */ public function new(Request $request, EntityManagerInterface $em, TranslatorInterface $translator) @@ -123,6 +130,11 @@ class PartController extends AbstractController /** * @Route("/part/{id}/clone", name="part_clone") + * @param Part $part + * @param Request $request + * @param EntityManagerInterface $em + * @param TranslatorInterface $translator + * @return \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response */ public function clone(Part $part, Request $request, EntityManagerInterface $em, TranslatorInterface $translator) { @@ -143,7 +155,7 @@ class PartController extends AbstractController return $this->redirectToRoute('part_edit', ['id' => $new_part->getID()]); } - return $this->render('Parts/new_part.html.twig', + return $this->render('Parts/edit/new_part.html.twig', [ 'part' => $new_part, 'form' => $form->createView(), diff --git a/src/Controller/SecurityController.php b/src/Controller/SecurityController.php index ddd59b48..3702e0ad 100644 --- a/src/Controller/SecurityController.php +++ b/src/Controller/SecurityController.php @@ -57,6 +57,6 @@ class SecurityController extends AbstractController */ public function logout() { - throw new \Exception('Will be intercepted before getting here'); + throw new \RuntimeException('Will be intercepted before getting here'); } } diff --git a/src/Controller/TreeController.php b/src/Controller/TreeController.php index 8a7d05cc..4f80ba0e 100644 --- a/src/Controller/TreeController.php +++ b/src/Controller/TreeController.php @@ -35,11 +35,9 @@ use App\Entity\Parts\Footprint; use App\Entity\Parts\Manufacturer; use App\Entity\Parts\Storelocation; use App\Entity\Parts\Supplier; -use App\Helpers\TreeViewNode; use App\Services\ToolsTreeBuilder; use App\Services\TreeBuilder; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; -use Symfony\Component\Form\Extension\Core\Type\LocaleType; use Symfony\Component\Routing\Annotation\Route; /** @@ -66,7 +64,7 @@ class TreeController extends AbstractController */ public function categoryTree(TreeBuilder $builder, Category $category = null) { - if ($category != null) { + if ($category !== null) { $tree[] = $builder->elementToTreeNode($category); } else { $tree = $builder->typeToTree(Category::class); @@ -82,7 +80,7 @@ class TreeController extends AbstractController */ public function footprintTree(TreeBuilder $builder, Footprint $footprint = null) { - if ($footprint != null) { + if ($footprint !== null) { $tree[] = $builder->elementToTreeNode($footprint); } else { $tree = $builder->typeToTree(Footprint::class, null); @@ -98,7 +96,7 @@ class TreeController extends AbstractController */ public function locationTree(TreeBuilder $builder, Storelocation $location = null) { - if ($location != null) { + if ($location !== null) { $tree[] = $builder->elementToTreeNode($location); } else { $tree = $builder->typeToTree(Storelocation::class, null); @@ -114,7 +112,7 @@ class TreeController extends AbstractController */ public function manufacturerTree(TreeBuilder $builder, Manufacturer $manufacturer = null) { - if ($manufacturer != null) { + if ($manufacturer !== null) { $tree[] = $builder->elementToTreeNode($manufacturer); } else { $tree = $builder->typeToTree(Manufacturer::class, null); @@ -130,7 +128,7 @@ class TreeController extends AbstractController */ public function supplierTree(TreeBuilder $builder, Supplier $supplier = null) { - if ($supplier != null) { + if ($supplier !== null) { $tree[] = $builder->elementToTreeNode($supplier); } else { $tree = $builder->typeToTree(Supplier::class, null); @@ -146,7 +144,7 @@ class TreeController extends AbstractController */ public function deviceTree(TreeBuilder $builder, Device $device = null) { - if ($device != null) { + if ($device !== null) { $tree[] = $builder->elementToTreeNode($device); } else { $tree = $builder->typeToTree(Device::class, null); diff --git a/src/Controller/UserController.php b/src/Controller/UserController.php index b0ed066a..17ae9705 100644 --- a/src/Controller/UserController.php +++ b/src/Controller/UserController.php @@ -30,16 +30,13 @@ namespace App\Controller; use App\Entity\Attachments\AttachmentType; -use App\Entity\Parts\Footprint; use App\Entity\UserSystem\User; -use App\Form\AdminPages\BaseEntityAdminForm; use App\Form\UserAdminForm; use App\Form\UserSettingsType; use App\Services\EntityExporter; use App\Services\EntityImporter; use App\Services\StructuralElementRecursionHelper; use Doctrine\ORM\EntityManagerInterface; -use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\Asset\Packages; use Symfony\Component\Form\Extension\Core\Type\PasswordType; use Symfony\Component\Form\Extension\Core\Type\RepeatedType; @@ -63,7 +60,7 @@ class UserController extends AdminPages\BaseAdminController protected $entity_class = User::class; protected $twig_template = 'AdminPages/UserAdmin.html.twig'; protected $form_class = UserAdminForm::class; - protected $route_base = "user"; + protected $route_base = 'user'; /** @@ -79,7 +76,7 @@ class UserController extends AdminPages\BaseAdminController * @Route("/new", name="user_new") * @Route("/") * - * @return \Symfony\Component\HttpFoundation\Response + * @return Response */ public function new(Request $request, EntityManagerInterface $em, EntityImporter $importer) { @@ -110,6 +107,7 @@ class UserController extends AdminPages\BaseAdminController * @Route("/{id}/export", name="user_export") * @param Request $request * @param AttachmentType $entity + * @return Response */ public function exportEntity(User $entity, EntityExporter $exporter, Request $request) { diff --git a/src/Entity/Attachments/Attachment.php b/src/Entity/Attachments/Attachment.php index c9eefa93..a9ac313a 100644 --- a/src/Entity/Attachments/Attachment.php +++ b/src/Entity/Attachments/Attachment.php @@ -27,7 +27,6 @@ use App\Entity\Base\DBElement; use App\Entity\Base\NamedDBElement; use App\Validator\Constraints\Selectable; use Doctrine\ORM\Mapping as ORM; -use Symfony\Component\Intl\Exception\NotImplementedException; /** * Class Attachment. @@ -114,7 +113,7 @@ abstract class Attachment extends NamedDBElement /** * Get the element, associated with this Attachement (for example a "Part" object). * - * @return DBElement The associated Element. + * @return AttachmentContainingDBElement The associated Element. */ public function getElement(): ?AttachmentContainingDBElement { @@ -260,8 +259,8 @@ abstract class Attachment extends NamedDBElement } if ($path_required) { return (bool) filter_var($string, FILTER_VALIDATE_URL, FILTER_FLAG_PATH_REQUIRED); - } else { - return (bool) filter_var($string, FILTER_VALIDATE_URL); } + + return (bool) filter_var($string, FILTER_VALIDATE_URL); } } diff --git a/src/Entity/Attachments/AttachmentContainingDBElement.php b/src/Entity/Attachments/AttachmentContainingDBElement.php index d3434161..26affaeb 100644 --- a/src/Entity/Attachments/AttachmentContainingDBElement.php +++ b/src/Entity/Attachments/AttachmentContainingDBElement.php @@ -56,7 +56,6 @@ use App\Entity\Base\NamedDBElement; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping as ORM; -use Doctrine\ORM\PersistentCollection; use Exception; /** @@ -103,11 +102,11 @@ abstract class AttachmentContainingDBElement extends NamedDBElement /** * Get all attachements of this element / Get the element's attachements with a specific type. * - * @param int $type_id * if NULL, all attachements of this element will be returned - * * if this is a number > 0, only attachements with this type ID will be returned + * @param int $type_id * if NULL, all attachements of this element will be returned + * * if this is a number > 0, only attachements with this type ID will be returned * @param bool $only_table_attachements if true, only attachements with "show_in_table == true" * - * @return Attachment[] the attachements as a one-dimensional array of Attachement objects + * @return Collection|Attachment[] the attachements as a one-dimensional array of Attachement objects * * @throws Exception if there was an error */ diff --git a/src/Entity/Attachments/AttachmentType.php b/src/Entity/Attachments/AttachmentType.php index 747d7b22..3d5d85ab 100644 --- a/src/Entity/Attachments/AttachmentType.php +++ b/src/Entity/Attachments/AttachmentType.php @@ -53,7 +53,6 @@ declare(strict_types=1); namespace App\Entity\Attachments; use App\Entity\Base\StructuralDBElement; -use App\Validator\Constraints\NoneOfItsChildren; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping as ORM; @@ -86,7 +85,7 @@ class AttachmentType extends StructuralDBElement /** * Get all attachements ("Attachement" objects) with this type. * - * @return Attachment[] all attachements with this type, as a one-dimensional array of Attachement-objects + * @return Collection|Attachment[] all attachements with this type, as a one-dimensional array of Attachement-objects * (sorted by their names) */ public function getAttachementsForType(): Collection diff --git a/src/Entity/Base/Company.php b/src/Entity/Base/Company.php index 3cc33115..b62aa62c 100644 --- a/src/Entity/Base/Company.php +++ b/src/Entity/Base/Company.php @@ -52,7 +52,6 @@ declare(strict_types=1); namespace App\Entity\Base; -use App\Entity\Base\StructuralDBElement; use Doctrine\ORM\Mapping as ORM; use Symfony\Component\Validator\Constraints as Assert; @@ -67,39 +66,39 @@ abstract class Company extends StructuralDBElement * @var string The address of the company * @ORM\Column(type="string") */ - protected $address = ""; + protected $address = ''; /** * @var string The phone number of the company * @ORM\Column(type="string") */ - protected $phone_number = ""; + protected $phone_number = ''; /** * @var string The fax number of the company * @ORM\Column(type="string") */ - protected $fax_number = ""; + protected $fax_number = ''; /** * @var string The email address of the company * @ORM\Column(type="string") * @Assert\Email() */ - protected $email_address = ""; + protected $email_address = ''; /** * @var string The website of the company * @ORM\Column(type="string") * @Assert\Url() */ - protected $website = ""; + protected $website = ''; /** * @var string * @ORM\Column(type="string") */ - protected $auto_product_url = ""; + protected $auto_product_url = ''; /******************************************************************************** * diff --git a/src/Entity/Base/StructuralDBElement.php b/src/Entity/Base/StructuralDBElement.php index a8c87b12..2aa1d0c6 100644 --- a/src/Entity/Base/StructuralDBElement.php +++ b/src/Entity/Base/StructuralDBElement.php @@ -55,10 +55,8 @@ namespace App\Entity\Base; use App\Entity\Attachments\AttachmentContainingDBElement; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\ORM\Mapping as ORM; -use Doctrine\ORM\PersistentCollection; use App\Validator\Constraints\NoneOfItsChildren; use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity; -use Symfony\Component\Serializer\Annotation\DiscriminatorMap; use Symfony\Component\Serializer\Annotation\Groups; /** @@ -102,7 +100,7 @@ abstract class StructuralDBElement extends AttachmentContainingDBElement * @ORM\Column(type="text") * @Groups({"simple", "extended", "full"}) */ - protected $comment = ""; + protected $comment = ''; /** * @var int @@ -132,6 +130,7 @@ abstract class StructuralDBElement extends AttachmentContainingDBElement public function __construct() { + parent::__construct(); $this->children = new ArrayCollection(); } @@ -154,16 +153,16 @@ abstract class StructuralDBElement extends AttachmentContainingDBElement $class_name = \get_class($this); //Check if both elements compared, are from the same type: - if ($class_name != \get_class($another_element)) { + if ($class_name !== \get_class($another_element)) { throw new \InvalidArgumentException('isChildOf() only works for objects of the same type!'); } - if (null == $this->getParent()) { // this is the root node + if (null === $this->getParent()) { // this is the root node return false; } //If this' parents element, is $another_element, then we are finished - return ($this->parent->getID() == $another_element->getID()) + return ($this->parent->getID() === $another_element->getID()) || $this->parent->isChildOf($another_element); //Otherwise, check recursivley } @@ -247,7 +246,7 @@ abstract class StructuralDBElement extends AttachmentContainingDBElement $overflow = 20; //We only allow 20 levels depth - while (null != $element->parent && $overflow >= 0) { + while (null !== $element->parent && $overflow >= 0) { $element = $element->parent; $this->full_path_strings[] = $element->getName(); //Decrement to prevent mem overflow. diff --git a/src/Entity/Parts/Category.php b/src/Entity/Parts/Category.php index a50af809..59c5b24b 100644 --- a/src/Entity/Parts/Category.php +++ b/src/Entity/Parts/Category.php @@ -83,13 +83,13 @@ class Category extends PartsContainingDBElement * @var string * @ORM\Column(type="text") */ - protected $partname_hint = ""; + protected $partname_hint = ''; /** * @var string * @ORM\Column(type="text") */ - protected $partname_regex = ""; + protected $partname_regex = ''; /** * @var bool @@ -119,13 +119,13 @@ class Category extends PartsContainingDBElement * @var string * @ORM\Column(type="text") */ - protected $default_description = ""; + protected $default_description = ''; /** * @var string * @ORM\Column(type="text") */ - protected $default_comment = ""; + protected $default_comment = ''; /** * Returns the ID as an string, defined by the element class. diff --git a/src/Entity/Parts/Footprint.php b/src/Entity/Parts/Footprint.php index d64166b3..e9e385d0 100644 --- a/src/Entity/Parts/Footprint.php +++ b/src/Entity/Parts/Footprint.php @@ -128,73 +128,14 @@ class Footprint extends PartsContainingDBElement /** * Get the filename of the 3d model (absolute path from filesystem root). - * - * @param bool $absolute If set to true, then the absolute filename (from system root) is returned. - * If set to false, then the path relative to Part-DB folder is returned. - * * @return string * the absolute path to the model (from filesystem root), as a UNIX path (with slashes) * * an empty string if there is no model */ - public function get3dFilename(bool $absolute = true): string + public function get3dFilename(): string { - if (true === $absolute) { - //TODO - throw new \Exception('Not Implemented yet...'); - //return str_replace('%BASE%', BASE, $this->db_data['filename_3d']); - } - return $this->filename_3d; } - /** - * Check if the filename of this footprint is valid (picture exists). - * - * This method is used to get all footprints with broken filename - * (Footprint::get_broken_filename_footprints()). - * - * An empty filename is a valid filename. - * - * @return bool * true if file exists or filename is empty - * * false if there is no file with this filename - */ - public function isFilenameValid(): bool - { - if (empty($this->getFilename())) { - return true; - } - - return file_exists($this->getFilename()); - } - - /** - * Check if the filename of this 3d footprint is valid (model exists and have ). - * - * This method is used to get all footprints with broken 3d filename - * (Footprint::get_broken_3d_filename_footprints()). - * - * An empty filename is a valid filename. - * - * @return bool * true if file exists or filename is empty - * * false if there is no file with this filename - */ - public function is3dFilenameValid(): bool - { - if (empty($this->get3dFilename())) { - return true; - } - - //Check if file is X3D-Model (these has .x3d extension) - if (false === strpos($this->get3dFilename(), '.x3d')) { - return false; - } - - return file_exists($this->get3dFilename()); - } - - /***************************************************************************** - * Setters - ****************************************************************************/ - /******************************************************************************** * * Setters @@ -203,25 +144,8 @@ class Footprint extends PartsContainingDBElement /** * Change the filename of this footprint. - * - * The filename won't be checked if it is valid. - * It's not really a Problem if there is no such file... - * (For this purpose we have the method Footprint::get_broken_filename_footprints()) - * - * @param string $new_filename * the new filename (absolute path from filesystem root, as a UNIX path [only slashes!] !! ) - * * see also lib.functions.php::to_unix_path() - * - * It's really important that you pass the whole (UNIX) path from filesystem root! - * If the file is located in the base directory of Part-DB, the base path - * will be automatically replaced with a placeholder before write it in the database. - * This way, the filenames are still correct if the installation directory - * of Part-DB is moved. - * - * The path-replacing will be done in Footprint::check_values_validity(), not here. - * - * @return Footprint - * - * @throws \Exception if there was an error + * @param string $new_filename The new file name + * @return Footprint */ public function setFilename(string $new_filename): self { @@ -232,8 +156,9 @@ class Footprint extends PartsContainingDBElement /** * Change the 3d model filename of this footprint. + * @param string $new_filename The new filename * - * @throws \Exception if there was an error + * @return Footprint */ public function set3dFilename(string $new_filename): self { diff --git a/src/Entity/Parts/MeasurementUnit.php b/src/Entity/Parts/MeasurementUnit.php index 06e4d1c7..25d74fa0 100644 --- a/src/Entity/Parts/MeasurementUnit.php +++ b/src/Entity/Parts/MeasurementUnit.php @@ -33,7 +33,6 @@ namespace App\Entity\Parts; use App\Entity\Base\PartsContainingDBElement; -use App\Entity\Base\StructuralDBElement; use Doctrine\ORM\Mapping as ORM; use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity; use Symfony\Component\Validator\Constraints as Assert; @@ -127,7 +126,7 @@ class MeasurementUnit extends PartsContainingDBElement */ public function setIsInteger(bool $isInteger): MeasurementUnit { - $this->isInteger = $isInteger; + $this->is_integer = $isInteger; return $this; } @@ -145,7 +144,7 @@ class MeasurementUnit extends PartsContainingDBElement */ public function setUseSIPrefix(bool $usesSIPrefixes): MeasurementUnit { - $this->useSIPrefixes = $usesSIPrefixes; + $this->use_si_prefix = $usesSIPrefixes; return $this; } } \ No newline at end of file diff --git a/src/Entity/Parts/Part.php b/src/Entity/Parts/Part.php index 5fc607a6..29b68922 100644 --- a/src/Entity/Parts/Part.php +++ b/src/Entity/Parts/Part.php @@ -71,7 +71,6 @@ use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping as ORM; -use Doctrine\ORM\PersistentCollection; use Symfony\Component\Validator\Constraints as Assert; /** @@ -169,7 +168,7 @@ class Part extends AttachmentContainingDBElement * * @ColumnSecurity(prefix="name") */ - protected $name = ''; + protected $name; /** * @var string @@ -303,12 +302,18 @@ class Part extends AttachmentContainingDBElement /** * Get the count of parts which must be in stock at least. + * If a integer-based part unit is selected, the value will be rounded to integers * - * @return int count of parts which must be in stock at least + * @return float count of parts which must be in stock at least */ public function getMinAmount(): float { - return $this->minamount; + if ($this->useFloatAmount()) { + return $this->minamount; + } + + return round($this->minamount); + } /** @@ -476,7 +481,7 @@ class Part extends AttachmentContainingDBElement * * @param bool $hide_obsolete If true, obsolete orderdetails will NOT be returned * - * @return Orderdetail[] * all orderdetails as a one-dimensional array of Orderdetails objects + * @return Collection|Orderdetail[] * all orderdetails as a one-dimensional array of Orderdetails objects * (empty array if there are no ones) * * the array is sorted by the suppliers names / minimum order quantity * @@ -638,7 +643,7 @@ class Part extends AttachmentContainingDBElement /** * Gets the measurement unit in which the part's amount should be measured. * Returns null if no specific unit was that. That means the parts are measured simply in quantity numbers. - * @return ?MeasurementUnit + * @return MeasurementUnit|null */ public function getPartUnit(): ?MeasurementUnit { @@ -648,7 +653,7 @@ class Part extends AttachmentContainingDBElement /** * Sets the measurement unit in which the part's amount should be measured. * Set to null, if the part should be measured in quantities. - * @param ?MeasurementUnit $partUnit + * @param MeasurementUnit|null $partUnit * @return Part */ public function setPartUnit(?MeasurementUnit $partUnit): Part @@ -762,7 +767,7 @@ class Part extends AttachmentContainingDBElement * Set the minimum amount of parts that have to be instock. * See getPartUnit() for the associated unit. * - * @param int $new_mininstock the new count of parts which should be in stock at least + * @param int $new_minamount the new count of parts which should be in stock at least * * @return self */ diff --git a/src/Entity/Parts/PartLot.php b/src/Entity/Parts/PartLot.php index 6d9bdb2c..1bedc6bc 100644 --- a/src/Entity/Parts/PartLot.php +++ b/src/Entity/Parts/PartLot.php @@ -33,7 +33,6 @@ namespace App\Entity\Parts; use App\Entity\Base\DBElement; -use App\Entity\Base\NamedDBElement; use App\Entity\Base\TimestampTrait; use App\Validator\Constraints\Selectable; use Doctrine\ORM\Mapping as ORM; @@ -56,13 +55,13 @@ class PartLot extends DBElement * @var string A short description about this lot, shown in table * @ORM\Column(type="text") */ - protected $description = ""; + protected $description = ''; /** * @var string A comment stored with this lot. * @ORM\Column(type="text") */ - protected $comment = ""; + protected $comment = ''; /** * @var ?\DateTime Set a time until when the lot must be used. @@ -126,7 +125,7 @@ class PartLot extends DBElement */ public function isExpired(): ?bool { - if ($this->expiration_date == null) { + if ($this->expiration_date === null) { return null; } diff --git a/src/Entity/Parts/Storelocation.php b/src/Entity/Parts/Storelocation.php index 7303b1af..db656012 100644 --- a/src/Entity/Parts/Storelocation.php +++ b/src/Entity/Parts/Storelocation.php @@ -61,9 +61,7 @@ declare(strict_types=1); namespace App\Entity\Parts; -use App\Entity\Base\PartsContainingDBElement; use App\Entity\Base\StructuralDBElement; -use App\Form\Type\StructuralEntityType; use Doctrine\ORM\Mapping as ORM; /** diff --git a/src/Entity/PriceInformations/Currency.php b/src/Entity/PriceInformations/Currency.php index b2eee33f..b678beeb 100644 --- a/src/Entity/PriceInformations/Currency.php +++ b/src/Entity/PriceInformations/Currency.php @@ -100,7 +100,7 @@ class Currency extends StructuralDBElement { $tmp = $this->getExchangeRate(); - if ($tmp == null) { + if ($tmp === null) { return null; } diff --git a/src/Entity/PriceInformations/Orderdetail.php b/src/Entity/PriceInformations/Orderdetail.php index f03bf416..c092463a 100644 --- a/src/Entity/PriceInformations/Orderdetail.php +++ b/src/Entity/PriceInformations/Orderdetail.php @@ -237,7 +237,7 @@ class Orderdetail extends DBElement public function getPrice(int $quantity = 1, $multiplier = null) : ?float { - if (($quantity == 0) && ($multiplier === null)) { + if (($quantity === 0) && ($multiplier === null)) { return 0.0; } @@ -258,7 +258,7 @@ class Orderdetail extends DBElement $correct_pricedetails = $pricedetails; } - if ($correct_pricedetails == null) { + if ($correct_pricedetails === null) { return null; } @@ -276,22 +276,21 @@ class Orderdetail extends DBElement *********************************************************************************/ /** - * Set the supplier ID. - * - * @param int $new_supplier_id the ID of the new supplier + * Sets the new supplier associated with this orderdetail. + * @param Supplier $new_supplier + * @return Orderdetail */ - public function setSupplierId(int $new_supplier_id): self + public function setSupplier(Supplier $new_supplier) : Orderdetail { - throw new \Exception('Not implemented yet!'); - //TODO; - + $this->supplier = $new_supplier; return $this; } /** * Set the supplier part-nr. - * * @param string $new_supplierpartnr the new supplier-part-nr + * @return Orderdetail + * @return Orderdetail */ public function setSupplierpartnr(string $new_supplierpartnr): self { @@ -302,8 +301,9 @@ class Orderdetail extends DBElement /** * Set if the part is obsolete at the supplier of that orderdetails. - * * @param bool $new_obsolete true means that this part is obsolete + * @return Orderdetail + * @return Orderdetail */ public function setObsolete(bool $new_obsolete): self { @@ -315,8 +315,9 @@ class Orderdetail extends DBElement /** * Sets the custom product supplier URL for this order detail. * Set this to "", if the function getSupplierProductURL should return the automatic generated URL. - * * @param $new_url string The new URL for the supplier URL. + * @return Orderdetail + * @return Orderdetail */ public function setSupplierProductUrl(string $new_url) { diff --git a/src/Entity/PriceInformations/Pricedetail.php b/src/Entity/PriceInformations/Pricedetail.php index 561617cd..49f10734 100644 --- a/src/Entity/PriceInformations/Pricedetail.php +++ b/src/Entity/PriceInformations/Pricedetail.php @@ -220,6 +220,7 @@ class Pricedetail extends DBElement public function setCurrency(?Currency $currency): Pricedetail { $this->currency = $currency; + return $this; } /** diff --git a/src/Entity/UserSystem/User.php b/src/Entity/UserSystem/User.php index d7cbded1..6a693e96 100644 --- a/src/Entity/UserSystem/User.php +++ b/src/Entity/UserSystem/User.php @@ -91,7 +91,7 @@ class User extends NamedDBElement implements UserInterface, HasPermissionsInterf * @ORM\Column(type="string", length=180, unique=true) * @Assert\NotBlank */ - protected $name = ""; + protected $name = ''; /** * //@ORM\Column(type="json"). diff --git a/src/Repository/StructuralDBElementRepository.php b/src/Repository/StructuralDBElementRepository.php index 18e11f58..e96b1ec4 100644 --- a/src/Repository/StructuralDBElementRepository.php +++ b/src/Repository/StructuralDBElementRepository.php @@ -33,7 +33,6 @@ namespace App\Repository; use App\Entity\Base\StructuralDBElement; -use Doctrine\Common\Collections\Criteria; use Doctrine\ORM\EntityRepository; class StructuralDBElementRepository extends EntityRepository