Fixed some inspection issues.

This commit is contained in:
Jan Böhmer 2019-08-20 18:39:57 +02:00
parent 8e23629dc0
commit 1629f31fed
31 changed files with 187 additions and 211 deletions

View file

@ -53,11 +53,15 @@ class AttachmentTypeController extends BaseAdminController
protected $entity_class = AttachmentType::class; protected $entity_class = AttachmentType::class;
protected $twig_template = 'AdminPages/AttachmentTypeAdmin.html.twig'; protected $twig_template = 'AdminPages/AttachmentTypeAdmin.html.twig';
protected $form_class = BaseEntityAdminForm::class; 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}/edit", requirements={"id"="\d+"}, name="attachment_type_edit")
* @Route("/{id}/", requirements={"id"="\d+"}) * @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) public function edit(AttachmentType $entity, Request $request, EntityManagerInterface $em)
{ {
@ -68,7 +72,10 @@ class AttachmentTypeController extends BaseAdminController
* @Route("/new", name="attachment_type_new") * @Route("/new", name="attachment_type_new")
* @Route("/") * @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) 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"}) * @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) public function delete(Request $request, AttachmentType $entity, StructuralElementRecursionHelper $recursionHelper)
{ {
@ -86,7 +97,6 @@ class AttachmentTypeController extends BaseAdminController
/** /**
* @Route("/export", name="attachment_type_export_all") * @Route("/export", name="attachment_type_export_all")
* @param Request $request * @param Request $request
* @param SerializerInterface $serializer
* @param EntityManagerInterface $em * @param EntityManagerInterface $em
* @return Response * @return Response
*/ */
@ -99,6 +109,7 @@ class AttachmentTypeController extends BaseAdminController
* @Route("/{id}/export", name="attachment_type_export") * @Route("/{id}/export", name="attachment_type_export")
* @param Request $request * @param Request $request
* @param AttachmentType $entity * @param AttachmentType $entity
* @return Response
*/ */
public function exportEntity(AttachmentType $entity, EntityExporter $exporter, Request $request) public function exportEntity(AttachmentType $entity, EntityExporter $exporter, Request $request)
{ {

View file

@ -33,7 +33,6 @@ namespace App\Controller\AdminPages;
use App\Entity\Base\NamedDBElement; use App\Entity\Base\NamedDBElement;
use App\Entity\Base\StructuralDBElement; use App\Entity\Base\StructuralDBElement;
use App\Form\AdminPages\BaseEntityAdminForm;
use App\Form\AdminPages\ImportType; use App\Form\AdminPages\ImportType;
use App\Form\AdminPages\MassCreationForm; use App\Form\AdminPages\MassCreationForm;
use App\Services\EntityExporter; use App\Services\EntityExporter;
@ -48,14 +47,14 @@ use Symfony\Component\Validator\ConstraintViolationList;
abstract class BaseAdminController extends AbstractController abstract class BaseAdminController extends AbstractController
{ {
protected $entity_class = ""; protected $entity_class = '';
protected $form_class = ""; protected $form_class = '';
protected $twig_template = ""; protected $twig_template = '';
protected $route_base = ""; protected $route_base = '';
public function __construct() 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!'); 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) { foreach ($errors as $name => $error) {
/** @var $error ConstraintViolationList */ /** @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: //Show errors to user:
foreach ($errors as $name => $error) { foreach ($errors as $name => $error) {
/** @var $error ConstraintViolationList */ /** @var $error ConstraintViolationList */
$this->addFlash('error', $name . ":" . $error); $this->addFlash('error', $name . ':' . $error);
} }
} }

View file

@ -34,7 +34,6 @@ namespace App\Controller\AdminPages;
use App\Entity\Attachments\AttachmentType; use App\Entity\Attachments\AttachmentType;
use App\Entity\Parts\Category; use App\Entity\Parts\Category;
use App\Form\AdminPages\BaseEntityAdminForm;
use App\Form\AdminPages\CategoryAdminForm; use App\Form\AdminPages\CategoryAdminForm;
use App\Services\EntityExporter; use App\Services\EntityExporter;
use App\Services\EntityImporter; use App\Services\EntityImporter;
@ -55,11 +54,15 @@ class CategoryController extends BaseAdminController
protected $entity_class = Category::class; protected $entity_class = Category::class;
protected $twig_template = 'AdminPages/CategoryAdmin.html.twig'; protected $twig_template = 'AdminPages/CategoryAdmin.html.twig';
protected $form_class = CategoryAdminForm::class; protected $form_class = CategoryAdminForm::class;
protected $route_base = "category"; protected $route_base = 'category';
/** /**
* @Route("/{id}/edit", requirements={"id"="\d+"}, name="category_edit") * @Route("/{id}/edit", requirements={"id"="\d+"}, name="category_edit")
* @Route("/{id}/", requirements={"id"="\d+"}) * @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) public function edit(Category $entity, Request $request, EntityManagerInterface $em)
{ {
@ -70,7 +73,10 @@ class CategoryController extends BaseAdminController
* @Route("/new", name="category_new") * @Route("/new", name="category_new")
* @Route("/") * @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) public function new(Request $request, EntityManagerInterface $em, EntityImporter $importer)
{ {
@ -79,6 +85,10 @@ class CategoryController extends BaseAdminController
/** /**
* @Route("/{id}", name="category_delete", methods={"DELETE"}) * @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) public function delete(Request $request, Category $entity, StructuralElementRecursionHelper $recursionHelper)
{ {
@ -87,9 +97,9 @@ class CategoryController extends BaseAdminController
/** /**
* @Route("/export", name="category_export_all") * @Route("/export", name="category_export_all")
* @param Request $request
* @param SerializerInterface $serializer
* @param EntityManagerInterface $em * @param EntityManagerInterface $em
* @param EntityExporter $exporter
* @param Request $request
* @return Response * @return Response
*/ */
public function exportAll(EntityManagerInterface $em, EntityExporter $exporter, Request $request) public function exportAll(EntityManagerInterface $em, EntityExporter $exporter, Request $request)
@ -99,8 +109,10 @@ class CategoryController extends BaseAdminController
/** /**
* @Route("/{id}/export", name="category_export") * @Route("/{id}/export", name="category_export")
* @param Category $entity
* @param EntityExporter $exporter
* @param Request $request * @param Request $request
* @param AttachmentType $entity * @return Response
*/ */
public function exportEntity(Category $entity, EntityExporter $exporter, Request $request) public function exportEntity(Category $entity, EntityExporter $exporter, Request $request)
{ {

View file

@ -33,10 +33,7 @@ namespace App\Controller\AdminPages;
use App\Entity\Attachments\AttachmentType; use App\Entity\Attachments\AttachmentType;
use App\Entity\Parts\Category;
use App\Entity\PriceInformations\Currency; use App\Entity\PriceInformations\Currency;
use App\Form\AdminPages\BaseEntityAdminForm;
use App\Form\AdminPages\CategoryAdminForm;
use App\Form\AdminPages\CurrencyAdminForm; use App\Form\AdminPages\CurrencyAdminForm;
use App\Services\EntityExporter; use App\Services\EntityExporter;
use App\Services\EntityImporter; use App\Services\EntityImporter;
@ -58,11 +55,15 @@ class CurrencyController extends BaseAdminController
protected $entity_class = Currency::class; protected $entity_class = Currency::class;
protected $twig_template = 'AdminPages/CurrencyAdmin.html.twig'; protected $twig_template = 'AdminPages/CurrencyAdmin.html.twig';
protected $form_class = CurrencyAdminForm::class; protected $form_class = CurrencyAdminForm::class;
protected $route_base = "currency"; protected $route_base = 'currency';
/** /**
* @Route("/{id}/edit", requirements={"id"="\d+"}, name="currency_edit") * @Route("/{id}/edit", requirements={"id"="\d+"}, name="currency_edit")
* @Route("/{id}/", requirements={"id"="\d+"}) * @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) public function edit(Currency $entity, Request $request, EntityManagerInterface $em)
{ {
@ -73,7 +74,10 @@ class CurrencyController extends BaseAdminController
* @Route("/new", name="currency_new") * @Route("/new", name="currency_new")
* @Route("/") * @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) public function new(Request $request, EntityManagerInterface $em, EntityImporter $importer)
{ {
@ -82,6 +86,10 @@ class CurrencyController extends BaseAdminController
/** /**
* @Route("/{id}", name="currency_delete", methods={"DELETE"}) * @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) public function delete(Request $request, Currency $entity, StructuralElementRecursionHelper $recursionHelper)
{ {
@ -90,9 +98,9 @@ class CurrencyController extends BaseAdminController
/** /**
* @Route("/export", name="currency_export_all") * @Route("/export", name="currency_export_all")
* @param Request $request
* @param SerializerInterface $serializer
* @param EntityManagerInterface $em * @param EntityManagerInterface $em
* @param EntityExporter $exporter
* @param Request $request
* @return Response * @return Response
*/ */
public function exportAll(EntityManagerInterface $em, EntityExporter $exporter, Request $request) public function exportAll(EntityManagerInterface $em, EntityExporter $exporter, Request $request)
@ -102,8 +110,10 @@ class CurrencyController extends BaseAdminController
/** /**
* @Route("/{id}/export", name="currency_export") * @Route("/{id}/export", name="currency_export")
* @param Currency $entity
* @param EntityExporter $exporter
* @param Request $request * @param Request $request
* @param AttachmentType $entity * @return Response
*/ */
public function exportEntity(Currency $entity, EntityExporter $exporter, Request $request) public function exportEntity(Currency $entity, EntityExporter $exporter, Request $request)
{ {

View file

@ -55,11 +55,15 @@ class DeviceController extends BaseAdminController
protected $entity_class = Device::class; protected $entity_class = Device::class;
protected $twig_template = 'AdminPages/DeviceAdmin.html.twig'; protected $twig_template = 'AdminPages/DeviceAdmin.html.twig';
protected $form_class = BaseEntityAdminForm::class; protected $form_class = BaseEntityAdminForm::class;
protected $route_base = "device"; protected $route_base = 'device';
/** /**
* @Route("/{id}/edit", requirements={"id"="\d+"}, name="device_edit") * @Route("/{id}/edit", requirements={"id"="\d+"}, name="device_edit")
* @Route("/{id}/", requirements={"id"="\d+"}) * @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) public function edit(Device $entity, Request $request, EntityManagerInterface $em)
{ {
@ -70,7 +74,10 @@ class DeviceController extends BaseAdminController
* @Route("/new", name="device_new") * @Route("/new", name="device_new")
* @Route("/") * @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) public function new(Request $request, EntityManagerInterface $em, EntityImporter $importer)
{ {
@ -79,6 +86,10 @@ class DeviceController extends BaseAdminController
/** /**
* @Route("/{id}", name="device_delete", methods={"DELETE"}) * @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) public function delete(Request $request, Device $entity, StructuralElementRecursionHelper $recursionHelper)
{ {
@ -87,9 +98,9 @@ class DeviceController extends BaseAdminController
/** /**
* @Route("/export", name="device_export_all") * @Route("/export", name="device_export_all")
* @param Request $request
* @param SerializerInterface $serializer
* @param EntityManagerInterface $em * @param EntityManagerInterface $em
* @param EntityExporter $exporter
* @param Request $request
* @return Response * @return Response
*/ */
public function exportAll(EntityManagerInterface $em, EntityExporter $exporter, Request $request) public function exportAll(EntityManagerInterface $em, EntityExporter $exporter, Request $request)
@ -99,8 +110,10 @@ class DeviceController extends BaseAdminController
/** /**
* @Route("/{id}/export", name="device_export") * @Route("/{id}/export", name="device_export")
* @param Device $entity
* @param EntityExporter $exporter
* @param Request $request * @param Request $request
* @param AttachmentType $entity * @return Response
*/ */
public function exportEntity(Device $entity, EntityExporter $exporter, Request $request) public function exportEntity(Device $entity, EntityExporter $exporter, Request $request)
{ {

View file

@ -55,7 +55,7 @@ class FootprintController extends BaseAdminController
protected $entity_class = Footprint::class; protected $entity_class = Footprint::class;
protected $twig_template = 'AdminPages/FootprintAdmin.html.twig'; protected $twig_template = 'AdminPages/FootprintAdmin.html.twig';
protected $form_class = BaseEntityAdminForm::class; protected $form_class = BaseEntityAdminForm::class;
protected $route_base = "footprint"; protected $route_base = 'footprint';
/** /**
* @Route("/{id}/edit", requirements={"id"="\d+"}, name="footprint_edit") * @Route("/{id}/edit", requirements={"id"="\d+"}, name="footprint_edit")
@ -70,7 +70,7 @@ class FootprintController extends BaseAdminController
* @Route("/new", name="footprint_new") * @Route("/new", name="footprint_new")
* @Route("/") * @Route("/")
* *
* @return \Symfony\Component\HttpFoundation\Response * @return Response
*/ */
public function new(Request $request, EntityManagerInterface $em, EntityImporter $importer) public function new(Request $request, EntityManagerInterface $em, EntityImporter $importer)
{ {
@ -101,6 +101,7 @@ class FootprintController extends BaseAdminController
* @Route("/{id}/export", name="footprint_export") * @Route("/{id}/export", name="footprint_export")
* @param Request $request * @param Request $request
* @param AttachmentType $entity * @param AttachmentType $entity
* @return Response
*/ */
public function exportEntity(AttachmentType $entity, EntityExporter $exporter, Request $request) public function exportEntity(AttachmentType $entity, EntityExporter $exporter, Request $request)
{ {

View file

@ -32,11 +32,8 @@
namespace App\Controller\AdminPages; namespace App\Controller\AdminPages;
use App\Entity\Attachments\AttachmentType;
use App\Entity\Parts\Manufacturer; use App\Entity\Parts\Manufacturer;
use App\Entity\Parts\Supplier; use App\Entity\Parts\Supplier;
use App\Form\AdminPages\BaseEntityAdminForm;
use App\Form\AdminPages\CompanyForm; use App\Form\AdminPages\CompanyForm;
use App\Services\EntityExporter; use App\Services\EntityExporter;
use App\Services\EntityImporter; use App\Services\EntityImporter;
@ -72,7 +69,7 @@ class ManufacturerController extends BaseAdminController
* @Route("/new", name="manufacturer_new") * @Route("/new", name="manufacturer_new")
* @Route("/") * @Route("/")
* *
* @return \Symfony\Component\HttpFoundation\Response * @return Response
*/ */
public function new(Request $request, EntityManagerInterface $em, EntityImporter $importer) public function new(Request $request, EntityManagerInterface $em, EntityImporter $importer)
{ {
@ -103,6 +100,7 @@ class ManufacturerController extends BaseAdminController
* @Route("/{id}/export", name="manufacturer_export") * @Route("/{id}/export", name="manufacturer_export")
* @param Request $request * @param Request $request
* @param Supplier $entity * @param Supplier $entity
* @return Response
*/ */
public function exportEntity(Manufacturer $entity, EntityExporter $exporter, Request $request) public function exportEntity(Manufacturer $entity, EntityExporter $exporter, Request $request)
{ {

View file

@ -34,7 +34,6 @@ namespace App\Controller\AdminPages;
use App\Entity\Attachments\AttachmentType; use App\Entity\Attachments\AttachmentType;
use App\Entity\Parts\MeasurementUnit; use App\Entity\Parts\MeasurementUnit;
use App\Form\AdminPages\BaseEntityAdminForm;
use App\Form\AdminPages\MeasurementUnitAdminForm; use App\Form\AdminPages\MeasurementUnitAdminForm;
use App\Services\EntityExporter; use App\Services\EntityExporter;
use App\Services\EntityImporter; use App\Services\EntityImporter;
@ -55,7 +54,7 @@ class MeasurementUnitController extends BaseAdminController
protected $entity_class = MeasurementUnit::class; protected $entity_class = MeasurementUnit::class;
protected $twig_template = 'AdminPages/MeasurementUnitAdmin.html.twig'; protected $twig_template = 'AdminPages/MeasurementUnitAdmin.html.twig';
protected $form_class = MeasurementUnitAdminForm::class; 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") * @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("/new", name="measurement_unit_new")
* @Route("/") * @Route("/")
* *
* @return \Symfony\Component\HttpFoundation\Response * @return Response
*/ */
public function new(Request $request, EntityManagerInterface $em, EntityImporter $importer) public function new(Request $request, EntityManagerInterface $em, EntityImporter $importer)
{ {
@ -101,6 +100,7 @@ class MeasurementUnitController extends BaseAdminController
* @Route("/{id}/export", name="measurement_unit_export") * @Route("/{id}/export", name="measurement_unit_export")
* @param Request $request * @param Request $request
* @param AttachmentType $entity * @param AttachmentType $entity
* @return Response
*/ */
public function exportEntity(AttachmentType $entity, EntityExporter $exporter, Request $request) public function exportEntity(AttachmentType $entity, EntityExporter $exporter, Request $request)
{ {

View file

@ -34,7 +34,6 @@ namespace App\Controller\AdminPages;
use App\Entity\Attachments\AttachmentType; use App\Entity\Attachments\AttachmentType;
use App\Entity\Parts\Storelocation; use App\Entity\Parts\Storelocation;
use App\Form\AdminPages\BaseEntityAdminForm;
use App\Form\AdminPages\StorelocationAdminForm; use App\Form\AdminPages\StorelocationAdminForm;
use App\Services\EntityExporter; use App\Services\EntityExporter;
use App\Services\EntityImporter; use App\Services\EntityImporter;
@ -42,7 +41,6 @@ use App\Services\StructuralElementRecursionHelper;
use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\HttpCache\Store;
use Symfony\Component\Routing\Annotation\Route; use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Serializer\SerializerInterface; use Symfony\Component\Serializer\SerializerInterface;
@ -56,7 +54,7 @@ class StorelocationController extends BaseAdminController
protected $entity_class = Storelocation::class; protected $entity_class = Storelocation::class;
protected $twig_template = 'AdminPages/StorelocationAdmin.html.twig'; protected $twig_template = 'AdminPages/StorelocationAdmin.html.twig';
protected $form_class = StorelocationAdminForm::class; 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") * @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("/new", name="store_location_new")
* @Route("/") * @Route("/")
* *
* @return \Symfony\Component\HttpFoundation\Response * @return Response
*/ */
public function new(Request $request, EntityManagerInterface $em, EntityImporter $importer) public function new(Request $request, EntityManagerInterface $em, EntityImporter $importer)
{ {
@ -102,6 +100,7 @@ class StorelocationController extends BaseAdminController
* @Route("/{id}/export", name="store_location_export") * @Route("/{id}/export", name="store_location_export")
* @param Request $request * @param Request $request
* @param AttachmentType $entity * @param AttachmentType $entity
* @return Response
*/ */
public function exportEntity(Storelocation $entity, EntityExporter $exporter, Request $request) public function exportEntity(Storelocation $entity, EntityExporter $exporter, Request $request)
{ {

View file

@ -32,11 +32,7 @@
namespace App\Controller\AdminPages; namespace App\Controller\AdminPages;
use App\Entity\Attachments\AttachmentType;
use App\Entity\Parts\Supplier; use App\Entity\Parts\Supplier;
use App\Form\AdminPages\BaseEntityAdminForm;
use App\Form\AdminPages\CompanyForm;
use App\Form\AdminPages\SupplierForm; use App\Form\AdminPages\SupplierForm;
use App\Services\EntityExporter; use App\Services\EntityExporter;
use App\Services\EntityImporter; use App\Services\EntityImporter;
@ -57,7 +53,7 @@ class SupplierController extends BaseAdminController
protected $entity_class = Supplier::class; protected $entity_class = Supplier::class;
protected $twig_template = 'AdminPages/SupplierAdmin.html.twig'; protected $twig_template = 'AdminPages/SupplierAdmin.html.twig';
protected $form_class = SupplierForm::class; protected $form_class = SupplierForm::class;
protected $route_base = "supplier"; protected $route_base = 'supplier';
/** /**
* @Route("/{id}/edit", requirements={"id"="\d+"}, name="supplier_edit") * @Route("/{id}/edit", requirements={"id"="\d+"}, name="supplier_edit")
@ -72,7 +68,7 @@ class SupplierController extends BaseAdminController
* @Route("/new", name="supplier_new") * @Route("/new", name="supplier_new")
* @Route("/") * @Route("/")
* *
* @return \Symfony\Component\HttpFoundation\Response * @return Response
*/ */
public function new(Request $request, EntityManagerInterface $em, EntityImporter $importer) public function new(Request $request, EntityManagerInterface $em, EntityImporter $importer)
{ {
@ -103,6 +99,7 @@ class SupplierController extends BaseAdminController
* @Route("/{id}/export", name="supplier_export") * @Route("/{id}/export", name="supplier_export")
* @param Request $request * @param Request $request
* @param Supplier $entity * @param Supplier $entity
* @return Response
*/ */
public function exportEntity(Supplier $entity, EntityExporter $exporter, Request $request) public function exportEntity(Supplier $entity, EntityExporter $exporter, Request $request)
{ {

View file

@ -47,17 +47,20 @@ class AttachmentFileController extends AbstractController
* *
* @Route("/attachment/{id}/download", name="attachment_download") * @Route("/attachment/{id}/download", name="attachment_download")
* @param Attachment $attachment * @param Attachment $attachment
* @param AttachmentHelper $helper
* @return BinaryFileResponse
* @throws \Exception
*/ */
public function download(Attachment $attachment, AttachmentHelper $helper) public function download(Attachment $attachment, AttachmentHelper $helper)
{ {
$this->denyAccessUnlessGranted("read", $attachment); $this->denyAccessUnlessGranted('read', $attachment);
if ($attachment->isExternal()) { 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)) { 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") * @Route("/attachment/{id}/view", name="attachment_view")
* @param Attachment $attachment * @param Attachment $attachment
* @param AttachmentHelper $helper
* @return BinaryFileResponse
* @throws \Exception
*/ */
public function view(Attachment $attachment, AttachmentHelper $helper) public function view(Attachment $attachment, AttachmentHelper $helper)
{ {
$this->denyAccessUnlessGranted("read", $attachment); $this->denyAccessUnlessGranted('read', $attachment);
if ($attachment->isExternal()) { 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)) { 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!');
} }

View file

@ -33,7 +33,6 @@ namespace App\Controller;
use App\Entity\Parts\Category; use App\Entity\Parts\Category;
use App\Entity\Parts\Part; use App\Entity\Parts\Part;
use App\Form\Part\PartBaseType; use App\Form\Part\PartBaseType;
use App\Services\AttachmentFilenameService;
use App\Services\AttachmentHelper; use App\Services\AttachmentHelper;
use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityManagerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
@ -46,6 +45,9 @@ class PartController extends AbstractController
/** /**
* @Route("/part/{id}/info", name="part_info") * @Route("/part/{id}/info", name="part_info")
* @Route("/part/{id}", requirements={"id"="\d+"}) * @Route("/part/{id}", requirements={"id"="\d+"})
* @param Part $part
* @param AttachmentHelper $attachmentHelper
* @return \Symfony\Component\HttpFoundation\Response
*/ */
public function show(Part $part, AttachmentHelper $attachmentHelper) public function show(Part $part, AttachmentHelper $attachmentHelper)
{ {
@ -64,6 +66,8 @@ class PartController extends AbstractController
* *
* @param Part $part * @param Part $part
* *
* @param Request $request
* @param EntityManagerInterface $em
* @return \Symfony\Component\HttpFoundation\Response * @return \Symfony\Component\HttpFoundation\Response
*/ */
public function edit(Part $part, Request $request, EntityManagerInterface $em) public function edit(Part $part, Request $request, EntityManagerInterface $em)
@ -89,6 +93,9 @@ class PartController extends AbstractController
/** /**
* @Route("/part/new", name="part_new") * @Route("/part/new", name="part_new")
* *
* @param Request $request
* @param EntityManagerInterface $em
* @param TranslatorInterface $translator
* @return \Symfony\Component\HttpFoundation\Response * @return \Symfony\Component\HttpFoundation\Response
*/ */
public function new(Request $request, EntityManagerInterface $em, TranslatorInterface $translator) public function new(Request $request, EntityManagerInterface $em, TranslatorInterface $translator)
@ -123,6 +130,11 @@ class PartController extends AbstractController
/** /**
* @Route("/part/{id}/clone", name="part_clone") * @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) 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->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, 'part' => $new_part,
'form' => $form->createView(), 'form' => $form->createView(),

View file

@ -57,6 +57,6 @@ class SecurityController extends AbstractController
*/ */
public function logout() public function logout()
{ {
throw new \Exception('Will be intercepted before getting here'); throw new \RuntimeException('Will be intercepted before getting here');
} }
} }

View file

@ -35,11 +35,9 @@ use App\Entity\Parts\Footprint;
use App\Entity\Parts\Manufacturer; use App\Entity\Parts\Manufacturer;
use App\Entity\Parts\Storelocation; use App\Entity\Parts\Storelocation;
use App\Entity\Parts\Supplier; use App\Entity\Parts\Supplier;
use App\Helpers\TreeViewNode;
use App\Services\ToolsTreeBuilder; use App\Services\ToolsTreeBuilder;
use App\Services\TreeBuilder; use App\Services\TreeBuilder;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\Form\Extension\Core\Type\LocaleType;
use Symfony\Component\Routing\Annotation\Route; use Symfony\Component\Routing\Annotation\Route;
/** /**
@ -66,7 +64,7 @@ class TreeController extends AbstractController
*/ */
public function categoryTree(TreeBuilder $builder, Category $category = null) public function categoryTree(TreeBuilder $builder, Category $category = null)
{ {
if ($category != null) { if ($category !== null) {
$tree[] = $builder->elementToTreeNode($category); $tree[] = $builder->elementToTreeNode($category);
} else { } else {
$tree = $builder->typeToTree(Category::class); $tree = $builder->typeToTree(Category::class);
@ -82,7 +80,7 @@ class TreeController extends AbstractController
*/ */
public function footprintTree(TreeBuilder $builder, Footprint $footprint = null) public function footprintTree(TreeBuilder $builder, Footprint $footprint = null)
{ {
if ($footprint != null) { if ($footprint !== null) {
$tree[] = $builder->elementToTreeNode($footprint); $tree[] = $builder->elementToTreeNode($footprint);
} else { } else {
$tree = $builder->typeToTree(Footprint::class, null); $tree = $builder->typeToTree(Footprint::class, null);
@ -98,7 +96,7 @@ class TreeController extends AbstractController
*/ */
public function locationTree(TreeBuilder $builder, Storelocation $location = null) public function locationTree(TreeBuilder $builder, Storelocation $location = null)
{ {
if ($location != null) { if ($location !== null) {
$tree[] = $builder->elementToTreeNode($location); $tree[] = $builder->elementToTreeNode($location);
} else { } else {
$tree = $builder->typeToTree(Storelocation::class, null); $tree = $builder->typeToTree(Storelocation::class, null);
@ -114,7 +112,7 @@ class TreeController extends AbstractController
*/ */
public function manufacturerTree(TreeBuilder $builder, Manufacturer $manufacturer = null) public function manufacturerTree(TreeBuilder $builder, Manufacturer $manufacturer = null)
{ {
if ($manufacturer != null) { if ($manufacturer !== null) {
$tree[] = $builder->elementToTreeNode($manufacturer); $tree[] = $builder->elementToTreeNode($manufacturer);
} else { } else {
$tree = $builder->typeToTree(Manufacturer::class, null); $tree = $builder->typeToTree(Manufacturer::class, null);
@ -130,7 +128,7 @@ class TreeController extends AbstractController
*/ */
public function supplierTree(TreeBuilder $builder, Supplier $supplier = null) public function supplierTree(TreeBuilder $builder, Supplier $supplier = null)
{ {
if ($supplier != null) { if ($supplier !== null) {
$tree[] = $builder->elementToTreeNode($supplier); $tree[] = $builder->elementToTreeNode($supplier);
} else { } else {
$tree = $builder->typeToTree(Supplier::class, null); $tree = $builder->typeToTree(Supplier::class, null);
@ -146,7 +144,7 @@ class TreeController extends AbstractController
*/ */
public function deviceTree(TreeBuilder $builder, Device $device = null) public function deviceTree(TreeBuilder $builder, Device $device = null)
{ {
if ($device != null) { if ($device !== null) {
$tree[] = $builder->elementToTreeNode($device); $tree[] = $builder->elementToTreeNode($device);
} else { } else {
$tree = $builder->typeToTree(Device::class, null); $tree = $builder->typeToTree(Device::class, null);

View file

@ -30,16 +30,13 @@
namespace App\Controller; namespace App\Controller;
use App\Entity\Attachments\AttachmentType; use App\Entity\Attachments\AttachmentType;
use App\Entity\Parts\Footprint;
use App\Entity\UserSystem\User; use App\Entity\UserSystem\User;
use App\Form\AdminPages\BaseEntityAdminForm;
use App\Form\UserAdminForm; use App\Form\UserAdminForm;
use App\Form\UserSettingsType; use App\Form\UserSettingsType;
use App\Services\EntityExporter; use App\Services\EntityExporter;
use App\Services\EntityImporter; use App\Services\EntityImporter;
use App\Services\StructuralElementRecursionHelper; use App\Services\StructuralElementRecursionHelper;
use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityManagerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\Asset\Packages; use Symfony\Component\Asset\Packages;
use Symfony\Component\Form\Extension\Core\Type\PasswordType; use Symfony\Component\Form\Extension\Core\Type\PasswordType;
use Symfony\Component\Form\Extension\Core\Type\RepeatedType; use Symfony\Component\Form\Extension\Core\Type\RepeatedType;
@ -63,7 +60,7 @@ class UserController extends AdminPages\BaseAdminController
protected $entity_class = User::class; protected $entity_class = User::class;
protected $twig_template = 'AdminPages/UserAdmin.html.twig'; protected $twig_template = 'AdminPages/UserAdmin.html.twig';
protected $form_class = UserAdminForm::class; 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("/new", name="user_new")
* @Route("/") * @Route("/")
* *
* @return \Symfony\Component\HttpFoundation\Response * @return Response
*/ */
public function new(Request $request, EntityManagerInterface $em, EntityImporter $importer) public function new(Request $request, EntityManagerInterface $em, EntityImporter $importer)
{ {
@ -110,6 +107,7 @@ class UserController extends AdminPages\BaseAdminController
* @Route("/{id}/export", name="user_export") * @Route("/{id}/export", name="user_export")
* @param Request $request * @param Request $request
* @param AttachmentType $entity * @param AttachmentType $entity
* @return Response
*/ */
public function exportEntity(User $entity, EntityExporter $exporter, Request $request) public function exportEntity(User $entity, EntityExporter $exporter, Request $request)
{ {

View file

@ -27,7 +27,6 @@ use App\Entity\Base\DBElement;
use App\Entity\Base\NamedDBElement; use App\Entity\Base\NamedDBElement;
use App\Validator\Constraints\Selectable; use App\Validator\Constraints\Selectable;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Intl\Exception\NotImplementedException;
/** /**
* Class Attachment. * Class Attachment.
@ -114,7 +113,7 @@ abstract class Attachment extends NamedDBElement
/** /**
* Get the element, associated with this Attachement (for example a "Part" object). * 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 public function getElement(): ?AttachmentContainingDBElement
{ {
@ -260,8 +259,8 @@ abstract class Attachment extends NamedDBElement
} }
if ($path_required) { if ($path_required) {
return (bool) filter_var($string, FILTER_VALIDATE_URL, FILTER_FLAG_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);
} }
}
} }

View file

@ -56,7 +56,6 @@ use App\Entity\Base\NamedDBElement;
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;
use Doctrine\ORM\PersistentCollection;
use Exception; use Exception;
/** /**
@ -107,7 +106,7 @@ abstract class AttachmentContainingDBElement extends NamedDBElement
* * if this is a number > 0, only attachements with this type ID 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" * @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 * @throws Exception if there was an error
*/ */

View file

@ -53,7 +53,6 @@ declare(strict_types=1);
namespace App\Entity\Attachments; namespace App\Entity\Attachments;
use App\Entity\Base\StructuralDBElement; use App\Entity\Base\StructuralDBElement;
use App\Validator\Constraints\NoneOfItsChildren;
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;
@ -86,7 +85,7 @@ class AttachmentType extends StructuralDBElement
/** /**
* Get all attachements ("Attachement" objects) with this type. * 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) * (sorted by their names)
*/ */
public function getAttachementsForType(): Collection public function getAttachementsForType(): Collection

View file

@ -52,7 +52,6 @@ declare(strict_types=1);
namespace App\Entity\Base; namespace App\Entity\Base;
use App\Entity\Base\StructuralDBElement;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert; use Symfony\Component\Validator\Constraints as Assert;
@ -67,39 +66,39 @@ abstract class Company extends StructuralDBElement
* @var string The address of the company * @var string The address of the company
* @ORM\Column(type="string") * @ORM\Column(type="string")
*/ */
protected $address = ""; protected $address = '';
/** /**
* @var string The phone number of the company * @var string The phone number of the company
* @ORM\Column(type="string") * @ORM\Column(type="string")
*/ */
protected $phone_number = ""; protected $phone_number = '';
/** /**
* @var string The fax number of the company * @var string The fax number of the company
* @ORM\Column(type="string") * @ORM\Column(type="string")
*/ */
protected $fax_number = ""; protected $fax_number = '';
/** /**
* @var string The email address of the company * @var string The email address of the company
* @ORM\Column(type="string") * @ORM\Column(type="string")
* @Assert\Email() * @Assert\Email()
*/ */
protected $email_address = ""; protected $email_address = '';
/** /**
* @var string The website of the company * @var string The website of the company
* @ORM\Column(type="string") * @ORM\Column(type="string")
* @Assert\Url() * @Assert\Url()
*/ */
protected $website = ""; protected $website = '';
/** /**
* @var string * @var string
* @ORM\Column(type="string") * @ORM\Column(type="string")
*/ */
protected $auto_product_url = ""; protected $auto_product_url = '';
/******************************************************************************** /********************************************************************************
* *

View file

@ -55,10 +55,8 @@ namespace App\Entity\Base;
use App\Entity\Attachments\AttachmentContainingDBElement; use App\Entity\Attachments\AttachmentContainingDBElement;
use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
use Doctrine\ORM\PersistentCollection;
use App\Validator\Constraints\NoneOfItsChildren; use App\Validator\Constraints\NoneOfItsChildren;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity; use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
use Symfony\Component\Serializer\Annotation\DiscriminatorMap;
use Symfony\Component\Serializer\Annotation\Groups; use Symfony\Component\Serializer\Annotation\Groups;
/** /**
@ -102,7 +100,7 @@ abstract class StructuralDBElement extends AttachmentContainingDBElement
* @ORM\Column(type="text") * @ORM\Column(type="text")
* @Groups({"simple", "extended", "full"}) * @Groups({"simple", "extended", "full"})
*/ */
protected $comment = ""; protected $comment = '';
/** /**
* @var int * @var int
@ -132,6 +130,7 @@ abstract class StructuralDBElement extends AttachmentContainingDBElement
public function __construct() public function __construct()
{ {
parent::__construct();
$this->children = new ArrayCollection(); $this->children = new ArrayCollection();
} }
@ -154,16 +153,16 @@ abstract class StructuralDBElement extends AttachmentContainingDBElement
$class_name = \get_class($this); $class_name = \get_class($this);
//Check if both elements compared, are from the same type: //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!'); 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; return false;
} }
//If this' parents element, is $another_element, then we are finished //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 || $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 $overflow = 20; //We only allow 20 levels depth
while (null != $element->parent && $overflow >= 0) { while (null !== $element->parent && $overflow >= 0) {
$element = $element->parent; $element = $element->parent;
$this->full_path_strings[] = $element->getName(); $this->full_path_strings[] = $element->getName();
//Decrement to prevent mem overflow. //Decrement to prevent mem overflow.

View file

@ -83,13 +83,13 @@ class Category extends PartsContainingDBElement
* @var string * @var string
* @ORM\Column(type="text") * @ORM\Column(type="text")
*/ */
protected $partname_hint = ""; protected $partname_hint = '';
/** /**
* @var string * @var string
* @ORM\Column(type="text") * @ORM\Column(type="text")
*/ */
protected $partname_regex = ""; protected $partname_regex = '';
/** /**
* @var bool * @var bool
@ -119,13 +119,13 @@ class Category extends PartsContainingDBElement
* @var string * @var string
* @ORM\Column(type="text") * @ORM\Column(type="text")
*/ */
protected $default_description = ""; protected $default_description = '';
/** /**
* @var string * @var string
* @ORM\Column(type="text") * @ORM\Column(type="text")
*/ */
protected $default_comment = ""; protected $default_comment = '';
/** /**
* Returns the ID as an string, defined by the element class. * Returns the ID as an string, defined by the element class.

View file

@ -128,73 +128,14 @@ class Footprint extends PartsContainingDBElement
/** /**
* Get the filename of the 3d model (absolute path from filesystem root). * 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) * @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 * * 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; 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 * Setters
@ -203,25 +144,8 @@ class Footprint extends PartsContainingDBElement
/** /**
* Change the filename of this footprint. * Change the filename of this footprint.
* * @param string $new_filename The new file name
* 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 * @return Footprint
*
* @throws \Exception if there was an error
*/ */
public function setFilename(string $new_filename): self public function setFilename(string $new_filename): self
{ {
@ -232,8 +156,9 @@ class Footprint extends PartsContainingDBElement
/** /**
* Change the 3d model filename of this footprint. * 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 public function set3dFilename(string $new_filename): self
{ {

View file

@ -33,7 +33,6 @@ namespace App\Entity\Parts;
use App\Entity\Base\PartsContainingDBElement; use App\Entity\Base\PartsContainingDBElement;
use App\Entity\Base\StructuralDBElement;
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;
use Symfony\Component\Validator\Constraints as Assert; use Symfony\Component\Validator\Constraints as Assert;
@ -127,7 +126,7 @@ class MeasurementUnit extends PartsContainingDBElement
*/ */
public function setIsInteger(bool $isInteger): MeasurementUnit public function setIsInteger(bool $isInteger): MeasurementUnit
{ {
$this->isInteger = $isInteger; $this->is_integer = $isInteger;
return $this; return $this;
} }
@ -145,7 +144,7 @@ class MeasurementUnit extends PartsContainingDBElement
*/ */
public function setUseSIPrefix(bool $usesSIPrefixes): MeasurementUnit public function setUseSIPrefix(bool $usesSIPrefixes): MeasurementUnit
{ {
$this->useSIPrefixes = $usesSIPrefixes; $this->use_si_prefix = $usesSIPrefixes;
return $this; return $this;
} }
} }

View file

@ -71,7 +71,6 @@ 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;
use Doctrine\ORM\PersistentCollection;
use Symfony\Component\Validator\Constraints as Assert; use Symfony\Component\Validator\Constraints as Assert;
/** /**
@ -169,7 +168,7 @@ class Part extends AttachmentContainingDBElement
* *
* @ColumnSecurity(prefix="name") * @ColumnSecurity(prefix="name")
*/ */
protected $name = ''; protected $name;
/** /**
* @var string * @var string
@ -303,14 +302,20 @@ class Part extends AttachmentContainingDBElement
/** /**
* Get the count of parts which must be in stock at least. * 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 public function getMinAmount(): float
{ {
if ($this->useFloatAmount()) {
return $this->minamount; return $this->minamount;
} }
return round($this->minamount);
}
/** /**
* Get the comment associated with this part. * Get the comment associated with this part.
* *
@ -476,7 +481,7 @@ class Part extends AttachmentContainingDBElement
* *
* @param bool $hide_obsolete If true, obsolete orderdetails will NOT be returned * @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) * (empty array if there are no ones)
* * the array is sorted by the suppliers names / minimum order quantity * * 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. * 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. * 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 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. * Sets the measurement unit in which the part's amount should be measured.
* Set to null, if the part should be measured in quantities. * Set to null, if the part should be measured in quantities.
* @param ?MeasurementUnit $partUnit * @param MeasurementUnit|null $partUnit
* @return Part * @return Part
*/ */
public function setPartUnit(?MeasurementUnit $partUnit): 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. * Set the minimum amount of parts that have to be instock.
* See getPartUnit() for the associated unit. * 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 * @return self
*/ */

View file

@ -33,7 +33,6 @@ namespace App\Entity\Parts;
use App\Entity\Base\DBElement; use App\Entity\Base\DBElement;
use App\Entity\Base\NamedDBElement;
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;
@ -56,13 +55,13 @@ class PartLot extends DBElement
* @var string A short description about this lot, shown in table * @var string A short description about this lot, shown in table
* @ORM\Column(type="text") * @ORM\Column(type="text")
*/ */
protected $description = ""; protected $description = '';
/** /**
* @var string A comment stored with this lot. * @var string A comment stored with this lot.
* @ORM\Column(type="text") * @ORM\Column(type="text")
*/ */
protected $comment = ""; protected $comment = '';
/** /**
* @var ?\DateTime Set a time until when the lot must be used. * @var ?\DateTime Set a time until when the lot must be used.
@ -126,7 +125,7 @@ class PartLot extends DBElement
*/ */
public function isExpired(): ?bool public function isExpired(): ?bool
{ {
if ($this->expiration_date == null) { if ($this->expiration_date === null) {
return null; return null;
} }

View file

@ -61,9 +61,7 @@ declare(strict_types=1);
namespace App\Entity\Parts; namespace App\Entity\Parts;
use App\Entity\Base\PartsContainingDBElement;
use App\Entity\Base\StructuralDBElement; use App\Entity\Base\StructuralDBElement;
use App\Form\Type\StructuralEntityType;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
/** /**

View file

@ -100,7 +100,7 @@ class Currency extends StructuralDBElement
{ {
$tmp = $this->getExchangeRate(); $tmp = $this->getExchangeRate();
if ($tmp == null) { if ($tmp === null) {
return null; return null;
} }

View file

@ -237,7 +237,7 @@ class Orderdetail extends DBElement
public function getPrice(int $quantity = 1, $multiplier = null) : ?float public function getPrice(int $quantity = 1, $multiplier = null) : ?float
{ {
if (($quantity == 0) && ($multiplier === null)) { if (($quantity === 0) && ($multiplier === null)) {
return 0.0; return 0.0;
} }
@ -258,7 +258,7 @@ class Orderdetail extends DBElement
$correct_pricedetails = $pricedetails; $correct_pricedetails = $pricedetails;
} }
if ($correct_pricedetails == null) { if ($correct_pricedetails === null) {
return null; return null;
} }
@ -276,22 +276,21 @@ class Orderdetail extends DBElement
*********************************************************************************/ *********************************************************************************/
/** /**
* Set the supplier ID. * Sets the new supplier associated with this orderdetail.
* * @param Supplier $new_supplier
* @param int $new_supplier_id the ID of the 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!'); $this->supplier = $new_supplier;
//TODO;
return $this; return $this;
} }
/** /**
* Set the supplier part-nr. * Set the supplier part-nr.
*
* @param string $new_supplierpartnr the new supplier-part-nr * @param string $new_supplierpartnr the new supplier-part-nr
* @return Orderdetail
* @return Orderdetail
*/ */
public function setSupplierpartnr(string $new_supplierpartnr): self 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. * Set if the part is obsolete at the supplier of that orderdetails.
*
* @param bool $new_obsolete true means that this part is obsolete * @param bool $new_obsolete true means that this part is obsolete
* @return Orderdetail
* @return Orderdetail
*/ */
public function setObsolete(bool $new_obsolete): self 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. * Sets the custom product supplier URL for this order detail.
* Set this to "", if the function getSupplierProductURL should return the automatic generated URL. * Set this to "", if the function getSupplierProductURL should return the automatic generated URL.
*
* @param $new_url string The new URL for the supplier URL. * @param $new_url string The new URL for the supplier URL.
* @return Orderdetail
* @return Orderdetail
*/ */
public function setSupplierProductUrl(string $new_url) public function setSupplierProductUrl(string $new_url)
{ {

View file

@ -220,6 +220,7 @@ class Pricedetail extends DBElement
public function setCurrency(?Currency $currency): Pricedetail public function setCurrency(?Currency $currency): Pricedetail
{ {
$this->currency = $currency; $this->currency = $currency;
return $this;
} }
/** /**

View file

@ -91,7 +91,7 @@ class User extends NamedDBElement implements UserInterface, HasPermissionsInterf
* @ORM\Column(type="string", length=180, unique=true) * @ORM\Column(type="string", length=180, unique=true)
* @Assert\NotBlank * @Assert\NotBlank
*/ */
protected $name = ""; protected $name = '';
/** /**
* //@ORM\Column(type="json"). * //@ORM\Column(type="json").

View file

@ -33,7 +33,6 @@ namespace App\Repository;
use App\Entity\Base\StructuralDBElement; use App\Entity\Base\StructuralDBElement;
use Doctrine\Common\Collections\Criteria;
use Doctrine\ORM\EntityRepository; use Doctrine\ORM\EntityRepository;
class StructuralDBElementRepository extends EntityRepository class StructuralDBElementRepository extends EntityRepository