Applied code style rules to src/

This commit is contained in:
Jan Böhmer 2020-01-05 15:46:58 +01:00
parent 700c049d26
commit f861de791f
186 changed files with 1462 additions and 1059 deletions

View file

@ -6,5 +6,5 @@ parameters:
- "clean-code"
- "common"
# very nice to have ↓
- "symplify"
#- "symplify"
- "symfony"

View file

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
@ -51,7 +54,7 @@ class CleanAttachmentsCommand extends Command
parent::__construct();
}
protected function configure()
protected function configure(): void
{
$this
->setDescription('Lists (and deletes if wanted) attachments files that are not used anymore (abandoned files).')
@ -59,7 +62,7 @@ class CleanAttachmentsCommand extends Command
' These files are not needed and can eventually deleted.');
}
protected function execute(InputInterface $input, OutputInterface $output)
protected function execute(InputInterface $input, OutputInterface $output): void
{
$io = new SymfonyStyle($input, $output);
@ -84,7 +87,7 @@ class CleanAttachmentsCommand extends Command
foreach ($finder as $file) {
//If not attachment object uses this file, print it
if (0 == \count($this->reverseSearch->findAttachmentsByFile($file))) {
if (0 === \count($this->reverseSearch->findAttachmentsByFile($file))) {
$file_list[] = $file;
$table->addRow([
$fs->makePathRelative($file->getPathname(), $mediaPath),
@ -99,7 +102,7 @@ class CleanAttachmentsCommand extends Command
$continue = $io->confirm(sprintf('Found %d abandoned files. Do you want to delete them? This can not be undone!', \count($file_list)), false);
if (!$continue) {
if (! $continue) {
//We are finished here, when no files should be deleted
return;
}

View file

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
@ -67,7 +70,7 @@ class ConvertBBCodeCommand extends Command
parent::__construct();
}
protected function configure()
protected function configure(): void
{
$this
->setDescription('Converts BBCode used in old Part-DB versions to newly used Markdown')
@ -97,7 +100,7 @@ class ConvertBBCodeCommand extends Command
];
}
protected function execute(InputInterface $input, OutputInterface $output)
protected function execute(InputInterface $input, OutputInterface $output): void
{
$io = new SymfonyStyle($input, $output);
$targets = $this->getTargetsLists();
@ -126,7 +129,7 @@ class ConvertBBCodeCommand extends Command
//In verbose mode print the names of the entities
foreach ($results as $result) {
/* @var NamedDBElement $result */
/** @var NamedDBElement $result */
$io->writeln(
'Convert entity: '.$result->getName().' ('.$result->getIDString().')',
OutputInterface::VERBOSITY_VERBOSE
@ -135,7 +138,7 @@ class ConvertBBCodeCommand extends Command
//Retrieve bbcode from entity
$bbcode = $this->propertyAccessor->getValue($result, $property);
//Check if the current property really contains BBCode
if (!preg_match(static::BBCODE_REGEX, $bbcode)) {
if (! preg_match(static::BBCODE_REGEX, $bbcode)) {
continue;
}
$io->writeln(
@ -156,7 +159,7 @@ class ConvertBBCodeCommand extends Command
}
//If we are not in dry run, save changes to DB
if (!$input->getOption('dry-run')) {
if (! $input->getOption('dry-run')) {
$this->em->flush();
$io->success('Changes saved to DB successfully!');
}

View file

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
@ -45,7 +48,7 @@ class SetPasswordCommand extends Command
parent::__construct();
}
protected function configure()
protected function configure(): void
{
$this
->setDescription('Sets the password of a user')
@ -54,18 +57,16 @@ class SetPasswordCommand extends Command
;
}
protected function execute(InputInterface $input, OutputInterface $output)
protected function execute(InputInterface $input, OutputInterface $output): void
{
$io = new SymfonyStyle($input, $output);
$user_name = $input->getArgument('user');
/**
* @var User
*/
/** @var User */
$users = $this->entityManager->getRepository(User::class)->findBy(['name' => $user_name]);
$user = $users[0];
if (null == $user) {
if (null === $user) {
$io->error(sprintf('No user with the given username %s found in the database!', $user_name));
return;
@ -77,14 +78,14 @@ class SetPasswordCommand extends Command
sprintf('You are going to change the password of %s with ID %d. Proceed?',
$user->getFullName(true), $user->getID()));
if (!$proceed) {
if (! $proceed) {
return;
}
$success = false;
$new_password = '';
while (!$success) {
while (! $success) {
$pw1 = $io->askHidden('Please enter new password:');
$pw2 = $io->askHidden('Please confirm:');
if ($pw1 !== $pw2) {

View file

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
@ -49,7 +52,7 @@ class UpdateExchangeRatesCommand extends Command
parent::__construct();
}
protected function configure()
protected function configure(): void
{
$this
->setDescription('Updates the currency exchange rates.')
@ -62,7 +65,7 @@ class UpdateExchangeRatesCommand extends Command
null);
}
protected function execute(InputInterface $input, OutputInterface $output)
protected function execute(InputInterface $input, OutputInterface $output): void
{
$io = new SymfonyStyle($input, $output);
@ -88,7 +91,7 @@ class UpdateExchangeRatesCommand extends Command
$repo = $this->em->getRepository(Currency::class);
$candidates = [];
if (!empty($iso_code)) {
if (! empty($iso_code)) {
$candidates = $repo->findBy(['iso_code' => $iso_code]);
} else {
$candidates = $repo->findAll();

View file

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*

View file

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*

View file

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
@ -80,7 +83,7 @@ abstract class BaseAdminController extends AbstractController
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
//Check if we editing a user and if we need to change the password of it
if ($entity instanceof User && !empty($form['new_password']->getData())) {
if ($entity instanceof User && ! empty($form['new_password']->getData())) {
$password = $this->passwordEncoder->encodePassword($entity, $form['new_password']->getData());
$entity->setPassword($password);
//By default the user must change the password afterwards
@ -90,11 +93,12 @@ abstract class BaseAdminController extends AbstractController
//Upload passed files
$attachments = $form['attachments'];
foreach ($attachments as $attachment) {
/** @var $attachment FormInterface */
/** @var FormInterface $attachment */
$options = [
'secure_attachment' => $attachment['secureFile']->getData(),
'download_url' => $attachment['downloadURL']->getData(),
];
try {
$this->attachmentSubmitHandler->handleFormSubmit($attachment->getData(), $attachment['file']->getData(), $options);
} catch (AttachmentDownloadException $ex) {
@ -112,7 +116,7 @@ abstract class BaseAdminController extends AbstractController
//Rebuild form, so it is based on the updated data. Important for the parent field!
//We can not use dynamic form events here, because the parent entity list is build from database!
$form = $this->createForm($this->form_class, $entity, ['attachment_class' => $this->attachment_class]);
} elseif ($form->isSubmitted() && !$form->isValid()) {
} elseif ($form->isSubmitted() && ! $form->isValid()) {
$this->addFlash('error', 'entity.edit_flash.invalid');
}
@ -136,7 +140,7 @@ abstract class BaseAdminController extends AbstractController
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
if ($new_entity instanceof User && !empty($form['new_password']->getData())) {
if ($new_entity instanceof User && ! empty($form['new_password']->getData())) {
$password = $this->passwordEncoder->encodePassword($new_entity, $form['new_password']->getData());
$new_entity->setPassword($password);
//By default the user must change the password afterwards
@ -146,11 +150,12 @@ abstract class BaseAdminController extends AbstractController
//Upload passed files
$attachments = $form['attachments'];
foreach ($attachments as $attachment) {
/** @var $attachment FormInterface */
/** @var FormInterface $attachment */
$options = [
'secure_attachment' => $attachment['secureFile']->getData(),
'download_url' => $attachment['downloadURL']->getData(),
];
try {
$this->attachmentSubmitHandler->handleFormSubmit($attachment->getData(), $attachment['file']->getData(), $options);
} catch (AttachmentDownloadException $ex) {
@ -168,7 +173,7 @@ abstract class BaseAdminController extends AbstractController
return $this->redirectToRoute($this->route_base.'_edit', ['id' => $new_entity->getID()]);
}
if ($form->isSubmitted() && !$form->isValid()) {
if ($form->isSubmitted() && ! $form->isValid()) {
$this->addFlash('error', 'entity.created_flash.invalid');
}
@ -187,7 +192,7 @@ abstract class BaseAdminController extends AbstractController
$errors = $importer->fileToDBEntities($file, $this->entity_class, $options);
foreach ($errors as $name => $error) {
/* @var $error ConstraintViolationList */
/** @var ConstraintViolationList $error */
$this->addFlash('error', $name.':'.$error);
}
}

View file

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*

View file

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*

View file

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*

View file

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
@ -32,7 +35,6 @@ use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Serializer\SerializerInterface;
/**
* @Route("/footprint")
@ -76,8 +78,6 @@ class FootprintController extends BaseAdminController
/**
* @Route("/export", name="footprint_export_all")
*
* @param SerializerInterface $serializer
*
* @return Response
*/
public function exportAll(EntityManagerInterface $em, EntityExporter $exporter, Request $request)

View file

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
@ -32,7 +35,6 @@ use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Serializer\SerializerInterface;
/**
* @Route("/manufacturer")
@ -76,8 +78,6 @@ class ManufacturerController extends BaseAdminController
/**
* @Route("/export", name="manufacturer_export_all")
*
* @param SerializerInterface $serializer
*
* @return Response
*/
public function exportAll(EntityManagerInterface $em, EntityExporter $exporter, Request $request)

View file

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
@ -32,7 +35,6 @@ use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Serializer\SerializerInterface;
/**
* @Route("/measurement_unit")
@ -76,8 +78,6 @@ class MeasurementUnitController extends BaseAdminController
/**
* @Route("/export", name="measurement_unit_export_all")
*
* @param SerializerInterface $serializer
*
* @return Response
*/
public function exportAll(EntityManagerInterface $em, EntityExporter $exporter, Request $request)

View file

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
@ -31,7 +34,6 @@ use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Serializer\SerializerInterface;
/**
* @Route("/store_location")
@ -75,8 +77,6 @@ class StorelocationController extends BaseAdminController
/**
* @Route("/export", name="store_location_export_all")
*
* @param SerializerInterface $serializer
*
* @return Response
*/
public function exportAll(EntityManagerInterface $em, EntityExporter $exporter, Request $request)

View file

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
@ -31,7 +34,6 @@ use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Serializer\SerializerInterface;
/**
* @Route("/supplier")
@ -75,8 +77,6 @@ class SupplierController extends BaseAdminController
/**
* @Route("/export", name="supplier_export_all")
*
* @param SerializerInterface $serializer
*
* @return Response
*/
public function exportAll(EntityManagerInterface $em, EntityExporter $exporter, Request $request)

View file

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
@ -49,7 +52,7 @@ class AttachmentFileController extends AbstractController
throw new \RuntimeException('You can not download external attachments!');
}
if (!$helper->isFileExisting($attachment)) {
if (! $helper->isFileExisting($attachment)) {
throw new \RuntimeException('The file associated with the attachment is not existing!');
}
@ -79,7 +82,7 @@ class AttachmentFileController extends AbstractController
throw new \RuntimeException('You can not download external attachments!');
}
if (!$helper->isFileExisting($attachment)) {
if (! $helper->isFileExisting($attachment)) {
throw new \RuntimeException('The file associated with the attachment is not existing!');
}

View file

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*

View file

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*

View file

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
@ -80,11 +82,12 @@ class PartController extends AbstractController
//Upload passed files
$attachments = $form['attachments'];
foreach ($attachments as $attachment) {
/** @var $attachment FormInterface */
/** @var FormInterface $attachment */
$options = [
'secure_attachment' => $attachment['secureFile']->getData(),
'download_url' => $attachment['downloadURL']->getData(),
];
try {
$attachmentSubmitHandler->handleFormSubmit($attachment->getData(), $attachment['file']->getData(), $options);
} catch (AttachmentDownloadException $ex) {
@ -100,7 +103,7 @@ class PartController extends AbstractController
$this->addFlash('info', 'part.edited_flash');
//Reload form, so the SIUnitType entries use the new part unit
$form = $this->createForm(PartBaseType::class, $part);
} elseif ($form->isSubmitted() && !$form->isValid()) {
} elseif ($form->isSubmitted() && ! $form->isValid()) {
$this->addFlash('error', 'part.edited_flash.invalid');
}
@ -163,11 +166,12 @@ class PartController extends AbstractController
//Upload passed files
$attachments = $form['attachments'];
foreach ($attachments as $attachment) {
/** @var $attachment FormInterface */
/** @var FormInterface $attachment */
$options = [
'secure_attachment' => $attachment['secureFile']->getData(),
'download_url' => $attachment['downloadURL']->getData(),
];
try {
$attachmentSubmitHandler->handleFormSubmit($attachment->getData(), $attachment['file']->getData(), $options);
} catch (AttachmentDownloadException $ex) {
@ -185,7 +189,7 @@ class PartController extends AbstractController
return $this->redirectToRoute('part_edit', ['id' => $new_part->getID()]);
}
if ($form->isSubmitted() && !$form->isValid()) {
if ($form->isSubmitted() && ! $form->isValid()) {
$this->addFlash('error', 'part.created_flash.invalid');
}

View file

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
@ -37,8 +40,6 @@ class PartListsController extends AbstractController
/**
* @Route("/category/{id}/parts", name="part_list_category")
*
* @param $id int The id of the category
*
* @return \Symfony\Component\HttpFoundation\JsonResponse|\Symfony\Component\HttpFoundation\Response
*/
public function showCategory(Category $category, Request $request, DataTableFactory $dataTable)
@ -59,8 +60,6 @@ class PartListsController extends AbstractController
/**
* @Route("/footprint/{id}/parts", name="part_list_footprint")
*
* @param $id int The id of the category
*
* @return \Symfony\Component\HttpFoundation\JsonResponse|\Symfony\Component\HttpFoundation\Response
*/
public function showFootprint(Footprint $footprint, Request $request, DataTableFactory $dataTable)
@ -81,8 +80,6 @@ class PartListsController extends AbstractController
/**
* @Route("/manufacturer/{id}/parts", name="part_list_manufacturer")
*
* @param $id int The id of the category
*
* @return \Symfony\Component\HttpFoundation\JsonResponse|\Symfony\Component\HttpFoundation\Response
*/
public function showManufacturer(Manufacturer $manufacturer, Request $request, DataTableFactory $dataTable)
@ -103,8 +100,6 @@ class PartListsController extends AbstractController
/**
* @Route("/store_location/{id}/parts", name="part_list_store_location")
*
* @param $id int The id of the category
*
* @return \Symfony\Component\HttpFoundation\JsonResponse|\Symfony\Component\HttpFoundation\Response
*/
public function showStorelocation(Storelocation $storelocation, Request $request, DataTableFactory $dataTable)
@ -125,8 +120,6 @@ class PartListsController extends AbstractController
/**
* @Route("/supplier/{id}/parts", name="part_list_supplier")
*
* @param $id int The id of the category
*
* @return \Symfony\Component\HttpFoundation\JsonResponse|\Symfony\Component\HttpFoundation\Response
*/
public function showSupplier(Supplier $supplier, Request $request, DataTableFactory $dataTable)

View file

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
@ -55,7 +58,7 @@ class RedirectController extends AbstractController
//Check if a user has set a preferred language setting:
$user = $this->getUser();
if (($user instanceof User) && !empty($user->getLanguage())) {
if (($user instanceof User) && ! empty($user->getLanguage())) {
$locale = $user->getLanguage();
}
@ -63,7 +66,7 @@ class RedirectController extends AbstractController
$new_url = $request->getUriForPath('/'.$locale.$request->getPathInfo());
//If either mod_rewrite is not enabled or the index.php version is enforced, add index.php to the string
if (($this->enforce_index_php || !$this->checkIfModRewriteAvailable())
if (($this->enforce_index_php || ! $this->checkIfModRewriteAvailable())
&& false === strpos($new_url, 'index.php')) {
//Like Request::getUriForPath only with index.php
$new_url = $request->getSchemeAndHttpHost().$request->getBaseUrl().'/index.php/'.$locale.$request->getPathInfo();
@ -81,7 +84,7 @@ class RedirectController extends AbstractController
*/
public function checkIfModRewriteAvailable()
{
if (!\function_exists('apache_get_modules')) {
if (! \function_exists('apache_get_modules')) {
//If we can not check for apache modules, we just hope for the best and assume url rewriting is available
//If you want to enforce index.php versions of the url, you can override this via ENV vars.
return true;

View file

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
@ -69,7 +72,7 @@ class SecurityController extends AbstractController
*/
public function requestPwReset(PasswordResetManager $passwordReset, Request $request)
{
if (!$this->allow_email_pw_reset) {
if (! $this->allow_email_pw_reset) {
throw new AccessDeniedHttpException('The password reset via email is disabled!');
}
@ -109,9 +112,9 @@ class SecurityController extends AbstractController
/**
* @Route("/pw_reset/new_pw/{user}/{token}", name="pw_reset_new_pw")
*/
public function pwResetNewPw(PasswordResetManager $passwordReset, Request $request, string $user = null, string $token = null)
public function pwResetNewPw(PasswordResetManager $passwordReset, Request $request, ?string $user = null, ?string $token = null)
{
if (!$this->allow_email_pw_reset) {
if (! $this->allow_email_pw_reset) {
throw new AccessDeniedHttpException('The password reset via email is disabled!');
}
@ -149,7 +152,7 @@ class SecurityController extends AbstractController
$data = $form->getData();
//Try to set the new password
$success = $passwordReset->setNewPassword($data['username'], $data['token'], $data['new_password']);
if (!$success) {
if (! $success) {
$this->addFlash('error', 'pw_reset.new_pw.error');
} else {
$this->addFlash('success', 'pw_reset.new_pw.success');
@ -166,7 +169,7 @@ class SecurityController extends AbstractController
/**
* @Route("/logout", name="logout")
*/
public function logout()
public function logout(): void
{
throw new \RuntimeException('Will be intercepted before getting here');
}

View file

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
@ -61,7 +64,7 @@ class TreeController extends AbstractController
* @Route("/category/{id}", name="tree_category")
* @Route("/categories")
*/
public function categoryTree(Category $category = null)
public function categoryTree(?Category $category = null)
{
$tree = $this->treeGenerator->getTreeView(Category::class, $category);
@ -72,7 +75,7 @@ class TreeController extends AbstractController
* @Route("/footprint/{id}", name="tree_footprint")
* @Route("/footprints")
*/
public function footprintTree(Footprint $footprint = null)
public function footprintTree(?Footprint $footprint = null)
{
$tree = $this->treeGenerator->getTreeView(Footprint::class, $footprint);
@ -83,7 +86,7 @@ class TreeController extends AbstractController
* @Route("/location/{id}", name="tree_location")
* @Route("/locations")
*/
public function locationTree(Storelocation $location = null)
public function locationTree(?Storelocation $location = null)
{
$tree = $this->treeGenerator->getTreeView(Storelocation::class, $location);
@ -94,7 +97,7 @@ class TreeController extends AbstractController
* @Route("/manufacturer/{id}", name="tree_manufacturer")
* @Route("/manufacturers")
*/
public function manufacturerTree(Manufacturer $manufacturer = null)
public function manufacturerTree(?Manufacturer $manufacturer = null)
{
$tree = $this->treeGenerator->getTreeView(Manufacturer::class, $manufacturer);
@ -105,7 +108,7 @@ class TreeController extends AbstractController
* @Route("/supplier/{id}", name="tree_supplier")
* @Route("/suppliers")
*/
public function supplierTree(Supplier $supplier = null)
public function supplierTree(?Supplier $supplier = null)
{
$tree = $this->treeGenerator->getTreeView(Supplier::class, $supplier);
@ -116,7 +119,7 @@ class TreeController extends AbstractController
* @Route("/device/{id}", name="tree_device")
* @Route("/devices")
*/
public function deviceTree(Device $device = null)
public function deviceTree(?Device $device = null)
{
$tree = $this->treeGenerator->getTreeView(Device::class, $device, '');

View file

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*

View file

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
@ -34,7 +37,6 @@ use Symfony\Component\Asset\Packages;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Serializer\SerializerInterface;
/**
* @Route("/user")
@ -106,8 +108,6 @@ class UserController extends AdminPages\BaseAdminController
/**
* @Route("/export", name="user_export_all")
*
* @param SerializerInterface $serializer
*
* @return Response
*/
public function exportAll(EntityManagerInterface $em, EntityExporter $exporter, Request $request)
@ -183,7 +183,7 @@ class UserController extends AdminPages\BaseAdminController
$url = 'https://www.gravatar.com/avatar/';
$url .= md5(strtolower(trim($email)));
$url .= "?s=$s&d=$d&r=$r";
$url .= "?s=${s}&d=${d}&r=${r}";
if ($img) {
$url = '<img src="'.$url.'"';
foreach ($atts as $key => $val) {

View file

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
@ -61,12 +64,13 @@ class UserSettingsController extends AbstractController
//When user change its settings, he should be logged in fully.
$this->denyAccessUnlessGranted('IS_AUTHENTICATED_FULLY');
if (!$user instanceof User) {
if (! $user instanceof User) {
return new \RuntimeException('This controller only works only for Part-DB User objects!');
}
if (empty($user->getBackupCodes())) {
$this->addFlash('error', 'tfa_backup.no_codes_enabled');
throw new \RuntimeException('You do not have any backup codes enabled, therefore you can not view them!');
}
@ -91,7 +95,7 @@ class UserSettingsController extends AbstractController
//When user change its settings, he should be logged in fully.
$this->denyAccessUnlessGranted('IS_AUTHENTICATED_FULLY');
if (!$user instanceof User) {
if (! $user instanceof User) {
throw new \RuntimeException('This controller only works only for Part-DB User objects!');
}
@ -103,12 +107,14 @@ class UserSettingsController extends AbstractController
$u2f = $key_repo->find($key_id);
if (null === $u2f) {
$this->addFlash('danger', 'tfa_u2f.u2f_delete.not_existing');
throw new \RuntimeException('Key not existing!');
}
//User can only delete its own U2F keys
if ($u2f->getUser() !== $user) {
$this->addFlash('danger', 'tfa_u2f.u2f_delete.access_denied');
throw new \RuntimeException('You can only delete your own U2F keys!');
}
@ -138,7 +144,7 @@ class UserSettingsController extends AbstractController
//When user change its settings, he should be logged in fully.
$this->denyAccessUnlessGranted('IS_AUTHENTICATED_FULLY');
if (!$user instanceof User) {
if (! $user instanceof User) {
return new \RuntimeException('This controller only works only for Part-DB User objects!');
}
@ -158,9 +164,7 @@ class UserSettingsController extends AbstractController
*/
public function userSettings(Request $request, EntityManagerInterface $em, UserPasswordEncoderInterface $passwordEncoder, GoogleAuthenticator $googleAuthenticator, BackupCodeManager $backupCodeManager)
{
/**
* @var User
*/
/** @var User */
$user = $this->getUser();
$page_need_reload = false;
@ -168,7 +172,7 @@ class UserSettingsController extends AbstractController
//When user change its settings, he should be logged in fully.
$this->denyAccessUnlessGranted('IS_AUTHENTICATED_FULLY');
if (!$user instanceof User) {
if (! $user instanceof User) {
throw new \RuntimeException('This controller only works only for Part-DB User objects!');
}
@ -180,7 +184,7 @@ class UserSettingsController extends AbstractController
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid() && !$this->demo_mode) {
if ($form->isSubmitted() && $form->isValid() && ! $this->demo_mode) {
//Check if user theme setting has changed
if ($user->getTheme() !== $em->getUnitOfWork()->getOriginalEntityData($user)['theme']) {
$page_need_reload = true;
@ -227,7 +231,7 @@ class UserSettingsController extends AbstractController
$pw_form->handleRequest($request);
//Check if password if everything was correct, then save it to User and DB
if ($pw_form->isSubmitted() && $pw_form->isValid() && !$this->demo_mode) {
if ($pw_form->isSubmitted() && $pw_form->isValid() && ! $this->demo_mode) {
$password = $passwordEncoder->encodePassword($user, $pw_form['new_password']->getData());
$user->setPassword($password);
@ -242,14 +246,14 @@ class UserSettingsController extends AbstractController
//Handle 2FA things
$google_form = $this->createForm(TFAGoogleSettingsType::class, $user);
$google_enabled = $user->isGoogleAuthenticatorEnabled();
if (!$form->isSubmitted() && !$google_enabled) {
if (! $form->isSubmitted() && ! $google_enabled) {
$user->setGoogleAuthenticatorSecret($googleAuthenticator->generateSecret());
$google_form->get('googleAuthenticatorSecret')->setData($user->getGoogleAuthenticatorSecret());
}
$google_form->handleRequest($request);
if ($google_form->isSubmitted() && $google_form->isValid() && !$this->demo_mode) {
if (!$google_enabled) {
if ($google_form->isSubmitted() && $google_form->isValid() && ! $this->demo_mode) {
if (! $google_enabled) {
//Save 2FA settings (save secrets)
$user->setGoogleAuthenticatorSecret($google_form->get('googleAuthenticatorSecret')->getData());
$backupCodeManager->enableBackupCodes($user);
@ -277,7 +281,7 @@ class UserSettingsController extends AbstractController
])->getForm();
$backup_form->handleRequest($request);
if ($backup_form->isSubmitted() && $backup_form->isValid() && !$this->demo_mode) {
if ($backup_form->isSubmitted() && $backup_form->isValid() && ! $this->demo_mode) {
$backupCodeManager->regenerateBackupCodes($user);
$em->flush();
$this->addFlash('success', 'user.settings.2fa.backup_codes.regenerated');

View file

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
@ -26,7 +29,7 @@ use Doctrine\Common\Persistence\ObjectManager;
class AppFixtures extends Fixture
{
public function load(ObjectManager $manager)
public function load(ObjectManager $manager): void
{
// $product = new Product();
// $manager->persist($product);

View file

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
@ -46,7 +49,7 @@ class DataStructureFixtures extends Fixture
/**
* Load data fixtures with the passed EntityManager.
*/
public function load(ObjectManager $manager)
public function load(ObjectManager $manager): void
{
//Reset autoincrement
$types = [AttachmentType::class, Device::class, Category::class, Footprint::class, Manufacturer::class,
@ -65,14 +68,14 @@ class DataStructureFixtures extends Fixture
* @param string $class The class for which the nodes should be generated (must be a StructuralDBElement child)
* @param ObjectManager $manager The ObjectManager that should be used to persist the nodes
*/
public function createNodesForClass(string $class, ObjectManager $manager)
public function createNodesForClass(string $class, ObjectManager $manager): void
{
if (!new $class() instanceof StructuralDBElement) {
if (! new $class() instanceof StructuralDBElement) {
throw new \InvalidArgumentException('$class must be a StructuralDBElement!');
}
$table_name = $this->em->getClassMetadata($class)->getTableName();
$this->em->getConnection()->exec("ALTER TABLE `$table_name` AUTO_INCREMENT = 1;");
$this->em->getConnection()->exec("ALTER TABLE `${table_name}` AUTO_INCREMENT = 1;");
/** @var StructuralDBElement $node1 */
$node1 = new $class();

View file

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
@ -31,21 +34,21 @@ class GroupFixtures extends Fixture
public const USERS = 'group-users';
public const READONLY = 'group-readonly';
public function load(ObjectManager $manager)
public function load(ObjectManager $manager): void
{
$admins = new Group();
$admins->setName('admins');
//Perm values taken from Version 1
$admins->getPermissions()->setRawPermissionValues([
'system' => '21', 'groups' => '1365', 'users' => '87381', 'self' => '85', 'config' => '85',
'database' => '21', 'parts' => '1431655765', 'parts_name' => '5', 'parts_description' => '5',
'parts_footprint' => '5', 'parts_manufacturer' => '5', 'parts_comment' => '5', 'parts_order' => '5',
'parts_orderdetails' => '341', 'parts_prices' => '341', 'parts_attachments' => '341', 'devices' => '5461',
'devices_parts' => '325', 'storelocations' => '5461', 'footprints' => '5461', 'categories' => '5461',
'suppliers' => '5461', 'manufacturers' => '5461', 'attachment_types' => '1365', 'tools' => '1365',
'labels' => '21', 'parts_category' => '5', 'parts_minamount' => '5', 'parts_lots' => '85', 'parts_tags' => '5',
'parts_unit' => '5', 'parts_mass' => '5', 'parts_status' => '5', 'parts_mpn' => '5', 'currencies' => '5461',
'measurement_units' => '5461',
'system' => 21, 'groups' => 1365, 'users' => 87381, 'self' => 85, 'config' => 85,
'database' => 21, 'parts' => 1431655765, 'parts_name' => 5, 'parts_description' => 5,
'parts_footprint' => 5, 'parts_manufacturer' => 5, 'parts_comment' => 5, 'parts_order' => 5,
'parts_orderdetails' => 341, 'parts_prices' => 341, 'parts_attachments' => 341, 'devices' => 5461,
'devices_parts' => 325, 'storelocations' => 5461, 'footprints' => 5461, 'categories' => 5461,
'suppliers' => 5461, 'manufacturers' => 5461, 'attachment_types' => 1365, 'tools' => 1365,
'labels' => 21, 'parts_category' => 5, 'parts_minamount' => 5, 'parts_lots' => 85, 'parts_tags' => 5,
'parts_unit' => 5, 'parts_mass' => 5, 'parts_status' => 5, 'parts_mpn' => 5, 'currencies' => 5461,
'measurement_units' => 5461,
]);
$this->setReference(self::ADMINS, $admins);
$manager->persist($admins);
@ -53,15 +56,15 @@ class GroupFixtures extends Fixture
$readonly = new Group();
$readonly->setName('readonly');
$readonly->getPermissions()->setRawPermissionValues([
'system' => '2', 'groups' => '2730', 'users' => '43690', 'self' => '25', 'config' => '170',
'database' => '42', 'parts' => '2778027689', 'parts_name' => '9', 'parts_description' => '9',
'parts_footprint' => '9', 'parts_manufacturer' => '9', 'parts_comment' => '9', 'parts_order' => '9',
'parts_orderdetails' => '681', 'parts_prices' => '681', 'parts_attachments' => '681', 'devices' => '1705',
'devices_parts' => '649', 'storelocations' => '1705', 'footprints' => '1705', 'categories' => '1705',
'suppliers' => '1705', 'manufacturers' => '1705', 'attachment_types' => '681', 'tools' => '1366',
'labels' => '165', 'parts_category' => '9', 'parts_minamount' => '9', 'parts_lots' => '169', 'parts_tags' => '9',
'parts_unit' => '9', 'parts_mass' => '9', 'parts_status' => '9', 'parts_mpn' => '9', 'currencies' => '9897',
'measurement_units' => '9897',
'system' => 2, 'groups' => 2730, 'users' => 43690, 'self' => 25, 'config' => 170,
'database' => 42, 'parts' => 2778027689, 'parts_name' => 9, 'parts_description' => 9,
'parts_footprint' => 9, 'parts_manufacturer' => 9, 'parts_comment' => 9, 'parts_order' => 9,
'parts_orderdetails' => 681, 'parts_prices' => 681, 'parts_attachments' => 681, 'devices' => 1705,
'devices_parts' => 649, 'storelocations' => 1705, 'footprints' => 1705, 'categories' => 1705,
'suppliers' => 1705, 'manufacturers' => 1705, 'attachment_types' => 681, 'tools' => 1366,
'labels' => 165, 'parts_category' => 9, 'parts_minamount' => 9, 'parts_lots' => 169, 'parts_tags' => 9,
'parts_unit' => 9, 'parts_mass' => 9, 'parts_status' => 9, 'parts_mpn' => 9, 'currencies' => 9897,
'measurement_units' => 9897,
]);
$this->setReference(self::READONLY, $readonly);
$manager->persist($readonly);
@ -69,15 +72,15 @@ class GroupFixtures extends Fixture
$users = new Group();
$users->setName('users');
$users->getPermissions()->setRawPermissionValues([
'system' => '42', 'groups' => '2730', 'users' => '43690', 'self' => '89', 'config' => '105',
'database' => '41', 'parts' => '1431655765', 'parts_name' => '5', 'parts_description' => '5',
'parts_footprint' => '5', 'parts_manufacturer' => '5', 'parts_comment' => '5', 'parts_order' => '5',
'parts_orderdetails' => '341', 'parts_prices' => '341', 'parts_attachments' => '341', 'devices' => '5461',
'devices_parts' => '325', 'storelocations' => '5461', 'footprints' => '5461', 'categories' => '5461',
'suppliers' => '5461', 'manufacturers' => '5461', 'attachment_types' => '1365', 'tools' => '1365',
'labels' => '85', 'parts_category' => '5', 'parts_minamount' => '5', 'parts_lots' => '85', 'parts_tags' => '5',
'parts_unit' => '5', 'parts_mass' => '5', 'parts_status' => '5', 'parts_mpn' => '5', 'currencies' => '5461',
'measurement_units' => '5461',
'system' => 42, 'groups' => 2730, 'users' => 43690, 'self' => 89, 'config' => 105,
'database' => 41, 'parts' => 1431655765, 'parts_name' => 5, 'parts_description' => 5,
'parts_footprint' => 5, 'parts_manufacturer' => 5, 'parts_comment' => 5, 'parts_order' => 5,
'parts_orderdetails' => 341, 'parts_prices' => 341, 'parts_attachments' => 341, 'devices' => 5461,
'devices_parts' => 325, 'storelocations' => 5461, 'footprints' => 5461, 'categories' => 5461,
'suppliers' => 5461, 'manufacturers' => 5461, 'attachment_types' => 1365, 'tools' => 1365,
'labels' => 85, 'parts_category' => 5, 'parts_minamount' => 5, 'parts_lots' => 85, 'parts_tags' => 5,
'parts_unit' => 5, 'parts_mass' => 5, 'parts_status' => 5, 'parts_mpn' => 5, 'currencies' => 5461,
'measurement_units' => 5461,
]);
$this->setReference(self::USERS, $users);
$manager->persist($users);

View file

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
@ -38,7 +41,7 @@ class UserFixtures extends Fixture
$this->encoder = $encoder;
}
public function load(ObjectManager $manager)
public function load(ObjectManager $manager): void
{
//Reset autoincrement
$this->em->getConnection()->exec('ALTER TABLE `users` AUTO_INCREMENT = 1;');

View file

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
@ -36,13 +39,13 @@ class CustomORMAdapter extends ORMAdapter
{
protected $hydrationMode;
public function configure(array $options)
public function configure(array $options): void
{
parent::configure($options);
$this->hydrationMode = isset($options['hydrate']) ? $options['hydrate'] : Query::HYDRATE_OBJECT;
$this->hydrationMode = $options['hydrate'] ?? Query::HYDRATE_OBJECT;
}
protected function prepareQuery(AdapterQuery $query)
protected function prepareQuery(AdapterQuery $query): void
{
parent::prepareQuery($query);
$query->setIdentifierPropertyPath(null);
@ -57,7 +60,7 @@ class CustomORMAdapter extends ORMAdapter
$builder = $query->get('qb');
$state = $query->getState();
// Apply definitive view state for current 'page' of the table
foreach ($state->getOrderBy() as list($column, $direction)) {
foreach ($state->getOrderBy() as [$column, $direction]) {
/** @var AbstractColumn $column */
if ($column->isOrderable()) {
$builder->addOrderBy($column->getOrderField(), $direction);

View file

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
@ -54,23 +57,13 @@ class AttachmentDataTable implements DataTableTypeInterface
$this->attachmentURLGenerator = $attachmentURLGenerator;
}
protected function getQuery(QueryBuilder $builder)
{
$builder->distinct()->select('attachment')
->addSelect('attachment_type')
//->addSelect('element')
->from(Attachment::class, 'attachment')
->leftJoin('attachment.attachment_type', 'attachment_type');
//->leftJoin('attachment.element', 'element');
}
public function configure(DataTable $dataTable, array $options)
public function configure(DataTable $dataTable, array $options): void
{
$dataTable->add('picture', TextColumn::class, [
'label' => '',
'render' => function ($value, Attachment $context) {
if ($context->isPicture()
&& !$context->isExternal()
&& ! $context->isExternal()
&& $this->attachmentHelper->isFileExisting($context)) {
return sprintf(
'<img alt="%s" src="%s" data-thumbnail="%s" class="%s">',
@ -204,9 +197,19 @@ class AttachmentDataTable implements DataTableTypeInterface
$dataTable->createAdapter(ORMAdapter::class, [
'entity' => Attachment::class,
'query' => function (QueryBuilder $builder) {
'query' => function (QueryBuilder $builder): void {
$this->getQuery($builder);
},
]);
}
protected function getQuery(QueryBuilder $builder): void
{
$builder->distinct()->select('attachment')
->addSelect('attachment_type')
//->addSelect('element')
->from(Attachment::class, 'attachment')
->leftJoin('attachment.attachment_type', 'attachment_type');
//->leftJoin('attachment.element', 'element');
}
}

View file

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
@ -50,11 +53,11 @@ class EntityColumn extends AbstractColumn
*/
public function normalize($value)
{
/* @var NamedDBElement $value */
/** @var NamedDBElement $value */
return $value;
}
public function configureOptions(OptionsResolver $resolver)
public function configureOptions(OptionsResolver $resolver): void
{
parent::configureOptions($resolver);
@ -76,9 +79,9 @@ class EntityColumn extends AbstractColumn
$this->urlGenerator->listPartsURL($entity),
$value
);
} else {
return sprintf('<i>%s</i>', $value);
}
return sprintf('<i>%s</i>', $value);
}
};
});

View file

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
@ -31,14 +34,11 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
*/
class LocaleDateTimeColumn extends AbstractColumn
{
/**
* {@inheritdoc}
*/
public function normalize($value)
{
if (null === $value) {
return $this->options['nullValue'];
} elseif (!$value instanceof \DateTimeInterface) {
} elseif (! $value instanceof \DateTimeInterface) {
$value = new \DateTime((string) $value);
}
@ -60,9 +60,6 @@ class LocaleDateTimeColumn extends AbstractColumn
return $formatter->format($value->getTimestamp());
}
/**
* {@inheritdoc}
*/
protected function configureOptions(OptionsResolver $resolver)
{
parent::configureOptions($resolver);

View file

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*

View file

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
@ -56,7 +59,7 @@ class PartAttachmentsColumn extends AbstractColumn
public function render($value, $context)
{
if (!$context instanceof Part) {
if (! $context instanceof Part) {
throw new \RuntimeException('$context must be a Part object!');
}
$tmp = '';
@ -70,7 +73,7 @@ class PartAttachmentsColumn extends AbstractColumn
if (--$count < 0) {
break;
}
/* @var Attachment $attachment */
/** @var Attachment $attachment */
$tmp .= sprintf(
'<a href="%s" title="%s" class="attach-table-icon" target="_blank" rel="noopener" data-no-ajax>%s</a>',
$this->urlGenerator->viewURL($attachment),
@ -87,7 +90,7 @@ class PartAttachmentsColumn extends AbstractColumn
return $tmp;
}
public function configureOptions(OptionsResolver $resolver)
public function configureOptions(OptionsResolver $resolver): void
{
parent::configureOptions($resolver);
}

View file

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*

View file

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
@ -71,87 +74,7 @@ class PartsDataTable implements DataTableTypeInterface
$this->attachmentURLGenerator = $attachmentURLGenerator;
}
protected function getQuery(QueryBuilder $builder)
{
$builder->distinct()->select('part')
->addSelect('category')
->addSelect('footprint')
->addSelect('manufacturer')
->addSelect('partUnit')
->addSelect('master_picture_attachment')
->addSelect('footprint_attachment')
->addSelect('partLots')
->addSelect('orderdetails')
->addSelect('attachments')
->addSelect('storelocations')
->from(Part::class, 'part')
->leftJoin('part.category', 'category')
->leftJoin('part.master_picture_attachment', 'master_picture_attachment')
->leftJoin('part.partLots', 'partLots')
->leftJoin('partLots.storage_location', 'storelocations')
->leftJoin('part.footprint', 'footprint')
->leftJoin('footprint.master_picture_attachment', 'footprint_attachment')
->leftJoin('part.manufacturer', 'manufacturer')
->leftJoin('part.orderdetails', 'orderdetails')
->leftJoin('part.attachments', 'attachments')
->leftJoin('part.partUnit', 'partUnit');
}
protected function buildCriteria(QueryBuilder $builder, array $options)
{
$em = $builder->getEntityManager();
if (isset($options['category'])) {
$category = $options['category'];
$list = $this->treeBuilder->typeToNodesList(Category::class, $category);
$list[] = $category;
$builder->andWhere('part.category IN (:cid)')->setParameter('cid', $list);
}
if (isset($options['footprint'])) {
$category = $options['footprint'];
$list = $this->treeBuilder->typeToNodesList(Footprint::class, $category);
$list[] = $category;
$builder->andWhere('part.footprint IN (:cid)')->setParameter('cid', $list);
}
if (isset($options['manufacturer'])) {
$category = $options['manufacturer'];
$list = $this->treeBuilder->typeToNodesList(Manufacturer::class, $category);
$list[] = $category;
$builder->andWhere('part.manufacturer IN (:cid)')->setParameter('cid', $list);
}
if (isset($options['storelocation'])) {
$location = $options['storelocation'];
$list = $this->treeBuilder->typeToNodesList(Storelocation::class, $location);
$list[] = $location;
$builder->andWhere('partLots.storage_location IN (:cid)')->setParameter('cid', $list);
}
if (isset($options['supplier'])) {
$supplier = $options['supplier'];
$list = $this->treeBuilder->typeToNodesList(Supplier::class, $supplier);
$list[] = $supplier;
$builder->andWhere('orderdetails.supplier IN (:cid)')->setParameter('cid', $list);
}
if (isset($options['tag'])) {
$builder->andWhere('part.tags LIKE :tag')->setParameter('tag', '%'.$options['tag'].'%');
}
if (isset($options['search'])) {
$builder->AndWhere('part.name LIKE :search')->orWhere('part.description LIKE :search')->orWhere('part.comment LIKE :search')
->setParameter('search', '%'.$options['search'].'%');
}
}
public function configure(DataTable $dataTable, array $options)
public function configure(DataTable $dataTable, array $options): void
{
$dataTable
->add('picture', TextColumn::class, [
@ -293,16 +216,96 @@ class PartsDataTable implements DataTableTypeInterface
->addOrderBy('name')
->createAdapter(CustomORMAdapter::class, [
'query' => function (QueryBuilder $builder) {
'query' => function (QueryBuilder $builder): void {
$this->getQuery($builder);
},
'entity' => Part::class,
'criteria' => [
function (QueryBuilder $builder) use ($options) {
function (QueryBuilder $builder) use ($options): void {
$this->buildCriteria($builder, $options);
},
new SearchCriteriaProvider(),
],
]);
}
protected function getQuery(QueryBuilder $builder): void
{
$builder->distinct()->select('part')
->addSelect('category')
->addSelect('footprint')
->addSelect('manufacturer')
->addSelect('partUnit')
->addSelect('master_picture_attachment')
->addSelect('footprint_attachment')
->addSelect('partLots')
->addSelect('orderdetails')
->addSelect('attachments')
->addSelect('storelocations')
->from(Part::class, 'part')
->leftJoin('part.category', 'category')
->leftJoin('part.master_picture_attachment', 'master_picture_attachment')
->leftJoin('part.partLots', 'partLots')
->leftJoin('partLots.storage_location', 'storelocations')
->leftJoin('part.footprint', 'footprint')
->leftJoin('footprint.master_picture_attachment', 'footprint_attachment')
->leftJoin('part.manufacturer', 'manufacturer')
->leftJoin('part.orderdetails', 'orderdetails')
->leftJoin('part.attachments', 'attachments')
->leftJoin('part.partUnit', 'partUnit');
}
protected function buildCriteria(QueryBuilder $builder, array $options): void
{
$em = $builder->getEntityManager();
if (isset($options['category'])) {
$category = $options['category'];
$list = $this->treeBuilder->typeToNodesList(Category::class, $category);
$list[] = $category;
$builder->andWhere('part.category IN (:cid)')->setParameter('cid', $list);
}
if (isset($options['footprint'])) {
$category = $options['footprint'];
$list = $this->treeBuilder->typeToNodesList(Footprint::class, $category);
$list[] = $category;
$builder->andWhere('part.footprint IN (:cid)')->setParameter('cid', $list);
}
if (isset($options['manufacturer'])) {
$category = $options['manufacturer'];
$list = $this->treeBuilder->typeToNodesList(Manufacturer::class, $category);
$list[] = $category;
$builder->andWhere('part.manufacturer IN (:cid)')->setParameter('cid', $list);
}
if (isset($options['storelocation'])) {
$location = $options['storelocation'];
$list = $this->treeBuilder->typeToNodesList(Storelocation::class, $location);
$list[] = $location;
$builder->andWhere('partLots.storage_location IN (:cid)')->setParameter('cid', $list);
}
if (isset($options['supplier'])) {
$supplier = $options['supplier'];
$list = $this->treeBuilder->typeToNodesList(Supplier::class, $supplier);
$list[] = $supplier;
$builder->andWhere('orderdetails.supplier IN (:cid)')->setParameter('cid', $list);
}
if (isset($options['tag'])) {
$builder->andWhere('part.tags LIKE :tag')->setParameter('tag', '%'.$options['tag'].'%');
}
if (isset($options['search'])) {
$builder->AndWhere('part.name LIKE :search')->orWhere('part.description LIKE :search')->orWhere('part.comment LIKE :search')
->setParameter('search', '%'.$options['search'].'%');
}
}
}

View file

@ -68,6 +68,11 @@ abstract class Attachment extends NamedDBElement
/** @var array Placeholders for attachments which using built in files. */
public const BUILTIN_PLACEHOLDER = ['%FOOTPRINTS%', '%FOOTPRINTS3D%'];
/**
* @var string The class of the element that can be passed to this attachment. Must be overridden in subclasses.
*/
public const ALLOWED_ELEMENT_CLASS = '';
/**
* @var bool
* @ORM\Column(type="boolean")
@ -99,11 +104,6 @@ abstract class Attachment extends NamedDBElement
*/
protected $attachment_type;
/**
* @var string The class of the element that can be passed to this attachment. Must be overridden in subclasses.
*/
public const ALLOWED_ELEMENT_CLASS = '';
public function __construct()
{
//parent::__construct();
@ -170,7 +170,7 @@ abstract class Attachment extends NamedDBElement
return true;
}
return !\in_array($tmp[0], array_merge(static::INTERNAL_PLACEHOLDER, static::BUILTIN_PLACEHOLDER), false);
return ! \in_array($tmp[0], array_merge(static::INTERNAL_PLACEHOLDER, static::BUILTIN_PLACEHOLDER), false);
}
/**
@ -221,7 +221,7 @@ abstract class Attachment extends NamedDBElement
return null;
}
if (!empty($this->original_filename)) {
if (! empty($this->original_filename)) {
return strtolower(pathinfo($this->original_filename, PATHINFO_EXTENSION));
}
@ -244,7 +244,7 @@ abstract class Attachment extends NamedDBElement
*/
public function getURL(): ?string
{
if (!$this->isExternal() && !$this->isBuiltIn()) {
if (! $this->isExternal() && ! $this->isBuiltIn()) {
return null;
}
@ -257,7 +257,7 @@ abstract class Attachment extends NamedDBElement
*/
public function getHost(): ?string
{
if (!$this->isExternal()) {
if (! $this->isExternal()) {
return null;
}
@ -287,7 +287,7 @@ abstract class Attachment extends NamedDBElement
}
//If we have a stored original filename, then use it
if (!empty($this->original_filename)) {
if (! empty($this->original_filename)) {
return $this->original_filename;
}
@ -362,8 +362,8 @@ abstract class Attachment extends NamedDBElement
*/
public function setElement(AttachmentContainingDBElement $element): self
{
if (!is_a($element, static::ALLOWED_ELEMENT_CLASS)) {
throw new \InvalidArgumentException(sprintf('The element associated with a %s must be a %s!', \get_class($this), static::ALLOWED_ELEMENT_CLASS));
if (! is_a($element, static::ALLOWED_ELEMENT_CLASS)) {
throw new \InvalidArgumentException(sprintf('The element associated with a %s must be a %s!', static::class, static::ALLOWED_ELEMENT_CLASS));
}
$this->element = $element;
@ -404,7 +404,7 @@ abstract class Attachment extends NamedDBElement
public function setURL(?string $url): self
{
//Only set if the URL is not empty
if (!empty($url)) {
if (! empty($url)) {
if (false !== strpos($url, '%BASE%') || false !== strpos($url, '%MEDIA%')) {
throw new \InvalidArgumentException('You can not reference internal files via the url field! But nice try!');
}
@ -443,9 +443,9 @@ abstract class Attachment extends NamedDBElement
/**
* Check if a string is a URL and is valid.
*
* @param $string string The string which should be checked
* @param string $string The string which should be checked
* @param bool $path_required If true, the string must contain a path to be valid. (e.g. foo.bar would be invalid, foo.bar/test.php would be valid).
* @param $only_http bool Set this to true, if only HTTPS or HTTP schemata should be allowed.
* @param bool $only_http Set this to true, if only HTTPS or HTTP schemata should be allowed.
* *Caution: When this is set to false, a attacker could use the file:// schema, to get internal server files, like /etc/passwd.*
*
* @return bool True if the string is a valid URL. False, if the string is not an URL or invalid.

View file

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
@ -30,12 +33,11 @@ use Doctrine\ORM\Mapping as ORM;
*/
class AttachmentTypeAttachment extends Attachment
{
public const ALLOWED_ELEMENT_CLASS = AttachmentType::class;
/**
* @var AttachmentType the element this attachment is associated with
* @ORM\ManyToOne(targetEntity="App\Entity\Attachments\AttachmentType", inversedBy="attachments")
* @ORM\JoinColumn(name="element_id", referencedColumnName="id", nullable=false, onDelete="CASCADE").
*/
protected $element;
public const ALLOWED_ELEMENT_CLASS = AttachmentType::class;
}

View file

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
@ -31,12 +34,11 @@ use Doctrine\ORM\Mapping as ORM;
*/
class CategoryAttachment extends Attachment
{
public const ALLOWED_ELEMENT_CLASS = Category::class;
/**
* @var Category the element this attachment is associated with
* @ORM\ManyToOne(targetEntity="App\Entity\Parts\Category", inversedBy="attachments")
* @ORM\JoinColumn(name="element_id", referencedColumnName="id", nullable=false, onDelete="CASCADE").
*/
protected $element;
public const ALLOWED_ELEMENT_CLASS = Category::class;
}

View file

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
@ -31,12 +34,11 @@ use Doctrine\ORM\Mapping as ORM;
*/
class CurrencyAttachment extends Attachment
{
public const ALLOWED_ELEMENT_CLASS = Currency::class;
/**
* @var Currency the element this attachment is associated with
* @ORM\ManyToOne(targetEntity="App\Entity\PriceInformations\Currency", inversedBy="attachments")
* @ORM\JoinColumn(name="element_id", referencedColumnName="id", nullable=false, onDelete="CASCADE").
*/
protected $element;
public const ALLOWED_ELEMENT_CLASS = Currency::class;
}

View file

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
@ -31,12 +34,11 @@ use Doctrine\ORM\Mapping as ORM;
*/
class DeviceAttachment extends Attachment
{
public const ALLOWED_ELEMENT_CLASS = Device::class;
/**
* @var Device the element this attachment is associated with
* @ORM\ManyToOne(targetEntity="App\Entity\Devices\Device", inversedBy="attachments")
* @ORM\JoinColumn(name="element_id", referencedColumnName="id", nullable=false, onDelete="CASCADE").
*/
protected $element;
public const ALLOWED_ELEMENT_CLASS = Device::class;
}

View file

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
@ -31,12 +34,11 @@ use Doctrine\ORM\Mapping as ORM;
*/
class FootprintAttachment extends Attachment
{
public const ALLOWED_ELEMENT_CLASS = Footprint::class;
/**
* @var Footprint the element this attachment is associated with
* @ORM\ManyToOne(targetEntity="App\Entity\Parts\Footprint", inversedBy="attachments")
* @ORM\JoinColumn(name="element_id", referencedColumnName="id", nullable=false, onDelete="CASCADE").
*/
protected $element;
public const ALLOWED_ELEMENT_CLASS = Footprint::class;
}

View file

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
@ -31,12 +34,11 @@ use Doctrine\ORM\Mapping as ORM;
*/
class GroupAttachment extends Attachment
{
public const ALLOWED_ELEMENT_CLASS = Group::class;
/**
* @var Group the element this attachment is associated with
* @ORM\ManyToOne(targetEntity="App\Entity\UserSystem\Group", inversedBy="attachments")
* @ORM\JoinColumn(name="element_id", referencedColumnName="id", nullable=false, onDelete="CASCADE").
*/
protected $element;
public const ALLOWED_ELEMENT_CLASS = Group::class;
}

View file

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
@ -31,12 +34,11 @@ use Doctrine\ORM\Mapping as ORM;
*/
class ManufacturerAttachment extends Attachment
{
public const ALLOWED_ELEMENT_CLASS = Manufacturer::class;
/**
* @var Manufacturer the element this attachment is associated with
* @ORM\ManyToOne(targetEntity="App\Entity\Parts\Manufacturer", inversedBy="attachments")
* @ORM\JoinColumn(name="element_id", referencedColumnName="id", nullable=false, onDelete="CASCADE").
*/
protected $element;
public const ALLOWED_ELEMENT_CLASS = Manufacturer::class;
}

View file

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
@ -32,12 +35,11 @@ use Doctrine\ORM\Mapping as ORM;
*/
class MeasurementUnitAttachment extends Attachment
{
public const ALLOWED_ELEMENT_CLASS = MeasurementUnit::class;
/**
* @var Manufacturer the element this attachment is associated with
* @ORM\ManyToOne(targetEntity="App\Entity\Parts\MeasurementUnit", inversedBy="attachments")
* @ORM\JoinColumn(name="element_id", referencedColumnName="id", nullable=false, onDelete="CASCADE").
*/
protected $element;
public const ALLOWED_ELEMENT_CLASS = MeasurementUnit::class;
}

View file

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
@ -31,12 +34,11 @@ use Doctrine\ORM\Mapping as ORM;
*/
class PartAttachment extends Attachment
{
public const ALLOWED_ELEMENT_CLASS = Part::class;
/**
* @var Part the element this attachment is associated with
* @ORM\ManyToOne(targetEntity="App\Entity\Parts\Part", inversedBy="attachments")
* @ORM\JoinColumn(name="element_id", referencedColumnName="id", nullable=false, onDelete="CASCADE").
*/
protected $element;
public const ALLOWED_ELEMENT_CLASS = Part::class;
}

View file

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
@ -31,12 +34,11 @@ use Doctrine\ORM\Mapping as ORM;
*/
class StorelocationAttachment extends Attachment
{
public const ALLOWED_ELEMENT_CLASS = Storelocation::class;
/**
* @var Storelocation the element this attachment is associated with
* @ORM\ManyToOne(targetEntity="App\Entity\Parts\Storelocation", inversedBy="attachments")
* @ORM\JoinColumn(name="element_id", referencedColumnName="id", nullable=false, onDelete="CASCADE").
*/
protected $element;
public const ALLOWED_ELEMENT_CLASS = Storelocation::class;
}

View file

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
@ -31,12 +34,11 @@ use Doctrine\ORM\Mapping as ORM;
*/
class SupplierAttachment extends Attachment
{
public const ALLOWED_ELEMENT_CLASS = Supplier::class;
/**
* @var Supplier the element this attachment is associated with
* @ORM\ManyToOne(targetEntity="App\Entity\Parts\Supplier", inversedBy="attachments")
* @ORM\JoinColumn(name="element_id", referencedColumnName="id", nullable=false, onDelete="CASCADE").
*/
protected $element;
public const ALLOWED_ELEMENT_CLASS = Supplier::class;
}

View file

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
@ -31,12 +34,11 @@ use Doctrine\ORM\Mapping as ORM;
*/
class UserAttachment extends Attachment
{
public const ALLOWED_ELEMENT_CLASS = User::class;
/**
* @var User the element this attachment is associated with
* @ORM\ManyToOne(targetEntity="App\Entity\UserSystem\User", inversedBy="attachments")
* @ORM\JoinColumn(name="element_id", referencedColumnName="id", nullable=false, onDelete="CASCADE").
*/
protected $element;
public const ALLOWED_ELEMENT_CLASS = User::class;
}

View file

@ -20,6 +20,7 @@
*/
declare(strict_types=1);
/**
* Part-DB Version 0.4+ "nextgen"
* Copyright (C) 2016 - 2019 Jan Böhmer

View file

@ -66,6 +66,12 @@ abstract class DBElement
*/
protected $id;
public function __clone()
{
//Set ID to null, so that an new entry is created
$this->id = null;
}
/**
* Get the ID. The ID can be zero, or even negative (for virtual elements). If an element is virtual, can be
* checked with isVirtualElement().
@ -86,10 +92,4 @@ abstract class DBElement
* @return string The ID as a string;
*/
abstract public function getIDString(): string;
public function __clone()
{
//Set ID to null, so that an new entry is created
$this->id = null;
}
}

View file

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*

View file

@ -45,6 +45,17 @@ abstract class NamedDBElement extends DBElement
*/
protected $name = '';
/******************************************************************************
*
* Helpers
*
******************************************************************************/
public function __toString()
{
return $this->getName();
}
/********************************************************************************
*
* Getters
@ -80,15 +91,4 @@ abstract class NamedDBElement extends DBElement
return $this;
}
/******************************************************************************
*
* Helpers
*
******************************************************************************/
public function __toString()
{
return $this->getName();
}
}

View file

@ -113,11 +113,11 @@ abstract class StructuralDBElement extends AttachmentContainingDBElement
*/
public function isChildOf(self $another_element): bool
{
$class_name = \get_class($this);
$class_name = static::class;
//Check if both elements compared, are from the same type
// (we have to check inheritance, or we get exceptions when using doctrine entities (they have a proxy type):
if (!is_a($another_element, $class_name) && !is_a($this, \get_class($another_element))) {
if (! is_a($another_element, $class_name) && ! is_a($this, \get_class($another_element))) {
throw new \InvalidArgumentException('isChildOf() only works for objects of the same type!');
}
@ -201,7 +201,7 @@ abstract class StructuralDBElement extends AttachmentContainingDBElement
*/
public function getFullPath(string $delimiter = self::PATH_DELIMITER_ARROW): string
{
if (!\is_array($this->full_path_strings)) {
if (! \is_array($this->full_path_strings)) {
$this->full_path_strings = [];
$this->full_path_strings[] = $this->getName();
$element = $this;
@ -233,7 +233,7 @@ abstract class StructuralDBElement extends AttachmentContainingDBElement
$tmp[] = $this;
//We only allow 20 levels depth
while (!end($tmp)->isRoot() && \count($tmp) < 20) {
while (! end($tmp)->isRoot() && \count($tmp) < 20) {
$tmp[] = end($tmp)->parent;
}
@ -243,8 +243,6 @@ abstract class StructuralDBElement extends AttachmentContainingDBElement
/**
* Get all sub elements of this element.
*
* @param bool $recursive if true, the search is recursive
*
* @return Collection<static> all subelements as an array of objects (sorted by their full path)
*/
public function getSubelements(): iterable

View file

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*

View file

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*

View file

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
@ -266,7 +269,7 @@ class PartLot extends DBElement
*/
public function getAmount(): float
{
if ($this->part instanceof Part && !$this->part->useFloatAmount()) {
if ($this->part instanceof Part && ! $this->part->useFloatAmount()) {
return round($this->amount);
}

View file

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*

View file

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
@ -192,7 +195,7 @@ trait BasicPropertyTrait
/**
* Set the favorite status for this part.
*
* @param $new_favorite_status bool The new favorite status, that should be applied on this part.
* @param bool $new_favorite_status The new favorite status, that should be applied on this part.
* Set this to true, when the part should be a favorite.
*/
public function setFavorite(bool $new_favorite_status): self

View file

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
@ -134,7 +137,7 @@ trait InstockTrait
public function useFloatAmount(): bool
{
if ($this->partUnit instanceof MeasurementUnit) {
return !$this->partUnit->isInteger();
return ! $this->partUnit->isInteger();
}
//When no part unit is set, treat it as part count, and so use the integer value.

View file

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*

View file

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
@ -185,7 +188,7 @@ trait OrderTrait
}
foreach ($all_orderdetails as $orderdetails) {
if (!$orderdetails->getObsolete()) {
if (! $orderdetails->getObsolete()) {
return false;
}
}

View file

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
@ -104,7 +107,7 @@ class Currency extends StructuralDBElement
return null;
}
return bcdiv(1, $tmp, static::PRICE_SCALE);
return bcdiv('1', $tmp, static::PRICE_SCALE);
}
/**

View file

@ -181,7 +181,7 @@ class Orderdetail extends DBElement
/**
* Get the link to the website of the article on the suppliers website.
*
* @param $no_automatic_url bool Set this to true, if you only want to get the local set product URL for this Orderdetail
* @param bool $no_automatic_url Set this to true, if you only want to get the local set product URL for this Orderdetail
* and not a automatic generated one, based from the Supplier
*
* @return string the link to the article
@ -330,7 +330,7 @@ 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
* @param string $new_url The new URL for the supplier URL
*
* @return Orderdetail
*/

View file

@ -68,10 +68,10 @@ use Symfony\Component\Validator\Constraints as Assert;
*/
class Pricedetail extends DBElement
{
public const PRICE_PRECISION = 5;
use TimestampTrait;
public const PRICE_PRECISION = 5;
/**
* @var Orderdetail
* @ORM\ManyToOne(targetEntity="Orderdetail", inversedBy="pricedetails")
@ -180,7 +180,7 @@ class Pricedetail extends DBElement
*/
public function getPriceRelatedQuantity(): float
{
if ($this->orderdetail && $this->orderdetail->getPart() && !$this->orderdetail->getPart()->useFloatAmount()) {
if ($this->orderdetail && $this->orderdetail->getPart() && ! $this->orderdetail->getPart()->useFloatAmount()) {
$tmp = round($this->price_related_quantity);
return $tmp < 1 ? 1 : $tmp;
@ -203,7 +203,7 @@ class Pricedetail extends DBElement
*/
public function getMinDiscountQuantity(): float
{
if ($this->orderdetail && $this->orderdetail->getPart() && !$this->orderdetail->getPart()->useFloatAmount()) {
if ($this->orderdetail && $this->orderdetail->getPart() && ! $this->orderdetail->getPart()->useFloatAmount()) {
$tmp = round($this->min_discount_quantity);
return $tmp < 1 ? 1 : $tmp;

View file

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*

View file

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
@ -299,7 +302,7 @@ class PermissionsEmbed
*/
public function isValidPermissionName(string $permission_name): bool
{
return isset($this->$permission_name);
return isset($this->{$permission_name});
}
/**
@ -312,11 +315,11 @@ class PermissionsEmbed
*/
public function getBitValue(string $permission_name, int $bit_n): int
{
if (!$this->isValidPermissionName($permission_name)) {
if (! $this->isValidPermissionName($permission_name)) {
throw new \InvalidArgumentException(sprintf('No permission with the name "%s" is existing!', $permission_name));
}
$perm_int = $this->$permission_name;
$perm_int = (int) $this->{$permission_name};
return static::readBitPair($perm_int, $bit_n);
}
@ -382,11 +385,11 @@ class PermissionsEmbed
*/
public function setBitValue(string $permission_name, int $bit_n, int $new_value): self
{
if (!$this->isValidPermissionName($permission_name)) {
if (! $this->isValidPermissionName($permission_name)) {
throw new \InvalidArgumentException('No permission with the given name is existing!');
}
$this->$permission_name = static::writeBitPair($this->$permission_name, $bit_n, $new_value);
$this->{$permission_name} = static::writeBitPair($this->{$permission_name}, $bit_n, $new_value);
return $this;
}
@ -401,11 +404,11 @@ class PermissionsEmbed
*/
public function getRawPermissionValue(string $permission_name): int
{
if (!$this->isValidPermissionName($permission_name)) {
if (! $this->isValidPermissionName($permission_name)) {
throw new \InvalidArgumentException('No permission with the given name is existing!');
}
return $this->$permission_name;
return $this->{$permission_name};
}
/**
@ -418,11 +421,11 @@ class PermissionsEmbed
*/
public function setRawPermissionValue(string $permission_name, int $value): self
{
if (!$this->isValidPermissionName($permission_name)) {
if (! $this->isValidPermissionName($permission_name)) {
throw new \InvalidArgumentException(sprintf('No permission with the given name %s is existing!', $permission_name));
}
$this->$permission_name = $value;
$this->{$permission_name} = $value;
return $this;
}
@ -436,9 +439,9 @@ class PermissionsEmbed
*
* @return $this
*/
public function setRawPermissionValues(array $values, array $values2 = null): self
public function setRawPermissionValues(array $values, ?array $values2 = null): self
{
if (!empty($values2)) {
if (! empty($values2)) {
$values = array_combine($values, $values2);
}
@ -452,12 +455,12 @@ class PermissionsEmbed
/**
* Reads a bit pair from $data.
*
* @param $data int The data from where the bits should be extracted from
* @param $n int The number of the lower bit (of the pair) that should be read. Starting from zero.
* @param int|string $data The data from where the bits should be extracted from
* @param int $n The number of the lower bit (of the pair) that should be read. Starting from zero.
*
* @return int the value of the bit pair
*/
final protected static function readBitPair(int $data, int $n): int
final protected static function readBitPair($data, int $n): int
{
Assert::lessThanEq($n, 31, '$n must be smaller than 32, because only a 32bit int is used! Got %s.');
if (0 !== $n % 2) {
@ -471,9 +474,9 @@ class PermissionsEmbed
/**
* Writes a bit pair in the given $data and returns it.
*
* @param $data int The data which should be modified
* @param $n int The number of the lower bit of the pair which should be written
* @param $new int The new value of the pair
* @param int $data The data which should be modified
* @param int $n The number of the lower bit of the pair which should be written
* @param int $new The new value of the pair
*
* @return int the new data with the modified pair
*/

View file

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
@ -38,13 +41,6 @@ class U2FKey implements TwoFactorKeyInterface
{
use TimestampTrait;
/**
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
/**
* @ORM\Column(type="string", length=64)
*
@ -73,6 +69,13 @@ class U2FKey implements TwoFactorKeyInterface
**/
public $counter;
/**
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\UserSystem\User", inversedBy="u2fKeys")
*
@ -95,62 +98,52 @@ class U2FKey implements TwoFactorKeyInterface
$this->counter = $data->counter;
}
/** {@inheritdoc} */
public function getKeyHandle()
{
return $this->keyHandle;
}
/** {@inheritdoc} */
public function setKeyHandle($keyHandle)
public function setKeyHandle($keyHandle): void
{
$this->keyHandle = $keyHandle;
}
/** {@inheritdoc} */
public function getPublicKey()
{
return $this->publicKey;
}
/** {@inheritdoc} */
public function setPublicKey($publicKey)
public function setPublicKey($publicKey): void
{
$this->publicKey = $publicKey;
}
/** {@inheritdoc} */
public function getCertificate()
{
return $this->certificate;
}
/** {@inheritdoc} */
public function setCertificate($certificate)
public function setCertificate($certificate): void
{
$this->certificate = $certificate;
}
/** {@inheritdoc} */
public function getCounter()
{
return $this->counter;
}
/** {@inheritdoc} */
public function setCounter($counter)
public function setCounter($counter): void
{
$this->counter = $counter;
}
/** {@inheritdoc} */
public function getName()
{
return $this->name;
}
/** {@inheritdoc} */
public function setName($name)
public function setName($name): void
{
$this->name = $name;
}

View file

@ -266,6 +266,19 @@ class User extends AttachmentContainingDBElement implements UserInterface, HasPe
$this->u2fKeys = new ArrayCollection();
}
/**
* Returns a string representation of this user (the full name).
* E.g. 'Jane Doe (j.doe) [DISABLED].
*
* @return string
*/
public function __toString()
{
$tmp = $this->isDisabled() ? ' [DISABLED]' : '';
return $this->getFullName(true).$tmp;
}
/**
* Checks if the current user, is the user which represents the not logged in (anonymous) users.
*
@ -330,7 +343,7 @@ class User extends AttachmentContainingDBElement implements UserInterface, HasPe
/**
* @see UserInterface
*/
public function getSalt()
public function getSalt(): void
{
// not needed when using the "bcrypt" algorithm in security.yaml
}
@ -338,7 +351,7 @@ class User extends AttachmentContainingDBElement implements UserInterface, HasPe
/**
* @see UserInterface
*/
public function eraseCredentials()
public function eraseCredentials(): void
{
// If you store any temporary, sensitive data on the user, clear it here
// $this->plainPassword = null;
@ -503,7 +516,7 @@ class User extends AttachmentContainingDBElement implements UserInterface, HasPe
public function setName(string $new_name): NamedDBElement
{
// Anonymous user is not allowed to change its username
if (!$this->isAnonymousUser()) {
if (! $this->isAnonymousUser()) {
$this->name = $new_name;
}
@ -646,8 +659,6 @@ class User extends AttachmentContainingDBElement implements UserInterface, HasPe
/**
* Change the timezone of this user.
*
* @param string $timezone|null The new timezone (e.g. 'Europe/Berlin') or null to use the system wide one.
*
* @return $this
*/
public function setTimezone(?string $timezone): self
@ -706,19 +717,6 @@ class User extends AttachmentContainingDBElement implements UserInterface, HasPe
return $this;
}
/**
* Returns a string representation of this user (the full name).
* E.g. 'Jane Doe (j.doe) [DISABLED].
*
* @return string
*/
public function __toString()
{
$tmp = $this->isDisabled() ? ' [DISABLED]' : '';
return $this->getFullName(true).$tmp;
}
/**
* Return true if the user should do two-factor authentication.
*
@ -771,7 +769,7 @@ class User extends AttachmentContainingDBElement implements UserInterface, HasPe
*/
public function isBackupCode(string $code): bool
{
return \in_array($code, $this->backupCodes);
return \in_array($code, $this->backupCodes, true);
}
/**
@ -781,7 +779,7 @@ class User extends AttachmentContainingDBElement implements UserInterface, HasPe
*/
public function invalidateBackupCode(string $code): void
{
$key = array_search($code, $this->backupCodes);
$key = array_search($code, $this->backupCodes, true);
if (false !== $key) {
unset($this->backupCodes[$key]);
}
@ -883,9 +881,6 @@ class User extends AttachmentContainingDBElement implements UserInterface, HasPe
$this->u2fKeys->removeElement($key);
}
/**
* {@inheritdoc}
*/
public function getPreferredTwoFactorProvider(): ?string
{
//If U2F is available then prefer it

View file

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
@ -52,7 +55,7 @@ class AttachmentDeleteListener
*
* @PreUpdate
*/
public function preUpdateHandler(Attachment $attachment, PreUpdateEventArgs $event)
public function preUpdateHandler(Attachment $attachment, PreUpdateEventArgs $event): void
{
if ($event->hasChangedField('path')) {
//Dont delete file if the attachment uses a builtin ressource:
@ -70,7 +73,7 @@ class AttachmentDeleteListener
*
* @PostRemove
*/
public function postRemoveHandler(Attachment $attachment, LifecycleEventArgs $event)
public function postRemoveHandler(Attachment $attachment, LifecycleEventArgs $event): void
{
//Dont delete file if the attachment uses a builtin ressource:
if ($attachment->isBuiltIn()) {

View file

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
@ -46,7 +49,7 @@ class TreeCacheInvalidationListener
* @ORM\PostPersist()
* @ORM\PostRemove()
*/
public function invalidate(DBElement $element, LifecycleEventArgs $event)
public function invalidate(DBElement $element, LifecycleEventArgs $event): void
{
//If an element was changed, then invalidate all cached trees with this element class
if ($element instanceof StructuralDBElement) {

View file

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
@ -41,7 +44,7 @@ class LoginSuccessListener implements EventSubscriberInterface
$this->flashBag = $flashBag;
}
public function onLogin(InteractiveLoginEvent $event)
public function onLogin(InteractiveLoginEvent $event): void
{
$this->flashBag->add('notice', $this->translator->trans('flash.login_successful'));
}

View file

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
@ -43,7 +46,7 @@ class LogoutOnDisabledUserListener implements EventSubscriberInterface
$this->urlGenerator = $urlGenerator;
}
public function onRequest(RequestEvent $event)
public function onRequest(RequestEvent $event): void
{
$user = $this->security->getUser();
if ($user instanceof User && $user->isDisabled()) {

View file

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*

View file

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
@ -36,10 +39,6 @@ use Symfony\Component\Security\Http\HttpUtils;
*/
class PasswordChangeNeededSubscriber implements EventSubscriberInterface
{
protected $security;
protected $flashBag;
protected $httpUtils;
/**
* @var string[] The routes the user is allowed to access without being redirected.
* This should be only routes related to login/logout and user settings
@ -54,6 +53,9 @@ class PasswordChangeNeededSubscriber implements EventSubscriberInterface
/** @var string The route the user will redirected to, if he needs to change this password */
public const REDIRECT_TARGET = 'user_settings';
protected $security;
protected $flashBag;
protected $httpUtils;
public function __construct(Security $security, FlashBagInterface $flashBag, HttpUtils $httpUtils)
{
@ -72,15 +74,15 @@ class PasswordChangeNeededSubscriber implements EventSubscriberInterface
$user = $this->security->getUser();
$request = $event->getRequest();
if (!$event->isMasterRequest()) {
if (! $event->isMasterRequest()) {
return;
}
if (!$user instanceof User) {
if (! $user instanceof User) {
return;
}
//Abort if we dont need to redirect the user.
if (!$user->isNeedPwChange() && !static::TFARedirectNeeded($user)) {
if (! $user->isNeedPwChange() && ! static::TFARedirectNeeded($user)) {
return;
}
@ -123,16 +125,13 @@ class PasswordChangeNeededSubscriber implements EventSubscriberInterface
{
$tfa_enabled = $user->isU2FAuthEnabled() || $user->isGoogleAuthenticatorEnabled();
if (null !== $user->getGroup() && $user->getGroup()->isEnforce2FA() && !$tfa_enabled) {
if (null !== $user->getGroup() && $user->getGroup()->isEnforce2FA() && ! $tfa_enabled) {
return true;
}
return false;
}
/**
* {@inheritdoc}
*/
public static function getSubscribedEvents()
{
return [

View file

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
@ -57,9 +60,9 @@ class SymfonyDebugToolbarSubscriber implements EventSubscriberInterface
return ['kernel.response' => 'onKernelResponse'];
}
public function onKernelResponse(FilterResponseEvent $event)
public function onKernelResponse(FilterResponseEvent $event): void
{
if (!$this->kernel->getParameter('kernel.debug')) {
if (! $this->kernel->getParameter('kernel.debug')) {
return;
}

View file

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
@ -41,18 +44,18 @@ class TimezoneListener implements EventSubscriberInterface
$this->security = $security;
}
public function setTimeZone(ControllerEvent $event)
public function setTimeZone(ControllerEvent $event): void
{
$timezone = null;
//Check if the user has set a timezone
$user = $this->security->getUser();
if ($user instanceof User && !empty($user->getTimezone())) {
if ($user instanceof User && ! empty($user->getTimezone())) {
$timezone = $user->getTimezone();
}
//Fill with default value if needed
if (null === $timezone && !empty($this->default_timezone)) {
if (null === $timezone && ! empty($this->default_timezone)) {
$timezone = $this->default_timezone;
}

View file

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
@ -31,13 +34,12 @@ use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
class U2FRegistrationSubscriber implements EventSubscriberInterface
{
/** @var UrlGeneratorInterface */
private $router;
protected $em;
protected $demo_mode;
protected $flashBag;
/** @var UrlGeneratorInterface */
private $router;
public function __construct(UrlGeneratorInterface $router, EntityManagerInterface $entityManager, FlashBagInterface $flashBag, bool $demo_mode)
{
@ -58,7 +60,7 @@ class U2FRegistrationSubscriber implements EventSubscriberInterface
public function onRegister(RegisterEvent $event): void
{
//Skip adding of U2F key on demo mode
if (!$this->demo_mode) {
if (! $this->demo_mode) {
$user = $event->getUser();
$registration = $event->getRegistration();
$newKey = new U2FKey();

View file

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*

View file

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*

View file

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
@ -39,7 +42,7 @@ class AttachmentTypeAdminForm extends BaseEntityAdminForm
parent::__construct($security, $params);
}
protected function additionalFormElements(FormBuilderInterface $builder, array $options, NamedDBElement $entity)
protected function additionalFormElements(FormBuilderInterface $builder, array $options, NamedDBElement $entity): void
{
$is_new = null === $entity->getID();
@ -48,7 +51,7 @@ class AttachmentTypeAdminForm extends BaseEntityAdminForm
'help' => 'attachment_type.edit.filetype_filter.help',
'attr' => ['placeholder' => 'attachment_type.edit.filetype_filter.placeholder'],
'empty_data' => '',
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity), ]);
'disabled' => ! $this->security->isGranted($is_new ? 'create' : 'edit', $entity), ]);
//Normalize data before writing it to database
$builder->get('filetype_filter')->addViewTransformer(new CallbackTransformer(

View file

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
@ -50,13 +53,13 @@ class BaseEntityAdminForm extends AbstractType
$this->params = $params;
}
public function configureOptions(OptionsResolver $resolver)
public function configureOptions(OptionsResolver $resolver): void
{
parent::configureOptions($resolver); // TODO: Change the autogenerated stub
$resolver->setRequired('attachment_class');
}
public function buildForm(FormBuilderInterface $builder, array $options)
public function buildForm(FormBuilderInterface $builder, array $options): void
{
/** @var StructuralDBElement $entity */
$entity = $options['data'];
@ -65,22 +68,22 @@ class BaseEntityAdminForm extends AbstractType
$builder
->add('name', TextType::class, ['empty_data' => '', 'label' => 'name.label',
'attr' => ['placeholder' => 'part.name.placeholder'],
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity), ])
'disabled' => ! $this->security->isGranted($is_new ? 'create' : 'edit', $entity), ])
->add('parent', StructuralEntityType::class, ['class' => \get_class($entity),
'required' => false, 'label' => 'parent.label',
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'move', $entity), ])
'disabled' => ! $this->security->isGranted($is_new ? 'create' : 'move', $entity), ])
->add('not_selectable', CheckboxType::class, ['required' => false,
'label' => 'entity.edit.not_selectable',
'help' => 'entity.edit.not_selectable.help',
'label_attr' => ['class' => 'checkbox-custom'],
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity), ])
'disabled' => ! $this->security->isGranted($is_new ? 'create' : 'edit', $entity), ])
->add('comment', CKEditorType::class, ['required' => false, 'empty_data' => '',
'label' => 'comment.label',
'attr' => ['rows' => 4], 'help' => 'bbcode.hint',
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity), ]);
'disabled' => ! $this->security->isGranted($is_new ? 'create' : 'edit', $entity), ]);
$this->additionalFormElements($builder, $options, $entity);
@ -90,7 +93,7 @@ class BaseEntityAdminForm extends AbstractType
'allow_add' => true,
'allow_delete' => true,
'label' => false,
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity),
'disabled' => ! $this->security->isGranted($is_new ? 'create' : 'edit', $entity),
'entry_options' => [
'data_class' => $options['attachment_class'],
],
@ -99,7 +102,7 @@ class BaseEntityAdminForm extends AbstractType
$builder->add('master_picture_attachment', MasterPictureAttachmentType::class, [
'required' => false,
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity),
'disabled' => ! $this->security->isGranted($is_new ? 'create' : 'edit', $entity),
'label' => 'part.edit.master_attachment',
'entity' => $entity,
]);
@ -108,12 +111,12 @@ class BaseEntityAdminForm extends AbstractType
$builder->add('save', SubmitType::class, [
'label' => $is_new ? 'entity.create' : 'entity.edit.save',
'attr' => ['class' => $is_new ? 'btn-success' : ''],
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity), ])
'disabled' => ! $this->security->isGranted($is_new ? 'create' : 'edit', $entity), ])
->add('reset', ResetType::class, ['label' => 'entity.edit.reset',
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity), ]);
'disabled' => ! $this->security->isGranted($is_new ? 'create' : 'edit', $entity), ]);
}
protected function additionalFormElements(FormBuilderInterface $builder, array $options, NamedDBElement $entity)
protected function additionalFormElements(FormBuilderInterface $builder, array $options, NamedDBElement $entity): void
{
//Empty for Base
}

View file

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
@ -28,7 +31,7 @@ use Symfony\Component\Form\FormBuilderInterface;
class CategoryAdminForm extends BaseEntityAdminForm
{
protected function additionalFormElements(FormBuilderInterface $builder, array $options, NamedDBElement $entity)
protected function additionalFormElements(FormBuilderInterface $builder, array $options, NamedDBElement $entity): void
{
$is_new = null === $entity->getID();
@ -36,44 +39,44 @@ class CategoryAdminForm extends BaseEntityAdminForm
'label' => 'category.edit.disable_footprints',
'help' => 'category.edit.disable_footprints.help',
'label_attr' => ['class' => 'checkbox-custom'],
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity), ]);
'disabled' => ! $this->security->isGranted($is_new ? 'create' : 'edit', $entity), ]);
$builder->add('disable_manufacturers', CheckboxType::class, ['required' => false,
'label' => 'category.edit.disable_manufacturers',
'help' => 'category.edit.disable_manufacturers.help',
'label_attr' => ['class' => 'checkbox-custom'],
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity), ]);
'disabled' => ! $this->security->isGranted($is_new ? 'create' : 'edit', $entity), ]);
$builder->add('disable_autodatasheets', CheckboxType::class, ['required' => false,
'label' => 'category.edit.disable_autodatasheets',
'help' => 'category.edit.disable_autodatasheets.help',
'label_attr' => ['class' => 'checkbox-custom'],
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity), ]);
'disabled' => ! $this->security->isGranted($is_new ? 'create' : 'edit', $entity), ]);
$builder->add('disable_properties', CheckboxType::class, ['required' => false,
'label' => 'category.edit.disable_properties',
'help' => 'category.edit.disable_properties.help',
'label_attr' => ['class' => 'checkbox-custom'],
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity), ]);
'disabled' => ! $this->security->isGranted($is_new ? 'create' : 'edit', $entity), ]);
$builder->add('partname_hint', TextType::class, ['required' => false, 'empty_data' => '',
'label' => 'category.edit.partname_hint',
'attr' => ['placeholder' => 'category.edit.partname_hint.placeholder'],
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity), ]);
'disabled' => ! $this->security->isGranted($is_new ? 'create' : 'edit', $entity), ]);
$builder->add('partname_regex', TextType::class, ['required' => false, 'empty_data' => '',
'label' => 'category.edit.partname_regex',
'attr' => ['placeholder' => 'category.edit.partname_regex.placeholder'],
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity), ]);
'disabled' => ! $this->security->isGranted($is_new ? 'create' : 'edit', $entity), ]);
$builder->add('default_description', TextType::class, ['required' => false, 'empty_data' => '',
'label' => 'category.edit.default_description',
'attr' => ['placeholder' => 'category.edit.default_description.placeholder'],
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity), ]);
'disabled' => ! $this->security->isGranted($is_new ? 'create' : 'edit', $entity), ]);
$builder->add('default_comment', TextType::class, ['required' => false, 'empty_data' => '',
'label' => 'category.edit.default_comment',
'attr' => ['placeholder' => 'category.edit.default_comment.placeholder'],
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity), ]);
'disabled' => ! $this->security->isGranted($is_new ? 'create' : 'edit', $entity), ]);
}
}

View file

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
@ -30,20 +33,20 @@ use Symfony\Component\Form\FormBuilderInterface;
class CompanyForm extends BaseEntityAdminForm
{
protected function additionalFormElements(FormBuilderInterface $builder, array $options, NamedDBElement $entity)
protected function additionalFormElements(FormBuilderInterface $builder, array $options, NamedDBElement $entity): void
{
$is_new = null === $entity->getID();
$builder->add('address', TextareaType::class, [
'label' => 'company.edit.address',
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity),
'disabled' => ! $this->security->isGranted($is_new ? 'create' : 'edit', $entity),
'attr' => ['placeholder' => 'company.edit.address.placeholder'], 'required' => false,
'empty_data' => '',
]);
$builder->add('phone_number', TelType::class, [
'label' => 'company.edit.phone_number',
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity),
'disabled' => ! $this->security->isGranted($is_new ? 'create' : 'edit', $entity),
'attr' => ['placeholder' => 'company.edit.phone_number.placeholder'],
'required' => false,
'empty_data' => '',
@ -51,21 +54,21 @@ class CompanyForm extends BaseEntityAdminForm
$builder->add('fax_number', TelType::class, [
'label' => 'company.edit.fax_number',
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity),
'disabled' => ! $this->security->isGranted($is_new ? 'create' : 'edit', $entity),
'attr' => ['placeholder' => 'company.fax_number.placeholder'], 'required' => false,
'empty_data' => '',
]);
$builder->add('email_address', EmailType::class, [
'label' => 'company.edit.email',
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity),
'disabled' => ! $this->security->isGranted($is_new ? 'create' : 'edit', $entity),
'attr' => ['placeholder' => 'company.edit.email.placeholder'], 'required' => false,
'empty_data' => '',
]);
$builder->add('website', UrlType::class, [
'label' => 'company.edit.website',
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity),
'disabled' => ! $this->security->isGranted($is_new ? 'create' : 'edit', $entity),
'attr' => ['placeholder' => 'company.edit.website.placeholder'], 'required' => false,
'empty_data' => '',
]);
@ -73,7 +76,7 @@ class CompanyForm extends BaseEntityAdminForm
$builder->add('auto_product_url', UrlType::class, [
'label' => 'company.edit.auto_product_url',
'help' => 'company.edit.auto_product_url.help',
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity),
'disabled' => ! $this->security->isGranted($is_new ? 'create' : 'edit', $entity),
'attr' => ['placeholder' => 'company.edit.auto_product_url.placeholder'],
'required' => false,
'empty_data' => '',

View file

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
@ -28,7 +31,7 @@ use Symfony\Component\Form\FormBuilderInterface;
class CurrencyAdminForm extends BaseEntityAdminForm
{
protected function additionalFormElements(FormBuilderInterface $builder, array $options, NamedDBElement $entity)
protected function additionalFormElements(FormBuilderInterface $builder, array $options, NamedDBElement $entity): void
{
$is_new = null === $entity->getID();
@ -37,13 +40,13 @@ class CurrencyAdminForm extends BaseEntityAdminForm
'label' => 'currency.edit.iso_code',
'preferred_choices' => ['EUR', 'USD', 'GBP', 'JPY', 'CNY'],
'attr' => ['class' => 'selectpicker', 'data-live-search' => true],
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity), ]);
'disabled' => ! $this->security->isGranted($is_new ? 'create' : 'edit', $entity), ]);
$builder->add('exchange_rate', MoneyType::class, [
'required' => false,
'label' => 'currency.edit.exchange_rate',
'currency' => $this->params->get('default_currency'),
'scale' => 6,
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity), ]);
'disabled' => ! $this->security->isGranted($is_new ? 'create' : 'edit', $entity), ]);
}
}

View file

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
@ -27,11 +30,11 @@ use Symfony\Component\Form\FormBuilderInterface;
class FootprintAdminForm extends BaseEntityAdminForm
{
public function additionalFormElements(FormBuilderInterface $builder, array $options, NamedDBElement $entity)
public function additionalFormElements(FormBuilderInterface $builder, array $options, NamedDBElement $entity): void
{
$builder->add('footprint_3d', MasterPictureAttachmentType::class, [
'required' => false,
'disabled' => !$this->security->isGranted(null === $entity->getID() ? 'create' : 'edit', $entity),
'disabled' => ! $this->security->isGranted(null === $entity->getID() ? 'create' : 'edit', $entity),
'label' => 'footprint.edit.3d_model',
'filter' => '3d_model',
'entity' => $entity,

View file

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
@ -28,7 +31,7 @@ use Symfony\Component\Form\FormBuilderInterface;
class GroupAdminForm extends BaseEntityAdminForm
{
protected function additionalFormElements(FormBuilderInterface $builder, array $options, NamedDBElement $entity)
protected function additionalFormElements(FormBuilderInterface $builder, array $options, NamedDBElement $entity): void
{
$is_new = null === $entity->getID();
@ -36,13 +39,13 @@ class GroupAdminForm extends BaseEntityAdminForm
'label' => 'group.edit.enforce_2fa',
'help' => 'entity.edit.enforce_2fa.help',
'label_attr' => ['class' => 'checkbox-custom'],
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity),
'disabled' => ! $this->security->isGranted($is_new ? 'create' : 'edit', $entity),
]);
$builder->add('permissions', PermissionsType::class, [
'mapped' => false,
'data' => $builder->getData(),
'disabled' => !$this->security->isGranted('edit_permissions', $entity),
'disabled' => ! $this->security->isGranted('edit_permissions', $entity),
]);
}
}

View file

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
@ -41,14 +44,14 @@ class ImportType extends AbstractType
$this->security = $security;
}
public function buildForm(FormBuilderInterface $builder, array $options)
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$data = $options['data'];
//Disable import if user is not allowed to create elements.
$entity = new $data['entity_class']();
$perm_name = 'create';
$disabled = !$this->security->isGranted($perm_name, $entity);
$disabled = ! $this->security->isGranted($perm_name, $entity);
$builder

View file

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
@ -38,14 +41,14 @@ class MassCreationForm extends AbstractType
$this->security = $security;
}
public function buildForm(FormBuilderInterface $builder, array $options)
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$data = $options['data'];
//Disable import if user is not allowed to create elements.
$entity = new $data['entity_class']();
$perm_name = 'create';
$disabled = !$this->security->isGranted($perm_name, $entity);
$disabled = ! $this->security->isGranted($perm_name, $entity);
$builder
->add('lines', TextareaType::class, ['data' => '',

View file

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
@ -28,7 +31,7 @@ use Symfony\Component\Form\FormBuilderInterface;
class MeasurementUnitAdminForm extends BaseEntityAdminForm
{
protected function additionalFormElements(FormBuilderInterface $builder, array $options, NamedDBElement $entity)
protected function additionalFormElements(FormBuilderInterface $builder, array $options, NamedDBElement $entity): void
{
$is_new = null === $entity->getID();
@ -36,17 +39,17 @@ class MeasurementUnitAdminForm extends BaseEntityAdminForm
'label' => 'measurement_unit.edit.is_integer',
'help' => 'measurement_unit.edit.is_integer.help',
'label_attr' => ['class' => 'checkbox-custom'],
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity), ]);
'disabled' => ! $this->security->isGranted($is_new ? 'create' : 'edit', $entity), ]);
$builder->add('use_si_prefix', CheckboxType::class, ['required' => false,
'label' => 'measurement_unit.edit.use_si_prefix',
'help' => 'measurement_unit.edit.use_si_prefix.help',
'label_attr' => ['class' => 'checkbox-custom'],
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity), ]);
'disabled' => ! $this->security->isGranted($is_new ? 'create' : 'edit', $entity), ]);
$builder->add('unit', TextType::class, ['required' => false,
'label' => 'measurement_unit.edit.unit_symbol',
'attr' => ['placeholder' => 'measurement_unit.edit.unit_symbol.placeholder'],
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity), ]);
'disabled' => ! $this->security->isGranted($is_new ? 'create' : 'edit', $entity), ]);
}
}

View file

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
@ -29,7 +32,7 @@ use Symfony\Component\Form\FormBuilderInterface;
class StorelocationAdminForm extends BaseEntityAdminForm
{
protected function additionalFormElements(FormBuilderInterface $builder, array $options, NamedDBElement $entity)
protected function additionalFormElements(FormBuilderInterface $builder, array $options, NamedDBElement $entity): void
{
$is_new = null === $entity->getID();
@ -38,27 +41,27 @@ class StorelocationAdminForm extends BaseEntityAdminForm
'label' => 'storelocation.edit.is_full.label',
'help' => 'storelocation.edit.is_full.help',
'label_attr' => ['class' => 'checkbox-custom'],
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'move', $entity), ]);
'disabled' => ! $this->security->isGranted($is_new ? 'create' : 'move', $entity), ]);
$builder->add('limit_to_existing_parts', CheckboxType::class, [
'required' => false,
'label' => 'storelocation.limit_to_existing.label',
'help' => 'storelocation.limit_to_existing.help',
'label_attr' => ['class' => 'checkbox-custom'],
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'move', $entity), ]);
'disabled' => ! $this->security->isGranted($is_new ? 'create' : 'move', $entity), ]);
$builder->add('only_single_part', CheckboxType::class, [
'required' => false,
'label' => 'storelocation.only_single_part.label',
'help' => 'storelocation.only_single_part.help',
'label_attr' => ['class' => 'checkbox-custom'],
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'move', $entity), ]);
'disabled' => ! $this->security->isGranted($is_new ? 'create' : 'move', $entity), ]);
$builder->add('storage_type', StructuralEntityType::class, [
'required' => false,
'label' => 'storelocation.storage_type.label',
'help' => 'storelocation.storage_type.help',
'class' => MeasurementUnit::class, 'disable_not_selectable' => true,
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'move', $entity), ]);
'disabled' => ! $this->security->isGranted($is_new ? 'create' : 'move', $entity), ]);
}
}

View file

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
@ -29,7 +32,7 @@ use Symfony\Component\Form\FormBuilderInterface;
class SupplierForm extends CompanyForm
{
protected function additionalFormElements(FormBuilderInterface $builder, array $options, NamedDBElement $entity)
protected function additionalFormElements(FormBuilderInterface $builder, array $options, NamedDBElement $entity): void
{
$is_new = null === $entity->getID();
@ -40,14 +43,14 @@ class SupplierForm extends CompanyForm
'required' => false,
'label' => 'supplier.edit.default_currency',
'disable_not_selectable' => true,
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'move', $entity), ]);
'disabled' => ! $this->security->isGranted($is_new ? 'create' : 'move', $entity), ]);
$builder->add('shipping_costs', MoneyType::class, [
'required' => false,
'currency' => $this->params->get('default_currency'),
'scale' => 3,
'label' => 'supplier.shipping_costs.label',
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'move', $entity),
'disabled' => ! $this->security->isGranted($is_new ? 'create' : 'move', $entity),
]);
}
}

View file

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
@ -53,7 +56,7 @@ class AttachmentFormType extends AbstractType
$this->allow_attachments_download = $allow_attachments_downloads;
}
public function buildForm(FormBuilderInterface $builder, array $options)
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder->add('name', TextType::class, [
'label' => 'attachment.edit.name',
@ -94,7 +97,7 @@ class AttachmentFormType extends AbstractType
$builder->add('downloadURL', CheckboxType::class, ['required' => false,
'label' => 'attachment.edit.download_url',
'mapped' => false,
'disabled' => !$this->allow_attachments_download,
'disabled' => ! $this->allow_attachments_download,
'attr' => ['class' => 'form-control-sm'],
'label_attr' => ['class' => 'checkbox-custom'], ]);
@ -114,7 +117,7 @@ class AttachmentFormType extends AbstractType
//Check the secure file checkbox, if file is in securefile location
$builder->get('secureFile')->addEventListener(
FormEvents::PRE_SET_DATA,
function (FormEvent $event) {
function (FormEvent $event): void {
$attachment = $event->getForm()->getParent()->getData();
if ($attachment instanceof Attachment) {
$event->setData($attachment->isSecure());
@ -123,7 +126,7 @@ class AttachmentFormType extends AbstractType
);
}
public function configureOptions(OptionsResolver $resolver)
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
'data_class' => Attachment::class,

View file

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
@ -46,7 +49,7 @@ class OrderdetailType extends AbstractType
$this->security = $security;
}
public function buildForm(FormBuilderInterface $builder, array $options)
public function buildForm(FormBuilderInterface $builder, array $options): void
{
/** @var Orderdetail $orderdetail */
$orderdetail = $builder->getData();
@ -76,7 +79,7 @@ class OrderdetailType extends AbstractType
]);
//Add pricedetails after we know the data, so we can set the default currency
$builder->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) use ($options) {
$builder->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) use ($options): void {
/** @var Orderdetail $orderdetail */
$orderdetail = $event->getData();
@ -94,14 +97,14 @@ class OrderdetailType extends AbstractType
'prototype_data' => $dummy_pricedetail,
'by_reference' => false,
'entry_options' => [
'disabled' => !$this->security->isGranted('@parts_prices.edit'),
'disabled' => ! $this->security->isGranted('@parts_prices.edit'),
'measurement_unit' => $options['measurement_unit'],
],
]);
});
}
public function configureOptions(OptionsResolver $resolver)
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
'data_class' => Orderdetail::class,

View file

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
@ -59,7 +62,7 @@ class PartBaseType extends AbstractType
$this->urlGenerator = $urlGenerator;
}
public function buildForm(FormBuilderInterface $builder, array $options)
public function buildForm(FormBuilderInterface $builder, array $options): void
{
/** @var Part $part */
$part = $builder->getData();
@ -79,7 +82,7 @@ class PartBaseType extends AbstractType
'empty_data' => '',
'label' => 'part.edit.name',
'attr' => ['placeholder' => 'part.edit.name.placeholder'],
'disabled' => !$this->security->isGranted('name.edit', $part),
'disabled' => ! $this->security->isGranted('name.edit', $part),
])
->add('description', CKEditorType::class, [
'required' => false,
@ -87,26 +90,26 @@ class PartBaseType extends AbstractType
'label' => 'part.edit.description',
'config_name' => 'description_config',
'attr' => ['placeholder' => 'part.edit.description.placeholder', 'rows' => 2],
'disabled' => !$this->security->isGranted('description.edit', $part),
'disabled' => ! $this->security->isGranted('description.edit', $part),
])
->add('minAmount', SIUnitType::class, [
'attr' => ['min' => 0, 'placeholder' => 'part.editmininstock.placeholder'],
'label' => 'part.edit.mininstock',
'measurement_unit' => $part->getPartUnit(),
'disabled' => !$this->security->isGranted('minamount.edit', $part),
'disabled' => ! $this->security->isGranted('minamount.edit', $part),
])
->add('category', StructuralEntityType::class, [
'class' => Category::class,
'label' => 'part.edit.category',
'disable_not_selectable' => true,
'disabled' => !$this->security->isGranted('category.edit', $part),
'disabled' => ! $this->security->isGranted('category.edit', $part),
])
->add('footprint', StructuralEntityType::class, [
'class' => Footprint::class,
'required' => false,
'label' => 'part.edit.footprint',
'disable_not_selectable' => true,
'disabled' => !$this->security->isGranted('footprint.edit', $part),
'disabled' => ! $this->security->isGranted('footprint.edit', $part),
])
->add('tags', TextType::class, [
'required' => false,
@ -115,7 +118,7 @@ class PartBaseType extends AbstractType
'attr' => [
'class' => 'tagsinput',
'data-autocomplete' => $this->urlGenerator->generate('typeahead_tags', ['query' => 'QUERY']), ],
'disabled' => !$this->security->isGranted('tags.edit', $part),
'disabled' => ! $this->security->isGranted('tags.edit', $part),
]);
//Manufacturer section
@ -124,24 +127,24 @@ class PartBaseType extends AbstractType
'required' => false,
'label' => 'part.edit.manufacturer.label',
'disable_not_selectable' => true,
'disabled' => !$this->security->isGranted('manufacturer.edit', $part),
'disabled' => ! $this->security->isGranted('manufacturer.edit', $part),
])
->add('manufacturer_product_url', UrlType::class, [
'required' => false,
'empty_data' => '',
'label' => 'part.edit.manufacturer_url.label',
'disabled' => !$this->security->isGranted('mpn.edit', $part),
'disabled' => ! $this->security->isGranted('mpn.edit', $part),
])
->add('manufacturer_product_number', TextType::class, [
'required' => false,
'empty_data' => '',
'label' => 'part.edit.mpn',
'disabled' => !$this->security->isGranted('mpn.edit', $part), ])
'disabled' => ! $this->security->isGranted('mpn.edit', $part), ])
->add('manufacturing_status', ChoiceType::class, [
'label' => 'part.edit.manufacturing_status',
'choices' => $status_choices,
'required' => false,
'disabled' => !$this->security->isGranted('status.edit', $part),
'disabled' => ! $this->security->isGranted('status.edit', $part),
]);
//Advanced section
@ -149,26 +152,26 @@ class PartBaseType extends AbstractType
'label_attr' => ['class' => 'checkbox-custom'],
'required' => false,
'label' => 'part.edit.needs_review',
'disabled' => !$this->security->isGranted('edit', $part),
'disabled' => ! $this->security->isGranted('edit', $part),
])
->add('favorite', CheckboxType::class, [
'label_attr' => ['class' => 'checkbox-custom'],
'required' => false,
'label' => 'part.edit.is_favorite',
'disabled' => !$this->security->isGranted('change_favorite', $part),
'disabled' => ! $this->security->isGranted('change_favorite', $part),
])
->add('mass', SIUnitType::class, [
'unit' => 'g',
'label' => 'part.edit.mass',
'required' => false,
'disabled' => !$this->security->isGranted('mass.edit', $part),
'disabled' => ! $this->security->isGranted('mass.edit', $part),
])
->add('partUnit', StructuralEntityType::class, [
'class' => MeasurementUnit::class,
'required' => false,
'disable_not_selectable' => true,
'label' => 'part.edit.partUnit',
'disabled' => !$this->security->isGranted('unit.edit', $part),
'disabled' => ! $this->security->isGranted('unit.edit', $part),
]);
//Comment section
@ -176,7 +179,7 @@ class PartBaseType extends AbstractType
'required' => false,
'label' => 'part.edit.comment',
'attr' => ['rows' => 4],
'disabled' => !$this->security->isGranted('comment.edit', $part), 'empty_data' => '',
'disabled' => ! $this->security->isGranted('comment.edit', $part), 'empty_data' => '',
]);
//Part Lots section
@ -187,7 +190,7 @@ class PartBaseType extends AbstractType
'label' => false,
'entry_options' => [
'measurement_unit' => $part->getPartUnit(),
'disabled' => !$this->security->isGranted('lots.edit', $part),
'disabled' => ! $this->security->isGranted('lots.edit', $part),
],
'by_reference' => false,
]);
@ -200,14 +203,14 @@ class PartBaseType extends AbstractType
'label' => false,
'entry_options' => [
'data_class' => PartAttachment::class,
'disabled' => !$this->security->isGranted('attachments.edit', $part),
'disabled' => ! $this->security->isGranted('attachments.edit', $part),
],
'by_reference' => false,
]);
$builder->add('master_picture_attachment', MasterPictureAttachmentType::class, [
'required' => false,
'disabled' => !$this->security->isGranted('attachments.edit', $part),
'disabled' => ! $this->security->isGranted('attachments.edit', $part),
'label' => 'part.edit.master_attachment',
'entity' => $part,
]);
@ -222,7 +225,7 @@ class PartBaseType extends AbstractType
'prototype_data' => new Orderdetail(),
'entry_options' => [
'measurement_unit' => $part->getPartUnit(),
'disabled' => !$this->security->isGranted('orderdetails.edit', $part),
'disabled' => ! $this->security->isGranted('orderdetails.edit', $part),
],
]);
@ -232,7 +235,7 @@ class PartBaseType extends AbstractType
->add('reset', ResetType::class, ['label' => 'part.edit.reset']);
}
public function configureOptions(OptionsResolver $resolver)
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
'data_class' => Part::class,

View file

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
@ -43,7 +46,7 @@ class PartLotType extends AbstractType
$this->security = $security;
}
public function buildForm(FormBuilderInterface $builder, array $options)
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder->add('description', TextType::class, [
'label' => 'part_lot.edit.description',
@ -89,7 +92,7 @@ class PartLotType extends AbstractType
]);
}
public function configureOptions(OptionsResolver $resolver)
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
'data_class' => PartLot::class,

View file

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
@ -32,7 +35,7 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
class PricedetailType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
public function buildForm(FormBuilderInterface $builder, array $options): void
{
//No labels needed, we define translation in templates
$builder->add('min_discount_quantity', SIUnitType::class, [
@ -57,7 +60,7 @@ class PricedetailType extends AbstractType
]);
}
public function configureOptions(OptionsResolver $resolver)
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
'data_class' => Pricedetail::class,

Some files were not shown because too many files have changed in this diff Show more