mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-21 09:35:49 +02:00
Applied code style rules to src/
This commit is contained in:
parent
700c049d26
commit
f861de791f
186 changed files with 1462 additions and 1059 deletions
2
ecs.yaml
2
ecs.yaml
|
@ -6,5 +6,5 @@ parameters:
|
||||||
- "clean-code"
|
- "clean-code"
|
||||||
- "common"
|
- "common"
|
||||||
# very nice to have ↓
|
# very nice to have ↓
|
||||||
- "symplify"
|
#- "symplify"
|
||||||
- "symfony"
|
- "symfony"
|
|
@ -1,4 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
* 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();
|
parent::__construct();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function configure()
|
protected function configure(): void
|
||||||
{
|
{
|
||||||
$this
|
$this
|
||||||
->setDescription('Lists (and deletes if wanted) attachments files that are not used anymore (abandoned files).')
|
->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.');
|
' 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);
|
$io = new SymfonyStyle($input, $output);
|
||||||
|
|
||||||
|
@ -84,7 +87,7 @@ class CleanAttachmentsCommand extends Command
|
||||||
|
|
||||||
foreach ($finder as $file) {
|
foreach ($finder as $file) {
|
||||||
//If not attachment object uses this file, print it
|
//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;
|
$file_list[] = $file;
|
||||||
$table->addRow([
|
$table->addRow([
|
||||||
$fs->makePathRelative($file->getPathname(), $mediaPath),
|
$fs->makePathRelative($file->getPathname(), $mediaPath),
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
* 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();
|
parent::__construct();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function configure()
|
protected function configure(): void
|
||||||
{
|
{
|
||||||
$this
|
$this
|
||||||
->setDescription('Converts BBCode used in old Part-DB versions to newly used Markdown')
|
->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);
|
$io = new SymfonyStyle($input, $output);
|
||||||
$targets = $this->getTargetsLists();
|
$targets = $this->getTargetsLists();
|
||||||
|
@ -126,7 +129,7 @@ class ConvertBBCodeCommand extends Command
|
||||||
|
|
||||||
//In verbose mode print the names of the entities
|
//In verbose mode print the names of the entities
|
||||||
foreach ($results as $result) {
|
foreach ($results as $result) {
|
||||||
/* @var NamedDBElement $result */
|
/** @var NamedDBElement $result */
|
||||||
$io->writeln(
|
$io->writeln(
|
||||||
'Convert entity: '.$result->getName().' ('.$result->getIDString().')',
|
'Convert entity: '.$result->getName().' ('.$result->getIDString().')',
|
||||||
OutputInterface::VERBOSITY_VERBOSE
|
OutputInterface::VERBOSITY_VERBOSE
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
* 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();
|
parent::__construct();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function configure()
|
protected function configure(): void
|
||||||
{
|
{
|
||||||
$this
|
$this
|
||||||
->setDescription('Sets the password of a user')
|
->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);
|
$io = new SymfonyStyle($input, $output);
|
||||||
$user_name = $input->getArgument('user');
|
$user_name = $input->getArgument('user');
|
||||||
|
|
||||||
/**
|
/** @var User */
|
||||||
* @var User
|
|
||||||
*/
|
|
||||||
$users = $this->entityManager->getRepository(User::class)->findBy(['name' => $user_name]);
|
$users = $this->entityManager->getRepository(User::class)->findBy(['name' => $user_name]);
|
||||||
$user = $users[0];
|
$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));
|
$io->error(sprintf('No user with the given username %s found in the database!', $user_name));
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
* 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();
|
parent::__construct();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function configure()
|
protected function configure(): void
|
||||||
{
|
{
|
||||||
$this
|
$this
|
||||||
->setDescription('Updates the currency exchange rates.')
|
->setDescription('Updates the currency exchange rates.')
|
||||||
|
@ -62,7 +65,7 @@ class UpdateExchangeRatesCommand extends Command
|
||||||
null);
|
null);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function execute(InputInterface $input, OutputInterface $output)
|
protected function execute(InputInterface $input, OutputInterface $output): void
|
||||||
{
|
{
|
||||||
$io = new SymfonyStyle($input, $output);
|
$io = new SymfonyStyle($input, $output);
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||||
*
|
*
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||||
*
|
*
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||||
*
|
*
|
||||||
|
@ -90,11 +93,12 @@ abstract class BaseAdminController extends AbstractController
|
||||||
//Upload passed files
|
//Upload passed files
|
||||||
$attachments = $form['attachments'];
|
$attachments = $form['attachments'];
|
||||||
foreach ($attachments as $attachment) {
|
foreach ($attachments as $attachment) {
|
||||||
/** @var $attachment FormInterface */
|
/** @var FormInterface $attachment */
|
||||||
$options = [
|
$options = [
|
||||||
'secure_attachment' => $attachment['secureFile']->getData(),
|
'secure_attachment' => $attachment['secureFile']->getData(),
|
||||||
'download_url' => $attachment['downloadURL']->getData(),
|
'download_url' => $attachment['downloadURL']->getData(),
|
||||||
];
|
];
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$this->attachmentSubmitHandler->handleFormSubmit($attachment->getData(), $attachment['file']->getData(), $options);
|
$this->attachmentSubmitHandler->handleFormSubmit($attachment->getData(), $attachment['file']->getData(), $options);
|
||||||
} catch (AttachmentDownloadException $ex) {
|
} catch (AttachmentDownloadException $ex) {
|
||||||
|
@ -146,11 +150,12 @@ abstract class BaseAdminController extends AbstractController
|
||||||
//Upload passed files
|
//Upload passed files
|
||||||
$attachments = $form['attachments'];
|
$attachments = $form['attachments'];
|
||||||
foreach ($attachments as $attachment) {
|
foreach ($attachments as $attachment) {
|
||||||
/** @var $attachment FormInterface */
|
/** @var FormInterface $attachment */
|
||||||
$options = [
|
$options = [
|
||||||
'secure_attachment' => $attachment['secureFile']->getData(),
|
'secure_attachment' => $attachment['secureFile']->getData(),
|
||||||
'download_url' => $attachment['downloadURL']->getData(),
|
'download_url' => $attachment['downloadURL']->getData(),
|
||||||
];
|
];
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$this->attachmentSubmitHandler->handleFormSubmit($attachment->getData(), $attachment['file']->getData(), $options);
|
$this->attachmentSubmitHandler->handleFormSubmit($attachment->getData(), $attachment['file']->getData(), $options);
|
||||||
} catch (AttachmentDownloadException $ex) {
|
} catch (AttachmentDownloadException $ex) {
|
||||||
|
@ -187,7 +192,7 @@ abstract class BaseAdminController extends AbstractController
|
||||||
$errors = $importer->fileToDBEntities($file, $this->entity_class, $options);
|
$errors = $importer->fileToDBEntities($file, $this->entity_class, $options);
|
||||||
|
|
||||||
foreach ($errors as $name => $error) {
|
foreach ($errors as $name => $error) {
|
||||||
/* @var $error ConstraintViolationList */
|
/** @var ConstraintViolationList $error */
|
||||||
$this->addFlash('error', $name.':'.$error);
|
$this->addFlash('error', $name.':'.$error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||||
*
|
*
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||||
*
|
*
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||||
*
|
*
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
* 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\Request;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
use Symfony\Component\Routing\Annotation\Route;
|
use Symfony\Component\Routing\Annotation\Route;
|
||||||
use Symfony\Component\Serializer\SerializerInterface;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Route("/footprint")
|
* @Route("/footprint")
|
||||||
|
@ -76,8 +78,6 @@ class FootprintController extends BaseAdminController
|
||||||
/**
|
/**
|
||||||
* @Route("/export", name="footprint_export_all")
|
* @Route("/export", name="footprint_export_all")
|
||||||
*
|
*
|
||||||
* @param SerializerInterface $serializer
|
|
||||||
*
|
|
||||||
* @return Response
|
* @return Response
|
||||||
*/
|
*/
|
||||||
public function exportAll(EntityManagerInterface $em, EntityExporter $exporter, Request $request)
|
public function exportAll(EntityManagerInterface $em, EntityExporter $exporter, Request $request)
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
* 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\Request;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
use Symfony\Component\Routing\Annotation\Route;
|
use Symfony\Component\Routing\Annotation\Route;
|
||||||
use Symfony\Component\Serializer\SerializerInterface;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Route("/manufacturer")
|
* @Route("/manufacturer")
|
||||||
|
@ -76,8 +78,6 @@ class ManufacturerController extends BaseAdminController
|
||||||
/**
|
/**
|
||||||
* @Route("/export", name="manufacturer_export_all")
|
* @Route("/export", name="manufacturer_export_all")
|
||||||
*
|
*
|
||||||
* @param SerializerInterface $serializer
|
|
||||||
*
|
|
||||||
* @return Response
|
* @return Response
|
||||||
*/
|
*/
|
||||||
public function exportAll(EntityManagerInterface $em, EntityExporter $exporter, Request $request)
|
public function exportAll(EntityManagerInterface $em, EntityExporter $exporter, Request $request)
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
* 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\Request;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
use Symfony\Component\Routing\Annotation\Route;
|
use Symfony\Component\Routing\Annotation\Route;
|
||||||
use Symfony\Component\Serializer\SerializerInterface;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Route("/measurement_unit")
|
* @Route("/measurement_unit")
|
||||||
|
@ -76,8 +78,6 @@ class MeasurementUnitController extends BaseAdminController
|
||||||
/**
|
/**
|
||||||
* @Route("/export", name="measurement_unit_export_all")
|
* @Route("/export", name="measurement_unit_export_all")
|
||||||
*
|
*
|
||||||
* @param SerializerInterface $serializer
|
|
||||||
*
|
|
||||||
* @return Response
|
* @return Response
|
||||||
*/
|
*/
|
||||||
public function exportAll(EntityManagerInterface $em, EntityExporter $exporter, Request $request)
|
public function exportAll(EntityManagerInterface $em, EntityExporter $exporter, Request $request)
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
* 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\Request;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
use Symfony\Component\Routing\Annotation\Route;
|
use Symfony\Component\Routing\Annotation\Route;
|
||||||
use Symfony\Component\Serializer\SerializerInterface;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Route("/store_location")
|
* @Route("/store_location")
|
||||||
|
@ -75,8 +77,6 @@ class StorelocationController extends BaseAdminController
|
||||||
/**
|
/**
|
||||||
* @Route("/export", name="store_location_export_all")
|
* @Route("/export", name="store_location_export_all")
|
||||||
*
|
*
|
||||||
* @param SerializerInterface $serializer
|
|
||||||
*
|
|
||||||
* @return Response
|
* @return Response
|
||||||
*/
|
*/
|
||||||
public function exportAll(EntityManagerInterface $em, EntityExporter $exporter, Request $request)
|
public function exportAll(EntityManagerInterface $em, EntityExporter $exporter, Request $request)
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
* 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\Request;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
use Symfony\Component\Routing\Annotation\Route;
|
use Symfony\Component\Routing\Annotation\Route;
|
||||||
use Symfony\Component\Serializer\SerializerInterface;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Route("/supplier")
|
* @Route("/supplier")
|
||||||
|
@ -75,8 +77,6 @@ class SupplierController extends BaseAdminController
|
||||||
/**
|
/**
|
||||||
* @Route("/export", name="supplier_export_all")
|
* @Route("/export", name="supplier_export_all")
|
||||||
*
|
*
|
||||||
* @param SerializerInterface $serializer
|
|
||||||
*
|
|
||||||
* @return Response
|
* @return Response
|
||||||
*/
|
*/
|
||||||
public function exportAll(EntityManagerInterface $em, EntityExporter $exporter, Request $request)
|
public function exportAll(EntityManagerInterface $em, EntityExporter $exporter, Request $request)
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||||
*
|
*
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||||
*
|
*
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||||
*
|
*
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
* 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
|
//Upload passed files
|
||||||
$attachments = $form['attachments'];
|
$attachments = $form['attachments'];
|
||||||
foreach ($attachments as $attachment) {
|
foreach ($attachments as $attachment) {
|
||||||
/** @var $attachment FormInterface */
|
/** @var FormInterface $attachment */
|
||||||
$options = [
|
$options = [
|
||||||
'secure_attachment' => $attachment['secureFile']->getData(),
|
'secure_attachment' => $attachment['secureFile']->getData(),
|
||||||
'download_url' => $attachment['downloadURL']->getData(),
|
'download_url' => $attachment['downloadURL']->getData(),
|
||||||
];
|
];
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$attachmentSubmitHandler->handleFormSubmit($attachment->getData(), $attachment['file']->getData(), $options);
|
$attachmentSubmitHandler->handleFormSubmit($attachment->getData(), $attachment['file']->getData(), $options);
|
||||||
} catch (AttachmentDownloadException $ex) {
|
} catch (AttachmentDownloadException $ex) {
|
||||||
|
@ -163,11 +166,12 @@ class PartController extends AbstractController
|
||||||
//Upload passed files
|
//Upload passed files
|
||||||
$attachments = $form['attachments'];
|
$attachments = $form['attachments'];
|
||||||
foreach ($attachments as $attachment) {
|
foreach ($attachments as $attachment) {
|
||||||
/** @var $attachment FormInterface */
|
/** @var FormInterface $attachment */
|
||||||
$options = [
|
$options = [
|
||||||
'secure_attachment' => $attachment['secureFile']->getData(),
|
'secure_attachment' => $attachment['secureFile']->getData(),
|
||||||
'download_url' => $attachment['downloadURL']->getData(),
|
'download_url' => $attachment['downloadURL']->getData(),
|
||||||
];
|
];
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$attachmentSubmitHandler->handleFormSubmit($attachment->getData(), $attachment['file']->getData(), $options);
|
$attachmentSubmitHandler->handleFormSubmit($attachment->getData(), $attachment['file']->getData(), $options);
|
||||||
} catch (AttachmentDownloadException $ex) {
|
} catch (AttachmentDownloadException $ex) {
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
* 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")
|
* @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
|
* @return \Symfony\Component\HttpFoundation\JsonResponse|\Symfony\Component\HttpFoundation\Response
|
||||||
*/
|
*/
|
||||||
public function showCategory(Category $category, Request $request, DataTableFactory $dataTable)
|
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")
|
* @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
|
* @return \Symfony\Component\HttpFoundation\JsonResponse|\Symfony\Component\HttpFoundation\Response
|
||||||
*/
|
*/
|
||||||
public function showFootprint(Footprint $footprint, Request $request, DataTableFactory $dataTable)
|
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")
|
* @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
|
* @return \Symfony\Component\HttpFoundation\JsonResponse|\Symfony\Component\HttpFoundation\Response
|
||||||
*/
|
*/
|
||||||
public function showManufacturer(Manufacturer $manufacturer, Request $request, DataTableFactory $dataTable)
|
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")
|
* @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
|
* @return \Symfony\Component\HttpFoundation\JsonResponse|\Symfony\Component\HttpFoundation\Response
|
||||||
*/
|
*/
|
||||||
public function showStorelocation(Storelocation $storelocation, Request $request, DataTableFactory $dataTable)
|
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")
|
* @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
|
* @return \Symfony\Component\HttpFoundation\JsonResponse|\Symfony\Component\HttpFoundation\Response
|
||||||
*/
|
*/
|
||||||
public function showSupplier(Supplier $supplier, Request $request, DataTableFactory $dataTable)
|
public function showSupplier(Supplier $supplier, Request $request, DataTableFactory $dataTable)
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||||
*
|
*
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||||
*
|
*
|
||||||
|
@ -109,7 +112,7 @@ class SecurityController extends AbstractController
|
||||||
/**
|
/**
|
||||||
* @Route("/pw_reset/new_pw/{user}/{token}", name="pw_reset_new_pw")
|
* @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!');
|
throw new AccessDeniedHttpException('The password reset via email is disabled!');
|
||||||
|
@ -166,7 +169,7 @@ class SecurityController extends AbstractController
|
||||||
/**
|
/**
|
||||||
* @Route("/logout", name="logout")
|
* @Route("/logout", name="logout")
|
||||||
*/
|
*/
|
||||||
public function logout()
|
public function logout(): void
|
||||||
{
|
{
|
||||||
throw new \RuntimeException('Will be intercepted before getting here');
|
throw new \RuntimeException('Will be intercepted before getting here');
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
* 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("/category/{id}", name="tree_category")
|
||||||
* @Route("/categories")
|
* @Route("/categories")
|
||||||
*/
|
*/
|
||||||
public function categoryTree(Category $category = null)
|
public function categoryTree(?Category $category = null)
|
||||||
{
|
{
|
||||||
$tree = $this->treeGenerator->getTreeView(Category::class, $category);
|
$tree = $this->treeGenerator->getTreeView(Category::class, $category);
|
||||||
|
|
||||||
|
@ -72,7 +75,7 @@ class TreeController extends AbstractController
|
||||||
* @Route("/footprint/{id}", name="tree_footprint")
|
* @Route("/footprint/{id}", name="tree_footprint")
|
||||||
* @Route("/footprints")
|
* @Route("/footprints")
|
||||||
*/
|
*/
|
||||||
public function footprintTree(Footprint $footprint = null)
|
public function footprintTree(?Footprint $footprint = null)
|
||||||
{
|
{
|
||||||
$tree = $this->treeGenerator->getTreeView(Footprint::class, $footprint);
|
$tree = $this->treeGenerator->getTreeView(Footprint::class, $footprint);
|
||||||
|
|
||||||
|
@ -83,7 +86,7 @@ class TreeController extends AbstractController
|
||||||
* @Route("/location/{id}", name="tree_location")
|
* @Route("/location/{id}", name="tree_location")
|
||||||
* @Route("/locations")
|
* @Route("/locations")
|
||||||
*/
|
*/
|
||||||
public function locationTree(Storelocation $location = null)
|
public function locationTree(?Storelocation $location = null)
|
||||||
{
|
{
|
||||||
$tree = $this->treeGenerator->getTreeView(Storelocation::class, $location);
|
$tree = $this->treeGenerator->getTreeView(Storelocation::class, $location);
|
||||||
|
|
||||||
|
@ -94,7 +97,7 @@ class TreeController extends AbstractController
|
||||||
* @Route("/manufacturer/{id}", name="tree_manufacturer")
|
* @Route("/manufacturer/{id}", name="tree_manufacturer")
|
||||||
* @Route("/manufacturers")
|
* @Route("/manufacturers")
|
||||||
*/
|
*/
|
||||||
public function manufacturerTree(Manufacturer $manufacturer = null)
|
public function manufacturerTree(?Manufacturer $manufacturer = null)
|
||||||
{
|
{
|
||||||
$tree = $this->treeGenerator->getTreeView(Manufacturer::class, $manufacturer);
|
$tree = $this->treeGenerator->getTreeView(Manufacturer::class, $manufacturer);
|
||||||
|
|
||||||
|
@ -105,7 +108,7 @@ class TreeController extends AbstractController
|
||||||
* @Route("/supplier/{id}", name="tree_supplier")
|
* @Route("/supplier/{id}", name="tree_supplier")
|
||||||
* @Route("/suppliers")
|
* @Route("/suppliers")
|
||||||
*/
|
*/
|
||||||
public function supplierTree(Supplier $supplier = null)
|
public function supplierTree(?Supplier $supplier = null)
|
||||||
{
|
{
|
||||||
$tree = $this->treeGenerator->getTreeView(Supplier::class, $supplier);
|
$tree = $this->treeGenerator->getTreeView(Supplier::class, $supplier);
|
||||||
|
|
||||||
|
@ -116,7 +119,7 @@ class TreeController extends AbstractController
|
||||||
* @Route("/device/{id}", name="tree_device")
|
* @Route("/device/{id}", name="tree_device")
|
||||||
* @Route("/devices")
|
* @Route("/devices")
|
||||||
*/
|
*/
|
||||||
public function deviceTree(Device $device = null)
|
public function deviceTree(?Device $device = null)
|
||||||
{
|
{
|
||||||
$tree = $this->treeGenerator->getTreeView(Device::class, $device, '');
|
$tree = $this->treeGenerator->getTreeView(Device::class, $device, '');
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||||
*
|
*
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
* 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\Request;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
use Symfony\Component\Routing\Annotation\Route;
|
use Symfony\Component\Routing\Annotation\Route;
|
||||||
use Symfony\Component\Serializer\SerializerInterface;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Route("/user")
|
* @Route("/user")
|
||||||
|
@ -106,8 +108,6 @@ class UserController extends AdminPages\BaseAdminController
|
||||||
/**
|
/**
|
||||||
* @Route("/export", name="user_export_all")
|
* @Route("/export", name="user_export_all")
|
||||||
*
|
*
|
||||||
* @param SerializerInterface $serializer
|
|
||||||
*
|
|
||||||
* @return Response
|
* @return Response
|
||||||
*/
|
*/
|
||||||
public function exportAll(EntityManagerInterface $em, EntityExporter $exporter, Request $request)
|
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 = 'https://www.gravatar.com/avatar/';
|
||||||
$url .= md5(strtolower(trim($email)));
|
$url .= md5(strtolower(trim($email)));
|
||||||
$url .= "?s=$s&d=$d&r=$r";
|
$url .= "?s=${s}&d=${d}&r=${r}";
|
||||||
if ($img) {
|
if ($img) {
|
||||||
$url = '<img src="'.$url.'"';
|
$url = '<img src="'.$url.'"';
|
||||||
foreach ($atts as $key => $val) {
|
foreach ($atts as $key => $val) {
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||||
*
|
*
|
||||||
|
@ -67,6 +70,7 @@ class UserSettingsController extends AbstractController
|
||||||
|
|
||||||
if (empty($user->getBackupCodes())) {
|
if (empty($user->getBackupCodes())) {
|
||||||
$this->addFlash('error', 'tfa_backup.no_codes_enabled');
|
$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!');
|
throw new \RuntimeException('You do not have any backup codes enabled, therefore you can not view them!');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -103,12 +107,14 @@ class UserSettingsController extends AbstractController
|
||||||
$u2f = $key_repo->find($key_id);
|
$u2f = $key_repo->find($key_id);
|
||||||
if (null === $u2f) {
|
if (null === $u2f) {
|
||||||
$this->addFlash('danger', 'tfa_u2f.u2f_delete.not_existing');
|
$this->addFlash('danger', 'tfa_u2f.u2f_delete.not_existing');
|
||||||
|
|
||||||
throw new \RuntimeException('Key not existing!');
|
throw new \RuntimeException('Key not existing!');
|
||||||
}
|
}
|
||||||
|
|
||||||
//User can only delete its own U2F keys
|
//User can only delete its own U2F keys
|
||||||
if ($u2f->getUser() !== $user) {
|
if ($u2f->getUser() !== $user) {
|
||||||
$this->addFlash('danger', 'tfa_u2f.u2f_delete.access_denied');
|
$this->addFlash('danger', 'tfa_u2f.u2f_delete.access_denied');
|
||||||
|
|
||||||
throw new \RuntimeException('You can only delete your own U2F keys!');
|
throw new \RuntimeException('You can only delete your own U2F keys!');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -158,9 +164,7 @@ class UserSettingsController extends AbstractController
|
||||||
*/
|
*/
|
||||||
public function userSettings(Request $request, EntityManagerInterface $em, UserPasswordEncoderInterface $passwordEncoder, GoogleAuthenticator $googleAuthenticator, BackupCodeManager $backupCodeManager)
|
public function userSettings(Request $request, EntityManagerInterface $em, UserPasswordEncoderInterface $passwordEncoder, GoogleAuthenticator $googleAuthenticator, BackupCodeManager $backupCodeManager)
|
||||||
{
|
{
|
||||||
/**
|
/** @var User */
|
||||||
* @var User
|
|
||||||
*/
|
|
||||||
$user = $this->getUser();
|
$user = $this->getUser();
|
||||||
|
|
||||||
$page_need_reload = false;
|
$page_need_reload = false;
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
* 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
|
class AppFixtures extends Fixture
|
||||||
{
|
{
|
||||||
public function load(ObjectManager $manager)
|
public function load(ObjectManager $manager): void
|
||||||
{
|
{
|
||||||
// $product = new Product();
|
// $product = new Product();
|
||||||
// $manager->persist($product);
|
// $manager->persist($product);
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
* 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.
|
* Load data fixtures with the passed EntityManager.
|
||||||
*/
|
*/
|
||||||
public function load(ObjectManager $manager)
|
public function load(ObjectManager $manager): void
|
||||||
{
|
{
|
||||||
//Reset autoincrement
|
//Reset autoincrement
|
||||||
$types = [AttachmentType::class, Device::class, Category::class, Footprint::class, Manufacturer::class,
|
$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 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
|
* @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!');
|
throw new \InvalidArgumentException('$class must be a StructuralDBElement!');
|
||||||
}
|
}
|
||||||
|
|
||||||
$table_name = $this->em->getClassMetadata($class)->getTableName();
|
$table_name = $this->em->getClassMetadata($class)->getTableName();
|
||||||
$this->em->getConnection()->exec("ALTER TABLE `$table_name` AUTO_INCREMENT = 1;");
|
$this->em->getConnection()->exec("ALTER TABLE `${table_name}` AUTO_INCREMENT = 1;");
|
||||||
|
|
||||||
/** @var StructuralDBElement $node1 */
|
/** @var StructuralDBElement $node1 */
|
||||||
$node1 = new $class();
|
$node1 = new $class();
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
* 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 USERS = 'group-users';
|
||||||
public const READONLY = 'group-readonly';
|
public const READONLY = 'group-readonly';
|
||||||
|
|
||||||
public function load(ObjectManager $manager)
|
public function load(ObjectManager $manager): void
|
||||||
{
|
{
|
||||||
$admins = new Group();
|
$admins = new Group();
|
||||||
$admins->setName('admins');
|
$admins->setName('admins');
|
||||||
//Perm values taken from Version 1
|
//Perm values taken from Version 1
|
||||||
$admins->getPermissions()->setRawPermissionValues([
|
$admins->getPermissions()->setRawPermissionValues([
|
||||||
'system' => '21', 'groups' => '1365', 'users' => '87381', 'self' => '85', 'config' => '85',
|
'system' => 21, 'groups' => 1365, 'users' => 87381, 'self' => 85, 'config' => 85,
|
||||||
'database' => '21', 'parts' => '1431655765', 'parts_name' => '5', 'parts_description' => '5',
|
'database' => 21, 'parts' => 1431655765, 'parts_name' => 5, 'parts_description' => 5,
|
||||||
'parts_footprint' => '5', 'parts_manufacturer' => '5', 'parts_comment' => '5', 'parts_order' => '5',
|
'parts_footprint' => 5, 'parts_manufacturer' => 5, 'parts_comment' => 5, 'parts_order' => 5,
|
||||||
'parts_orderdetails' => '341', 'parts_prices' => '341', 'parts_attachments' => '341', 'devices' => '5461',
|
'parts_orderdetails' => 341, 'parts_prices' => 341, 'parts_attachments' => 341, 'devices' => 5461,
|
||||||
'devices_parts' => '325', 'storelocations' => '5461', 'footprints' => '5461', 'categories' => '5461',
|
'devices_parts' => 325, 'storelocations' => 5461, 'footprints' => 5461, 'categories' => 5461,
|
||||||
'suppliers' => '5461', 'manufacturers' => '5461', 'attachment_types' => '1365', 'tools' => '1365',
|
'suppliers' => 5461, 'manufacturers' => 5461, 'attachment_types' => 1365, 'tools' => 1365,
|
||||||
'labels' => '21', 'parts_category' => '5', 'parts_minamount' => '5', 'parts_lots' => '85', 'parts_tags' => '5',
|
'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',
|
'parts_unit' => 5, 'parts_mass' => 5, 'parts_status' => 5, 'parts_mpn' => 5, 'currencies' => 5461,
|
||||||
'measurement_units' => '5461',
|
'measurement_units' => 5461,
|
||||||
]);
|
]);
|
||||||
$this->setReference(self::ADMINS, $admins);
|
$this->setReference(self::ADMINS, $admins);
|
||||||
$manager->persist($admins);
|
$manager->persist($admins);
|
||||||
|
@ -53,15 +56,15 @@ class GroupFixtures extends Fixture
|
||||||
$readonly = new Group();
|
$readonly = new Group();
|
||||||
$readonly->setName('readonly');
|
$readonly->setName('readonly');
|
||||||
$readonly->getPermissions()->setRawPermissionValues([
|
$readonly->getPermissions()->setRawPermissionValues([
|
||||||
'system' => '2', 'groups' => '2730', 'users' => '43690', 'self' => '25', 'config' => '170',
|
'system' => 2, 'groups' => 2730, 'users' => 43690, 'self' => 25, 'config' => 170,
|
||||||
'database' => '42', 'parts' => '2778027689', 'parts_name' => '9', 'parts_description' => '9',
|
'database' => 42, 'parts' => 2778027689, 'parts_name' => 9, 'parts_description' => 9,
|
||||||
'parts_footprint' => '9', 'parts_manufacturer' => '9', 'parts_comment' => '9', 'parts_order' => '9',
|
'parts_footprint' => 9, 'parts_manufacturer' => 9, 'parts_comment' => 9, 'parts_order' => 9,
|
||||||
'parts_orderdetails' => '681', 'parts_prices' => '681', 'parts_attachments' => '681', 'devices' => '1705',
|
'parts_orderdetails' => 681, 'parts_prices' => 681, 'parts_attachments' => 681, 'devices' => 1705,
|
||||||
'devices_parts' => '649', 'storelocations' => '1705', 'footprints' => '1705', 'categories' => '1705',
|
'devices_parts' => 649, 'storelocations' => 1705, 'footprints' => 1705, 'categories' => 1705,
|
||||||
'suppliers' => '1705', 'manufacturers' => '1705', 'attachment_types' => '681', 'tools' => '1366',
|
'suppliers' => 1705, 'manufacturers' => 1705, 'attachment_types' => 681, 'tools' => 1366,
|
||||||
'labels' => '165', 'parts_category' => '9', 'parts_minamount' => '9', 'parts_lots' => '169', 'parts_tags' => '9',
|
'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',
|
'parts_unit' => 9, 'parts_mass' => 9, 'parts_status' => 9, 'parts_mpn' => 9, 'currencies' => 9897,
|
||||||
'measurement_units' => '9897',
|
'measurement_units' => 9897,
|
||||||
]);
|
]);
|
||||||
$this->setReference(self::READONLY, $readonly);
|
$this->setReference(self::READONLY, $readonly);
|
||||||
$manager->persist($readonly);
|
$manager->persist($readonly);
|
||||||
|
@ -69,15 +72,15 @@ class GroupFixtures extends Fixture
|
||||||
$users = new Group();
|
$users = new Group();
|
||||||
$users->setName('users');
|
$users->setName('users');
|
||||||
$users->getPermissions()->setRawPermissionValues([
|
$users->getPermissions()->setRawPermissionValues([
|
||||||
'system' => '42', 'groups' => '2730', 'users' => '43690', 'self' => '89', 'config' => '105',
|
'system' => 42, 'groups' => 2730, 'users' => 43690, 'self' => 89, 'config' => 105,
|
||||||
'database' => '41', 'parts' => '1431655765', 'parts_name' => '5', 'parts_description' => '5',
|
'database' => 41, 'parts' => 1431655765, 'parts_name' => 5, 'parts_description' => 5,
|
||||||
'parts_footprint' => '5', 'parts_manufacturer' => '5', 'parts_comment' => '5', 'parts_order' => '5',
|
'parts_footprint' => 5, 'parts_manufacturer' => 5, 'parts_comment' => 5, 'parts_order' => 5,
|
||||||
'parts_orderdetails' => '341', 'parts_prices' => '341', 'parts_attachments' => '341', 'devices' => '5461',
|
'parts_orderdetails' => 341, 'parts_prices' => 341, 'parts_attachments' => 341, 'devices' => 5461,
|
||||||
'devices_parts' => '325', 'storelocations' => '5461', 'footprints' => '5461', 'categories' => '5461',
|
'devices_parts' => 325, 'storelocations' => 5461, 'footprints' => 5461, 'categories' => 5461,
|
||||||
'suppliers' => '5461', 'manufacturers' => '5461', 'attachment_types' => '1365', 'tools' => '1365',
|
'suppliers' => 5461, 'manufacturers' => 5461, 'attachment_types' => 1365, 'tools' => 1365,
|
||||||
'labels' => '85', 'parts_category' => '5', 'parts_minamount' => '5', 'parts_lots' => '85', 'parts_tags' => '5',
|
'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',
|
'parts_unit' => 5, 'parts_mass' => 5, 'parts_status' => 5, 'parts_mpn' => 5, 'currencies' => 5461,
|
||||||
'measurement_units' => '5461',
|
'measurement_units' => 5461,
|
||||||
]);
|
]);
|
||||||
$this->setReference(self::USERS, $users);
|
$this->setReference(self::USERS, $users);
|
||||||
$manager->persist($users);
|
$manager->persist($users);
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
* 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;
|
$this->encoder = $encoder;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function load(ObjectManager $manager)
|
public function load(ObjectManager $manager): void
|
||||||
{
|
{
|
||||||
//Reset autoincrement
|
//Reset autoincrement
|
||||||
$this->em->getConnection()->exec('ALTER TABLE `users` AUTO_INCREMENT = 1;');
|
$this->em->getConnection()->exec('ALTER TABLE `users` AUTO_INCREMENT = 1;');
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
* 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;
|
protected $hydrationMode;
|
||||||
|
|
||||||
public function configure(array $options)
|
public function configure(array $options): void
|
||||||
{
|
{
|
||||||
parent::configure($options);
|
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);
|
parent::prepareQuery($query);
|
||||||
$query->setIdentifierPropertyPath(null);
|
$query->setIdentifierPropertyPath(null);
|
||||||
|
@ -57,7 +60,7 @@ class CustomORMAdapter extends ORMAdapter
|
||||||
$builder = $query->get('qb');
|
$builder = $query->get('qb');
|
||||||
$state = $query->getState();
|
$state = $query->getState();
|
||||||
// Apply definitive view state for current 'page' of the table
|
// 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 */
|
/** @var AbstractColumn $column */
|
||||||
if ($column->isOrderable()) {
|
if ($column->isOrderable()) {
|
||||||
$builder->addOrderBy($column->getOrderField(), $direction);
|
$builder->addOrderBy($column->getOrderField(), $direction);
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||||
*
|
*
|
||||||
|
@ -54,17 +57,7 @@ class AttachmentDataTable implements DataTableTypeInterface
|
||||||
$this->attachmentURLGenerator = $attachmentURLGenerator;
|
$this->attachmentURLGenerator = $attachmentURLGenerator;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function getQuery(QueryBuilder $builder)
|
public function configure(DataTable $dataTable, array $options): void
|
||||||
{
|
|
||||||
$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)
|
|
||||||
{
|
{
|
||||||
$dataTable->add('picture', TextColumn::class, [
|
$dataTable->add('picture', TextColumn::class, [
|
||||||
'label' => '',
|
'label' => '',
|
||||||
|
@ -204,9 +197,19 @@ class AttachmentDataTable implements DataTableTypeInterface
|
||||||
|
|
||||||
$dataTable->createAdapter(ORMAdapter::class, [
|
$dataTable->createAdapter(ORMAdapter::class, [
|
||||||
'entity' => Attachment::class,
|
'entity' => Attachment::class,
|
||||||
'query' => function (QueryBuilder $builder) {
|
'query' => function (QueryBuilder $builder): void {
|
||||||
$this->getQuery($builder);
|
$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');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
* 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)
|
public function normalize($value)
|
||||||
{
|
{
|
||||||
/* @var NamedDBElement $value */
|
/** @var NamedDBElement $value */
|
||||||
return $value;
|
return $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function configureOptions(OptionsResolver $resolver)
|
public function configureOptions(OptionsResolver $resolver): void
|
||||||
{
|
{
|
||||||
parent::configureOptions($resolver);
|
parent::configureOptions($resolver);
|
||||||
|
|
||||||
|
@ -76,9 +79,9 @@ class EntityColumn extends AbstractColumn
|
||||||
$this->urlGenerator->listPartsURL($entity),
|
$this->urlGenerator->listPartsURL($entity),
|
||||||
$value
|
$value
|
||||||
);
|
);
|
||||||
} else {
|
|
||||||
return sprintf('<i>%s</i>', $value);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return sprintf('<i>%s</i>', $value);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||||
*
|
*
|
||||||
|
@ -31,9 +34,6 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||||
*/
|
*/
|
||||||
class LocaleDateTimeColumn extends AbstractColumn
|
class LocaleDateTimeColumn extends AbstractColumn
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
public function normalize($value)
|
public function normalize($value)
|
||||||
{
|
{
|
||||||
if (null === $value) {
|
if (null === $value) {
|
||||||
|
@ -60,9 +60,6 @@ class LocaleDateTimeColumn extends AbstractColumn
|
||||||
return $formatter->format($value->getTimestamp());
|
return $formatter->format($value->getTimestamp());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
protected function configureOptions(OptionsResolver $resolver)
|
protected function configureOptions(OptionsResolver $resolver)
|
||||||
{
|
{
|
||||||
parent::configureOptions($resolver);
|
parent::configureOptions($resolver);
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||||
*
|
*
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||||
*
|
*
|
||||||
|
@ -70,7 +73,7 @@ class PartAttachmentsColumn extends AbstractColumn
|
||||||
if (--$count < 0) {
|
if (--$count < 0) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/* @var Attachment $attachment */
|
/** @var Attachment $attachment */
|
||||||
$tmp .= sprintf(
|
$tmp .= sprintf(
|
||||||
'<a href="%s" title="%s" class="attach-table-icon" target="_blank" rel="noopener" data-no-ajax>%s</a>',
|
'<a href="%s" title="%s" class="attach-table-icon" target="_blank" rel="noopener" data-no-ajax>%s</a>',
|
||||||
$this->urlGenerator->viewURL($attachment),
|
$this->urlGenerator->viewURL($attachment),
|
||||||
|
@ -87,7 +90,7 @@ class PartAttachmentsColumn extends AbstractColumn
|
||||||
return $tmp;
|
return $tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function configureOptions(OptionsResolver $resolver)
|
public function configureOptions(OptionsResolver $resolver): void
|
||||||
{
|
{
|
||||||
parent::configureOptions($resolver);
|
parent::configureOptions($resolver);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||||
*
|
*
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
* 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;
|
$this->attachmentURLGenerator = $attachmentURLGenerator;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function getQuery(QueryBuilder $builder)
|
public function configure(DataTable $dataTable, array $options): 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)
|
|
||||||
{
|
|
||||||
$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)
|
|
||||||
{
|
{
|
||||||
$dataTable
|
$dataTable
|
||||||
->add('picture', TextColumn::class, [
|
->add('picture', TextColumn::class, [
|
||||||
|
@ -293,16 +216,96 @@ class PartsDataTable implements DataTableTypeInterface
|
||||||
|
|
||||||
->addOrderBy('name')
|
->addOrderBy('name')
|
||||||
->createAdapter(CustomORMAdapter::class, [
|
->createAdapter(CustomORMAdapter::class, [
|
||||||
'query' => function (QueryBuilder $builder) {
|
'query' => function (QueryBuilder $builder): void {
|
||||||
$this->getQuery($builder);
|
$this->getQuery($builder);
|
||||||
},
|
},
|
||||||
'entity' => Part::class,
|
'entity' => Part::class,
|
||||||
'criteria' => [
|
'criteria' => [
|
||||||
function (QueryBuilder $builder) use ($options) {
|
function (QueryBuilder $builder) use ($options): void {
|
||||||
$this->buildCriteria($builder, $options);
|
$this->buildCriteria($builder, $options);
|
||||||
},
|
},
|
||||||
new SearchCriteriaProvider(),
|
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'].'%');
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,6 +68,11 @@ abstract class Attachment extends NamedDBElement
|
||||||
/** @var array Placeholders for attachments which using built in files. */
|
/** @var array Placeholders for attachments which using built in files. */
|
||||||
public const BUILTIN_PLACEHOLDER = ['%FOOTPRINTS%', '%FOOTPRINTS3D%'];
|
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
|
* @var bool
|
||||||
* @ORM\Column(type="boolean")
|
* @ORM\Column(type="boolean")
|
||||||
|
@ -99,11 +104,6 @@ abstract class Attachment extends NamedDBElement
|
||||||
*/
|
*/
|
||||||
protected $attachment_type;
|
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()
|
public function __construct()
|
||||||
{
|
{
|
||||||
//parent::__construct();
|
//parent::__construct();
|
||||||
|
@ -363,7 +363,7 @@ abstract class Attachment extends NamedDBElement
|
||||||
public function setElement(AttachmentContainingDBElement $element): self
|
public function setElement(AttachmentContainingDBElement $element): self
|
||||||
{
|
{
|
||||||
if (! is_a($element, 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!', \get_class($this), 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;
|
$this->element = $element;
|
||||||
|
@ -443,9 +443,9 @@ abstract class Attachment extends NamedDBElement
|
||||||
/**
|
/**
|
||||||
* Check if a string is a URL and is valid.
|
* 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 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.*
|
* *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.
|
* @return bool True if the string is a valid URL. False, if the string is not an URL or invalid.
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
* 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
|
class AttachmentTypeAttachment extends Attachment
|
||||||
{
|
{
|
||||||
|
public const ALLOWED_ELEMENT_CLASS = AttachmentType::class;
|
||||||
/**
|
/**
|
||||||
* @var AttachmentType the element this attachment is associated with
|
* @var AttachmentType the element this attachment is associated with
|
||||||
* @ORM\ManyToOne(targetEntity="App\Entity\Attachments\AttachmentType", inversedBy="attachments")
|
* @ORM\ManyToOne(targetEntity="App\Entity\Attachments\AttachmentType", inversedBy="attachments")
|
||||||
* @ORM\JoinColumn(name="element_id", referencedColumnName="id", nullable=false, onDelete="CASCADE").
|
* @ORM\JoinColumn(name="element_id", referencedColumnName="id", nullable=false, onDelete="CASCADE").
|
||||||
*/
|
*/
|
||||||
protected $element;
|
protected $element;
|
||||||
|
|
||||||
public const ALLOWED_ELEMENT_CLASS = AttachmentType::class;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
* 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
|
class CategoryAttachment extends Attachment
|
||||||
{
|
{
|
||||||
|
public const ALLOWED_ELEMENT_CLASS = Category::class;
|
||||||
/**
|
/**
|
||||||
* @var Category the element this attachment is associated with
|
* @var Category the element this attachment is associated with
|
||||||
* @ORM\ManyToOne(targetEntity="App\Entity\Parts\Category", inversedBy="attachments")
|
* @ORM\ManyToOne(targetEntity="App\Entity\Parts\Category", inversedBy="attachments")
|
||||||
* @ORM\JoinColumn(name="element_id", referencedColumnName="id", nullable=false, onDelete="CASCADE").
|
* @ORM\JoinColumn(name="element_id", referencedColumnName="id", nullable=false, onDelete="CASCADE").
|
||||||
*/
|
*/
|
||||||
protected $element;
|
protected $element;
|
||||||
|
|
||||||
public const ALLOWED_ELEMENT_CLASS = Category::class;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
* 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
|
class CurrencyAttachment extends Attachment
|
||||||
{
|
{
|
||||||
|
public const ALLOWED_ELEMENT_CLASS = Currency::class;
|
||||||
/**
|
/**
|
||||||
* @var Currency the element this attachment is associated with
|
* @var Currency the element this attachment is associated with
|
||||||
* @ORM\ManyToOne(targetEntity="App\Entity\PriceInformations\Currency", inversedBy="attachments")
|
* @ORM\ManyToOne(targetEntity="App\Entity\PriceInformations\Currency", inversedBy="attachments")
|
||||||
* @ORM\JoinColumn(name="element_id", referencedColumnName="id", nullable=false, onDelete="CASCADE").
|
* @ORM\JoinColumn(name="element_id", referencedColumnName="id", nullable=false, onDelete="CASCADE").
|
||||||
*/
|
*/
|
||||||
protected $element;
|
protected $element;
|
||||||
|
|
||||||
public const ALLOWED_ELEMENT_CLASS = Currency::class;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
* 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
|
class DeviceAttachment extends Attachment
|
||||||
{
|
{
|
||||||
|
public const ALLOWED_ELEMENT_CLASS = Device::class;
|
||||||
/**
|
/**
|
||||||
* @var Device the element this attachment is associated with
|
* @var Device the element this attachment is associated with
|
||||||
* @ORM\ManyToOne(targetEntity="App\Entity\Devices\Device", inversedBy="attachments")
|
* @ORM\ManyToOne(targetEntity="App\Entity\Devices\Device", inversedBy="attachments")
|
||||||
* @ORM\JoinColumn(name="element_id", referencedColumnName="id", nullable=false, onDelete="CASCADE").
|
* @ORM\JoinColumn(name="element_id", referencedColumnName="id", nullable=false, onDelete="CASCADE").
|
||||||
*/
|
*/
|
||||||
protected $element;
|
protected $element;
|
||||||
|
|
||||||
public const ALLOWED_ELEMENT_CLASS = Device::class;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
* 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
|
class FootprintAttachment extends Attachment
|
||||||
{
|
{
|
||||||
|
public const ALLOWED_ELEMENT_CLASS = Footprint::class;
|
||||||
/**
|
/**
|
||||||
* @var Footprint the element this attachment is associated with
|
* @var Footprint the element this attachment is associated with
|
||||||
* @ORM\ManyToOne(targetEntity="App\Entity\Parts\Footprint", inversedBy="attachments")
|
* @ORM\ManyToOne(targetEntity="App\Entity\Parts\Footprint", inversedBy="attachments")
|
||||||
* @ORM\JoinColumn(name="element_id", referencedColumnName="id", nullable=false, onDelete="CASCADE").
|
* @ORM\JoinColumn(name="element_id", referencedColumnName="id", nullable=false, onDelete="CASCADE").
|
||||||
*/
|
*/
|
||||||
protected $element;
|
protected $element;
|
||||||
|
|
||||||
public const ALLOWED_ELEMENT_CLASS = Footprint::class;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
* 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
|
class GroupAttachment extends Attachment
|
||||||
{
|
{
|
||||||
|
public const ALLOWED_ELEMENT_CLASS = Group::class;
|
||||||
/**
|
/**
|
||||||
* @var Group the element this attachment is associated with
|
* @var Group the element this attachment is associated with
|
||||||
* @ORM\ManyToOne(targetEntity="App\Entity\UserSystem\Group", inversedBy="attachments")
|
* @ORM\ManyToOne(targetEntity="App\Entity\UserSystem\Group", inversedBy="attachments")
|
||||||
* @ORM\JoinColumn(name="element_id", referencedColumnName="id", nullable=false, onDelete="CASCADE").
|
* @ORM\JoinColumn(name="element_id", referencedColumnName="id", nullable=false, onDelete="CASCADE").
|
||||||
*/
|
*/
|
||||||
protected $element;
|
protected $element;
|
||||||
|
|
||||||
public const ALLOWED_ELEMENT_CLASS = Group::class;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
* 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
|
class ManufacturerAttachment extends Attachment
|
||||||
{
|
{
|
||||||
|
public const ALLOWED_ELEMENT_CLASS = Manufacturer::class;
|
||||||
/**
|
/**
|
||||||
* @var Manufacturer the element this attachment is associated with
|
* @var Manufacturer the element this attachment is associated with
|
||||||
* @ORM\ManyToOne(targetEntity="App\Entity\Parts\Manufacturer", inversedBy="attachments")
|
* @ORM\ManyToOne(targetEntity="App\Entity\Parts\Manufacturer", inversedBy="attachments")
|
||||||
* @ORM\JoinColumn(name="element_id", referencedColumnName="id", nullable=false, onDelete="CASCADE").
|
* @ORM\JoinColumn(name="element_id", referencedColumnName="id", nullable=false, onDelete="CASCADE").
|
||||||
*/
|
*/
|
||||||
protected $element;
|
protected $element;
|
||||||
|
|
||||||
public const ALLOWED_ELEMENT_CLASS = Manufacturer::class;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
* 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
|
class MeasurementUnitAttachment extends Attachment
|
||||||
{
|
{
|
||||||
|
public const ALLOWED_ELEMENT_CLASS = MeasurementUnit::class;
|
||||||
/**
|
/**
|
||||||
* @var Manufacturer the element this attachment is associated with
|
* @var Manufacturer the element this attachment is associated with
|
||||||
* @ORM\ManyToOne(targetEntity="App\Entity\Parts\MeasurementUnit", inversedBy="attachments")
|
* @ORM\ManyToOne(targetEntity="App\Entity\Parts\MeasurementUnit", inversedBy="attachments")
|
||||||
* @ORM\JoinColumn(name="element_id", referencedColumnName="id", nullable=false, onDelete="CASCADE").
|
* @ORM\JoinColumn(name="element_id", referencedColumnName="id", nullable=false, onDelete="CASCADE").
|
||||||
*/
|
*/
|
||||||
protected $element;
|
protected $element;
|
||||||
|
|
||||||
public const ALLOWED_ELEMENT_CLASS = MeasurementUnit::class;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
* 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
|
class PartAttachment extends Attachment
|
||||||
{
|
{
|
||||||
|
public const ALLOWED_ELEMENT_CLASS = Part::class;
|
||||||
/**
|
/**
|
||||||
* @var Part the element this attachment is associated with
|
* @var Part the element this attachment is associated with
|
||||||
* @ORM\ManyToOne(targetEntity="App\Entity\Parts\Part", inversedBy="attachments")
|
* @ORM\ManyToOne(targetEntity="App\Entity\Parts\Part", inversedBy="attachments")
|
||||||
* @ORM\JoinColumn(name="element_id", referencedColumnName="id", nullable=false, onDelete="CASCADE").
|
* @ORM\JoinColumn(name="element_id", referencedColumnName="id", nullable=false, onDelete="CASCADE").
|
||||||
*/
|
*/
|
||||||
protected $element;
|
protected $element;
|
||||||
|
|
||||||
public const ALLOWED_ELEMENT_CLASS = Part::class;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
* 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
|
class StorelocationAttachment extends Attachment
|
||||||
{
|
{
|
||||||
|
public const ALLOWED_ELEMENT_CLASS = Storelocation::class;
|
||||||
/**
|
/**
|
||||||
* @var Storelocation the element this attachment is associated with
|
* @var Storelocation the element this attachment is associated with
|
||||||
* @ORM\ManyToOne(targetEntity="App\Entity\Parts\Storelocation", inversedBy="attachments")
|
* @ORM\ManyToOne(targetEntity="App\Entity\Parts\Storelocation", inversedBy="attachments")
|
||||||
* @ORM\JoinColumn(name="element_id", referencedColumnName="id", nullable=false, onDelete="CASCADE").
|
* @ORM\JoinColumn(name="element_id", referencedColumnName="id", nullable=false, onDelete="CASCADE").
|
||||||
*/
|
*/
|
||||||
protected $element;
|
protected $element;
|
||||||
|
|
||||||
public const ALLOWED_ELEMENT_CLASS = Storelocation::class;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
* 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
|
class SupplierAttachment extends Attachment
|
||||||
{
|
{
|
||||||
|
public const ALLOWED_ELEMENT_CLASS = Supplier::class;
|
||||||
/**
|
/**
|
||||||
* @var Supplier the element this attachment is associated with
|
* @var Supplier the element this attachment is associated with
|
||||||
* @ORM\ManyToOne(targetEntity="App\Entity\Parts\Supplier", inversedBy="attachments")
|
* @ORM\ManyToOne(targetEntity="App\Entity\Parts\Supplier", inversedBy="attachments")
|
||||||
* @ORM\JoinColumn(name="element_id", referencedColumnName="id", nullable=false, onDelete="CASCADE").
|
* @ORM\JoinColumn(name="element_id", referencedColumnName="id", nullable=false, onDelete="CASCADE").
|
||||||
*/
|
*/
|
||||||
protected $element;
|
protected $element;
|
||||||
|
|
||||||
public const ALLOWED_ELEMENT_CLASS = Supplier::class;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
* 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
|
class UserAttachment extends Attachment
|
||||||
{
|
{
|
||||||
|
public const ALLOWED_ELEMENT_CLASS = User::class;
|
||||||
/**
|
/**
|
||||||
* @var User the element this attachment is associated with
|
* @var User the element this attachment is associated with
|
||||||
* @ORM\ManyToOne(targetEntity="App\Entity\UserSystem\User", inversedBy="attachments")
|
* @ORM\ManyToOne(targetEntity="App\Entity\UserSystem\User", inversedBy="attachments")
|
||||||
* @ORM\JoinColumn(name="element_id", referencedColumnName="id", nullable=false, onDelete="CASCADE").
|
* @ORM\JoinColumn(name="element_id", referencedColumnName="id", nullable=false, onDelete="CASCADE").
|
||||||
*/
|
*/
|
||||||
protected $element;
|
protected $element;
|
||||||
|
|
||||||
public const ALLOWED_ELEMENT_CLASS = User::class;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Part-DB Version 0.4+ "nextgen"
|
* Part-DB Version 0.4+ "nextgen"
|
||||||
* Copyright (C) 2016 - 2019 Jan Böhmer
|
* Copyright (C) 2016 - 2019 Jan Böhmer
|
||||||
|
|
|
@ -66,6 +66,12 @@ abstract class DBElement
|
||||||
*/
|
*/
|
||||||
protected $id;
|
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
|
* Get the ID. The ID can be zero, or even negative (for virtual elements). If an element is virtual, can be
|
||||||
* checked with isVirtualElement().
|
* checked with isVirtualElement().
|
||||||
|
@ -86,10 +92,4 @@ abstract class DBElement
|
||||||
* @return string The ID as a string;
|
* @return string The ID as a string;
|
||||||
*/
|
*/
|
||||||
abstract public function getIDString(): string;
|
abstract public function getIDString(): string;
|
||||||
|
|
||||||
public function __clone()
|
|
||||||
{
|
|
||||||
//Set ID to null, so that an new entry is created
|
|
||||||
$this->id = null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||||
*
|
*
|
||||||
|
|
|
@ -45,6 +45,17 @@ abstract class NamedDBElement extends DBElement
|
||||||
*/
|
*/
|
||||||
protected $name = '';
|
protected $name = '';
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
*
|
||||||
|
* Helpers
|
||||||
|
*
|
||||||
|
******************************************************************************/
|
||||||
|
|
||||||
|
public function __toString()
|
||||||
|
{
|
||||||
|
return $this->getName();
|
||||||
|
}
|
||||||
|
|
||||||
/********************************************************************************
|
/********************************************************************************
|
||||||
*
|
*
|
||||||
* Getters
|
* Getters
|
||||||
|
@ -80,15 +91,4 @@ abstract class NamedDBElement extends DBElement
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/******************************************************************************
|
|
||||||
*
|
|
||||||
* Helpers
|
|
||||||
*
|
|
||||||
******************************************************************************/
|
|
||||||
|
|
||||||
public function __toString()
|
|
||||||
{
|
|
||||||
return $this->getName();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -113,7 +113,7 @@ abstract class StructuralDBElement extends AttachmentContainingDBElement
|
||||||
*/
|
*/
|
||||||
public function isChildOf(self $another_element): bool
|
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
|
//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):
|
// (we have to check inheritance, or we get exceptions when using doctrine entities (they have a proxy type):
|
||||||
|
@ -243,8 +243,6 @@ abstract class StructuralDBElement extends AttachmentContainingDBElement
|
||||||
/**
|
/**
|
||||||
* Get all sub elements of this element.
|
* 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)
|
* @return Collection<static> all subelements as an array of objects (sorted by their full path)
|
||||||
*/
|
*/
|
||||||
public function getSubelements(): iterable
|
public function getSubelements(): iterable
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||||
*
|
*
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||||
*
|
*
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||||
*
|
*
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||||
*
|
*
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
* 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.
|
* 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.
|
* Set this to true, when the part should be a favorite.
|
||||||
*/
|
*/
|
||||||
public function setFavorite(bool $new_favorite_status): self
|
public function setFavorite(bool $new_favorite_status): self
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||||
*
|
*
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||||
*
|
*
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||||
*
|
*
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
* 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 null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return bcdiv(1, $tmp, static::PRICE_SCALE);
|
return bcdiv('1', $tmp, static::PRICE_SCALE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -181,7 +181,7 @@ class Orderdetail extends DBElement
|
||||||
/**
|
/**
|
||||||
* Get the link to the website of the article on the suppliers website.
|
* 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
|
* and not a automatic generated one, based from the Supplier
|
||||||
*
|
*
|
||||||
* @return string the link to the article
|
* @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.
|
* Sets the custom product supplier URL for this order detail.
|
||||||
* Set this to "", if the function getSupplierProductURL should return the automatic generated URL.
|
* Set this to "", if the function getSupplierProductURL should return the automatic generated URL.
|
||||||
*
|
*
|
||||||
* @param $new_url string The new URL for the supplier URL
|
* @param string $new_url The new URL for the supplier URL
|
||||||
*
|
*
|
||||||
* @return Orderdetail
|
* @return Orderdetail
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -68,10 +68,10 @@ use Symfony\Component\Validator\Constraints as Assert;
|
||||||
*/
|
*/
|
||||||
class Pricedetail extends DBElement
|
class Pricedetail extends DBElement
|
||||||
{
|
{
|
||||||
public const PRICE_PRECISION = 5;
|
|
||||||
|
|
||||||
use TimestampTrait;
|
use TimestampTrait;
|
||||||
|
|
||||||
|
public const PRICE_PRECISION = 5;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var Orderdetail
|
* @var Orderdetail
|
||||||
* @ORM\ManyToOne(targetEntity="Orderdetail", inversedBy="pricedetails")
|
* @ORM\ManyToOne(targetEntity="Orderdetail", inversedBy="pricedetails")
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||||
*
|
*
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
* 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
|
public function isValidPermissionName(string $permission_name): bool
|
||||||
{
|
{
|
||||||
return isset($this->$permission_name);
|
return isset($this->{$permission_name});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -316,7 +319,7 @@ class PermissionsEmbed
|
||||||
throw new \InvalidArgumentException(sprintf('No permission with the name "%s" is existing!', $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);
|
return static::readBitPair($perm_int, $bit_n);
|
||||||
}
|
}
|
||||||
|
@ -386,7 +389,7 @@ class PermissionsEmbed
|
||||||
throw new \InvalidArgumentException('No permission with the given name is existing!');
|
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;
|
return $this;
|
||||||
}
|
}
|
||||||
|
@ -405,7 +408,7 @@ class PermissionsEmbed
|
||||||
throw new \InvalidArgumentException('No permission with the given name is existing!');
|
throw new \InvalidArgumentException('No permission with the given name is existing!');
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->$permission_name;
|
return $this->{$permission_name};
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -422,7 +425,7 @@ class PermissionsEmbed
|
||||||
throw new \InvalidArgumentException(sprintf('No permission with the given name %s is existing!', $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;
|
return $this;
|
||||||
}
|
}
|
||||||
|
@ -436,7 +439,7 @@ class PermissionsEmbed
|
||||||
*
|
*
|
||||||
* @return $this
|
* @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);
|
$values = array_combine($values, $values2);
|
||||||
|
@ -452,12 +455,12 @@ class PermissionsEmbed
|
||||||
/**
|
/**
|
||||||
* Reads a bit pair from $data.
|
* Reads a bit pair from $data.
|
||||||
*
|
*
|
||||||
* @param $data int The data from where the bits should be extracted from
|
* @param int|string $data 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 $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
|
* @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.');
|
Assert::lessThanEq($n, 31, '$n must be smaller than 32, because only a 32bit int is used! Got %s.');
|
||||||
if (0 !== $n % 2) {
|
if (0 !== $n % 2) {
|
||||||
|
@ -471,9 +474,9 @@ class PermissionsEmbed
|
||||||
/**
|
/**
|
||||||
* Writes a bit pair in the given $data and returns it.
|
* Writes a bit pair in the given $data and returns it.
|
||||||
*
|
*
|
||||||
* @param $data int The data which should be modified
|
* @param int $data The data which should be modified
|
||||||
* @param $n int The number of the lower bit of the pair which should be written
|
* @param int $n The number of the lower bit of the pair which should be written
|
||||||
* @param $new int The new value of the pair
|
* @param int $new The new value of the pair
|
||||||
*
|
*
|
||||||
* @return int the new data with the modified pair
|
* @return int the new data with the modified pair
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
* 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;
|
use TimestampTrait;
|
||||||
|
|
||||||
/**
|
|
||||||
* @ORM\Id
|
|
||||||
* @ORM\Column(type="integer")
|
|
||||||
* @ORM\GeneratedValue(strategy="AUTO")
|
|
||||||
*/
|
|
||||||
protected $id;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ORM\Column(type="string", length=64)
|
* @ORM\Column(type="string", length=64)
|
||||||
*
|
*
|
||||||
|
@ -73,6 +69,13 @@ class U2FKey implements TwoFactorKeyInterface
|
||||||
**/
|
**/
|
||||||
public $counter;
|
public $counter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ORM\Id
|
||||||
|
* @ORM\Column(type="integer")
|
||||||
|
* @ORM\GeneratedValue(strategy="AUTO")
|
||||||
|
*/
|
||||||
|
protected $id;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ORM\ManyToOne(targetEntity="App\Entity\UserSystem\User", inversedBy="u2fKeys")
|
* @ORM\ManyToOne(targetEntity="App\Entity\UserSystem\User", inversedBy="u2fKeys")
|
||||||
*
|
*
|
||||||
|
@ -95,62 +98,52 @@ class U2FKey implements TwoFactorKeyInterface
|
||||||
$this->counter = $data->counter;
|
$this->counter = $data->counter;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** {@inheritdoc} */
|
|
||||||
public function getKeyHandle()
|
public function getKeyHandle()
|
||||||
{
|
{
|
||||||
return $this->keyHandle;
|
return $this->keyHandle;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** {@inheritdoc} */
|
public function setKeyHandle($keyHandle): void
|
||||||
public function setKeyHandle($keyHandle)
|
|
||||||
{
|
{
|
||||||
$this->keyHandle = $keyHandle;
|
$this->keyHandle = $keyHandle;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** {@inheritdoc} */
|
|
||||||
public function getPublicKey()
|
public function getPublicKey()
|
||||||
{
|
{
|
||||||
return $this->publicKey;
|
return $this->publicKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** {@inheritdoc} */
|
public function setPublicKey($publicKey): void
|
||||||
public function setPublicKey($publicKey)
|
|
||||||
{
|
{
|
||||||
$this->publicKey = $publicKey;
|
$this->publicKey = $publicKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** {@inheritdoc} */
|
|
||||||
public function getCertificate()
|
public function getCertificate()
|
||||||
{
|
{
|
||||||
return $this->certificate;
|
return $this->certificate;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** {@inheritdoc} */
|
public function setCertificate($certificate): void
|
||||||
public function setCertificate($certificate)
|
|
||||||
{
|
{
|
||||||
$this->certificate = $certificate;
|
$this->certificate = $certificate;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** {@inheritdoc} */
|
|
||||||
public function getCounter()
|
public function getCounter()
|
||||||
{
|
{
|
||||||
return $this->counter;
|
return $this->counter;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** {@inheritdoc} */
|
public function setCounter($counter): void
|
||||||
public function setCounter($counter)
|
|
||||||
{
|
{
|
||||||
$this->counter = $counter;
|
$this->counter = $counter;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** {@inheritdoc} */
|
|
||||||
public function getName()
|
public function getName()
|
||||||
{
|
{
|
||||||
return $this->name;
|
return $this->name;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** {@inheritdoc} */
|
public function setName($name): void
|
||||||
public function setName($name)
|
|
||||||
{
|
{
|
||||||
$this->name = $name;
|
$this->name = $name;
|
||||||
}
|
}
|
||||||
|
|
|
@ -266,6 +266,19 @@ class User extends AttachmentContainingDBElement implements UserInterface, HasPe
|
||||||
$this->u2fKeys = new ArrayCollection();
|
$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.
|
* 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
|
* @see UserInterface
|
||||||
*/
|
*/
|
||||||
public function getSalt()
|
public function getSalt(): void
|
||||||
{
|
{
|
||||||
// not needed when using the "bcrypt" algorithm in security.yaml
|
// not needed when using the "bcrypt" algorithm in security.yaml
|
||||||
}
|
}
|
||||||
|
@ -338,7 +351,7 @@ class User extends AttachmentContainingDBElement implements UserInterface, HasPe
|
||||||
/**
|
/**
|
||||||
* @see UserInterface
|
* @see UserInterface
|
||||||
*/
|
*/
|
||||||
public function eraseCredentials()
|
public function eraseCredentials(): void
|
||||||
{
|
{
|
||||||
// If you store any temporary, sensitive data on the user, clear it here
|
// If you store any temporary, sensitive data on the user, clear it here
|
||||||
// $this->plainPassword = null;
|
// $this->plainPassword = null;
|
||||||
|
@ -646,8 +659,6 @@ class User extends AttachmentContainingDBElement implements UserInterface, HasPe
|
||||||
/**
|
/**
|
||||||
* Change the timezone of this user.
|
* 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
|
* @return $this
|
||||||
*/
|
*/
|
||||||
public function setTimezone(?string $timezone): self
|
public function setTimezone(?string $timezone): self
|
||||||
|
@ -706,19 +717,6 @@ class User extends AttachmentContainingDBElement implements UserInterface, HasPe
|
||||||
return $this;
|
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.
|
* 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
|
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
|
public function invalidateBackupCode(string $code): void
|
||||||
{
|
{
|
||||||
$key = array_search($code, $this->backupCodes);
|
$key = array_search($code, $this->backupCodes, true);
|
||||||
if (false !== $key) {
|
if (false !== $key) {
|
||||||
unset($this->backupCodes[$key]);
|
unset($this->backupCodes[$key]);
|
||||||
}
|
}
|
||||||
|
@ -883,9 +881,6 @@ class User extends AttachmentContainingDBElement implements UserInterface, HasPe
|
||||||
$this->u2fKeys->removeElement($key);
|
$this->u2fKeys->removeElement($key);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
public function getPreferredTwoFactorProvider(): ?string
|
public function getPreferredTwoFactorProvider(): ?string
|
||||||
{
|
{
|
||||||
//If U2F is available then prefer it
|
//If U2F is available then prefer it
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||||
*
|
*
|
||||||
|
@ -52,7 +55,7 @@ class AttachmentDeleteListener
|
||||||
*
|
*
|
||||||
* @PreUpdate
|
* @PreUpdate
|
||||||
*/
|
*/
|
||||||
public function preUpdateHandler(Attachment $attachment, PreUpdateEventArgs $event)
|
public function preUpdateHandler(Attachment $attachment, PreUpdateEventArgs $event): void
|
||||||
{
|
{
|
||||||
if ($event->hasChangedField('path')) {
|
if ($event->hasChangedField('path')) {
|
||||||
//Dont delete file if the attachment uses a builtin ressource:
|
//Dont delete file if the attachment uses a builtin ressource:
|
||||||
|
@ -70,7 +73,7 @@ class AttachmentDeleteListener
|
||||||
*
|
*
|
||||||
* @PostRemove
|
* @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:
|
//Dont delete file if the attachment uses a builtin ressource:
|
||||||
if ($attachment->isBuiltIn()) {
|
if ($attachment->isBuiltIn()) {
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||||
*
|
*
|
||||||
|
@ -46,7 +49,7 @@ class TreeCacheInvalidationListener
|
||||||
* @ORM\PostPersist()
|
* @ORM\PostPersist()
|
||||||
* @ORM\PostRemove()
|
* @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 an element was changed, then invalidate all cached trees with this element class
|
||||||
if ($element instanceof StructuralDBElement) {
|
if ($element instanceof StructuralDBElement) {
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
* 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;
|
$this->flashBag = $flashBag;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onLogin(InteractiveLoginEvent $event)
|
public function onLogin(InteractiveLoginEvent $event): void
|
||||||
{
|
{
|
||||||
$this->flashBag->add('notice', $this->translator->trans('flash.login_successful'));
|
$this->flashBag->add('notice', $this->translator->trans('flash.login_successful'));
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
* 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;
|
$this->urlGenerator = $urlGenerator;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onRequest(RequestEvent $event)
|
public function onRequest(RequestEvent $event): void
|
||||||
{
|
{
|
||||||
$user = $this->security->getUser();
|
$user = $this->security->getUser();
|
||||||
if ($user instanceof User && $user->isDisabled()) {
|
if ($user instanceof User && $user->isDisabled()) {
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||||
*
|
*
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
* 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
|
class PasswordChangeNeededSubscriber implements EventSubscriberInterface
|
||||||
{
|
{
|
||||||
protected $security;
|
|
||||||
protected $flashBag;
|
|
||||||
protected $httpUtils;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var string[] The routes the user is allowed to access without being redirected.
|
* @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
|
* 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 */
|
/** @var string The route the user will redirected to, if he needs to change this password */
|
||||||
public const REDIRECT_TARGET = 'user_settings';
|
public const REDIRECT_TARGET = 'user_settings';
|
||||||
|
protected $security;
|
||||||
|
protected $flashBag;
|
||||||
|
protected $httpUtils;
|
||||||
|
|
||||||
public function __construct(Security $security, FlashBagInterface $flashBag, HttpUtils $httpUtils)
|
public function __construct(Security $security, FlashBagInterface $flashBag, HttpUtils $httpUtils)
|
||||||
{
|
{
|
||||||
|
@ -130,9 +132,6 @@ class PasswordChangeNeededSubscriber implements EventSubscriberInterface
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
public static function getSubscribedEvents()
|
public static function getSubscribedEvents()
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||||
*
|
*
|
||||||
|
@ -57,7 +60,7 @@ class SymfonyDebugToolbarSubscriber implements EventSubscriberInterface
|
||||||
return ['kernel.response' => 'onKernelResponse'];
|
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;
|
return;
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||||
*
|
*
|
||||||
|
@ -41,7 +44,7 @@ class TimezoneListener implements EventSubscriberInterface
|
||||||
$this->security = $security;
|
$this->security = $security;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setTimeZone(ControllerEvent $event)
|
public function setTimeZone(ControllerEvent $event): void
|
||||||
{
|
{
|
||||||
$timezone = null;
|
$timezone = null;
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
* 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
|
class U2FRegistrationSubscriber implements EventSubscriberInterface
|
||||||
{
|
{
|
||||||
/** @var UrlGeneratorInterface */
|
|
||||||
private $router;
|
|
||||||
|
|
||||||
protected $em;
|
protected $em;
|
||||||
|
|
||||||
protected $demo_mode;
|
protected $demo_mode;
|
||||||
protected $flashBag;
|
protected $flashBag;
|
||||||
|
/** @var UrlGeneratorInterface */
|
||||||
|
private $router;
|
||||||
|
|
||||||
public function __construct(UrlGeneratorInterface $router, EntityManagerInterface $entityManager, FlashBagInterface $flashBag, bool $demo_mode)
|
public function __construct(UrlGeneratorInterface $router, EntityManagerInterface $entityManager, FlashBagInterface $flashBag, bool $demo_mode)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||||
*
|
*
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||||
*
|
*
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
* 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);
|
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();
|
$is_new = null === $entity->getID();
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
* 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;
|
$this->params = $params;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function configureOptions(OptionsResolver $resolver)
|
public function configureOptions(OptionsResolver $resolver): void
|
||||||
{
|
{
|
||||||
parent::configureOptions($resolver); // TODO: Change the autogenerated stub
|
parent::configureOptions($resolver); // TODO: Change the autogenerated stub
|
||||||
$resolver->setRequired('attachment_class');
|
$resolver->setRequired('attachment_class');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
public function buildForm(FormBuilderInterface $builder, array $options): void
|
||||||
{
|
{
|
||||||
/** @var StructuralDBElement $entity */
|
/** @var StructuralDBElement $entity */
|
||||||
$entity = $options['data'];
|
$entity = $options['data'];
|
||||||
|
@ -113,7 +116,7 @@ class BaseEntityAdminForm extends AbstractType
|
||||||
'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
|
//Empty for Base
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
* 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
|
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();
|
$is_new = null === $entity->getID();
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||||
*
|
*
|
||||||
|
@ -30,7 +33,7 @@ use Symfony\Component\Form\FormBuilderInterface;
|
||||||
|
|
||||||
class CompanyForm extends BaseEntityAdminForm
|
class CompanyForm extends BaseEntityAdminForm
|
||||||
{
|
{
|
||||||
protected function additionalFormElements(FormBuilderInterface $builder, array $options, NamedDBElement $entity)
|
protected function additionalFormElements(FormBuilderInterface $builder, array $options, NamedDBElement $entity): void
|
||||||
{
|
{
|
||||||
$is_new = null === $entity->getID();
|
$is_new = null === $entity->getID();
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
* 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
|
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();
|
$is_new = null === $entity->getID();
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||||
*
|
*
|
||||||
|
@ -27,7 +30,7 @@ use Symfony\Component\Form\FormBuilderInterface;
|
||||||
|
|
||||||
class FootprintAdminForm extends BaseEntityAdminForm
|
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, [
|
$builder->add('footprint_3d', MasterPictureAttachmentType::class, [
|
||||||
'required' => false,
|
'required' => false,
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
* 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
|
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();
|
$is_new = null === $entity->getID();
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||||
*
|
*
|
||||||
|
@ -41,7 +44,7 @@ class ImportType extends AbstractType
|
||||||
$this->security = $security;
|
$this->security = $security;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
public function buildForm(FormBuilderInterface $builder, array $options): void
|
||||||
{
|
{
|
||||||
$data = $options['data'];
|
$data = $options['data'];
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||||
*
|
*
|
||||||
|
@ -38,7 +41,7 @@ class MassCreationForm extends AbstractType
|
||||||
$this->security = $security;
|
$this->security = $security;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
public function buildForm(FormBuilderInterface $builder, array $options): void
|
||||||
{
|
{
|
||||||
$data = $options['data'];
|
$data = $options['data'];
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
* 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
|
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();
|
$is_new = null === $entity->getID();
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
* 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
|
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();
|
$is_new = null === $entity->getID();
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
* 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
|
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();
|
$is_new = null === $entity->getID();
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
* 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;
|
$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, [
|
$builder->add('name', TextType::class, [
|
||||||
'label' => 'attachment.edit.name',
|
'label' => 'attachment.edit.name',
|
||||||
|
@ -114,7 +117,7 @@ class AttachmentFormType extends AbstractType
|
||||||
//Check the secure file checkbox, if file is in securefile location
|
//Check the secure file checkbox, if file is in securefile location
|
||||||
$builder->get('secureFile')->addEventListener(
|
$builder->get('secureFile')->addEventListener(
|
||||||
FormEvents::PRE_SET_DATA,
|
FormEvents::PRE_SET_DATA,
|
||||||
function (FormEvent $event) {
|
function (FormEvent $event): void {
|
||||||
$attachment = $event->getForm()->getParent()->getData();
|
$attachment = $event->getForm()->getParent()->getData();
|
||||||
if ($attachment instanceof Attachment) {
|
if ($attachment instanceof Attachment) {
|
||||||
$event->setData($attachment->isSecure());
|
$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([
|
$resolver->setDefaults([
|
||||||
'data_class' => Attachment::class,
|
'data_class' => Attachment::class,
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
* 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;
|
$this->security = $security;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
public function buildForm(FormBuilderInterface $builder, array $options): void
|
||||||
{
|
{
|
||||||
/** @var Orderdetail $orderdetail */
|
/** @var Orderdetail $orderdetail */
|
||||||
$orderdetail = $builder->getData();
|
$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
|
//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 */
|
/** @var Orderdetail $orderdetail */
|
||||||
$orderdetail = $event->getData();
|
$orderdetail = $event->getData();
|
||||||
|
|
||||||
|
@ -101,7 +104,7 @@ class OrderdetailType extends AbstractType
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public function configureOptions(OptionsResolver $resolver)
|
public function configureOptions(OptionsResolver $resolver): void
|
||||||
{
|
{
|
||||||
$resolver->setDefaults([
|
$resolver->setDefaults([
|
||||||
'data_class' => Orderdetail::class,
|
'data_class' => Orderdetail::class,
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
* 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;
|
$this->urlGenerator = $urlGenerator;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
public function buildForm(FormBuilderInterface $builder, array $options): void
|
||||||
{
|
{
|
||||||
/** @var Part $part */
|
/** @var Part $part */
|
||||||
$part = $builder->getData();
|
$part = $builder->getData();
|
||||||
|
@ -232,7 +235,7 @@ class PartBaseType extends AbstractType
|
||||||
->add('reset', ResetType::class, ['label' => 'part.edit.reset']);
|
->add('reset', ResetType::class, ['label' => 'part.edit.reset']);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function configureOptions(OptionsResolver $resolver)
|
public function configureOptions(OptionsResolver $resolver): void
|
||||||
{
|
{
|
||||||
$resolver->setDefaults([
|
$resolver->setDefaults([
|
||||||
'data_class' => Part::class,
|
'data_class' => Part::class,
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
* 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;
|
$this->security = $security;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
public function buildForm(FormBuilderInterface $builder, array $options): void
|
||||||
{
|
{
|
||||||
$builder->add('description', TextType::class, [
|
$builder->add('description', TextType::class, [
|
||||||
'label' => 'part_lot.edit.description',
|
'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([
|
$resolver->setDefaults([
|
||||||
'data_class' => PartLot::class,
|
'data_class' => PartLot::class,
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
* 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
|
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
|
//No labels needed, we define translation in templates
|
||||||
$builder->add('min_discount_quantity', SIUnitType::class, [
|
$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([
|
$resolver->setDefaults([
|
||||||
'data_class' => Pricedetail::class,
|
'data_class' => Pricedetail::class,
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue