mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-21 09:35:49 +02:00
Fixed some inspection issues.
This commit is contained in:
parent
eef26f7ae6
commit
639829f5c5
97 changed files with 305 additions and 185 deletions
|
@ -46,6 +46,7 @@ use App\Services\Attachments\AttachmentManager;
|
||||||
use App\Services\Attachments\AttachmentPathResolver;
|
use App\Services\Attachments\AttachmentPathResolver;
|
||||||
use App\Services\Attachments\AttachmentReverseSearch;
|
use App\Services\Attachments\AttachmentReverseSearch;
|
||||||
use IntlDateFormatter;
|
use IntlDateFormatter;
|
||||||
|
use Locale;
|
||||||
use Symfony\Component\Console\Command\Command;
|
use Symfony\Component\Console\Command\Command;
|
||||||
use Symfony\Component\Console\Helper\Table;
|
use Symfony\Component\Console\Helper\Table;
|
||||||
use Symfony\Component\Console\Input\InputInterface;
|
use Symfony\Component\Console\Input\InputInterface;
|
||||||
|
@ -106,7 +107,7 @@ class CleanAttachmentsCommand extends Command
|
||||||
|
|
||||||
$table = new Table($output);
|
$table = new Table($output);
|
||||||
$table->setHeaders(['Filename', 'MIME Type', 'Last modified date']);
|
$table->setHeaders(['Filename', 'MIME Type', 'Last modified date']);
|
||||||
$dateformatter = IntlDateFormatter::create(\Locale::getDefault(), IntlDateFormatter::SHORT, IntlDateFormatter::SHORT);
|
$dateformatter = IntlDateFormatter::create(Locale::getDefault(), IntlDateFormatter::SHORT, IntlDateFormatter::SHORT);
|
||||||
|
|
||||||
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
|
||||||
|
|
|
@ -65,6 +65,7 @@ use App\Services\LogSystem\EventCommentHelper;
|
||||||
use App\Services\LogSystem\HistoryHelper;
|
use App\Services\LogSystem\HistoryHelper;
|
||||||
use App\Services\LogSystem\TimeTravel;
|
use App\Services\LogSystem\TimeTravel;
|
||||||
use App\Services\StructuralElementRecursionHelper;
|
use App\Services\StructuralElementRecursionHelper;
|
||||||
|
use DateTime;
|
||||||
use Doctrine\ORM\EntityManagerInterface;
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
use InvalidArgumentException;
|
use InvalidArgumentException;
|
||||||
use Omines\DataTablesBundle\DataTableFactory;
|
use Omines\DataTablesBundle\DataTableFactory;
|
||||||
|
@ -77,7 +78,6 @@ use Symfony\Component\HttpFoundation\RedirectResponse;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
use Symfony\Component\PasswordHasher\Hasher\UserPasswordHasherInterface;
|
use Symfony\Component\PasswordHasher\Hasher\UserPasswordHasherInterface;
|
||||||
use Symfony\Component\Security\Core\Encoder\UserPasswordEncoderInterface;
|
|
||||||
use Symfony\Component\Validator\ConstraintViolationList;
|
use Symfony\Component\Validator\ConstraintViolationList;
|
||||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||||
|
|
||||||
|
@ -138,17 +138,17 @@ abstract class BaseAdminController extends AbstractController
|
||||||
$this->entityManager = $entityManager;
|
$this->entityManager = $entityManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function revertElementIfNeeded(AbstractDBElement $entity, ?string $timestamp): ?\DateTime
|
protected function revertElementIfNeeded(AbstractDBElement $entity, ?string $timestamp): ?DateTime
|
||||||
{
|
{
|
||||||
if (null !== $timestamp) {
|
if (null !== $timestamp) {
|
||||||
$this->denyAccessUnlessGranted('@tools.timetravel');
|
$this->denyAccessUnlessGranted('@tools.timetravel');
|
||||||
$this->denyAccessUnlessGranted('show_history', $entity);
|
$this->denyAccessUnlessGranted('show_history', $entity);
|
||||||
//If the timestamp only contains numbers interpret it as unix timestamp
|
//If the timestamp only contains numbers interpret it as unix timestamp
|
||||||
if (ctype_digit($timestamp)) {
|
if (ctype_digit($timestamp)) {
|
||||||
$timeTravel_timestamp = new \DateTime();
|
$timeTravel_timestamp = new DateTime();
|
||||||
$timeTravel_timestamp->setTimestamp((int) $timestamp);
|
$timeTravel_timestamp->setTimestamp((int) $timestamp);
|
||||||
} else { //Try to parse it via DateTime
|
} else { //Try to parse it via DateTime
|
||||||
$timeTravel_timestamp = new \DateTime($timestamp);
|
$timeTravel_timestamp = new DateTime($timestamp);
|
||||||
}
|
}
|
||||||
$this->timeTravel->revertEntityToTimestamp($entity, $timeTravel_timestamp);
|
$this->timeTravel->revertEntityToTimestamp($entity, $timeTravel_timestamp);
|
||||||
|
|
||||||
|
@ -433,7 +433,8 @@ abstract class BaseAdminController extends AbstractController
|
||||||
$this->denyAccessUnlessGranted('delete', $entity);
|
$this->denyAccessUnlessGranted('delete', $entity);
|
||||||
|
|
||||||
if ($this->isCsrfTokenValid('delete'.$entity->getId(), $request->request->get('_token'))) {
|
if ($this->isCsrfTokenValid('delete'.$entity->getId(), $request->request->get('_token'))) {
|
||||||
$entityManager = $this->getDoctrine()->getManager();
|
|
||||||
|
$entityManager = $this->entityManager;
|
||||||
|
|
||||||
if (!$this->deleteCheck($entity)) {
|
if (!$this->deleteCheck($entity)) {
|
||||||
return $this->redirectToRoute($this->route_base.'_edit', ['id' => $entity->getID()]);
|
return $this->redirectToRoute($this->route_base.'_edit', ['id' => $entity->getID()]);
|
||||||
|
|
|
@ -68,7 +68,6 @@ use Symfony\Component\HttpFoundation\Request;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
use Symfony\Component\PasswordHasher\Hasher\UserPasswordHasherInterface;
|
use Symfony\Component\PasswordHasher\Hasher\UserPasswordHasherInterface;
|
||||||
use Symfony\Component\Routing\Annotation\Route;
|
use Symfony\Component\Routing\Annotation\Route;
|
||||||
use Symfony\Component\Security\Core\Encoder\UserPasswordEncoderInterface;
|
|
||||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -51,6 +51,7 @@ use App\Services\EntityExporter;
|
||||||
use App\Services\EntityImporter;
|
use App\Services\EntityImporter;
|
||||||
use App\Services\StructuralElementRecursionHelper;
|
use App\Services\StructuralElementRecursionHelper;
|
||||||
use Doctrine\ORM\EntityManagerInterface;
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
|
use Symfony\Component\HttpFoundation\RedirectResponse;
|
||||||
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;
|
||||||
|
@ -70,7 +71,7 @@ class FootprintController extends BaseAdminController
|
||||||
/**
|
/**
|
||||||
* @Route("/{id}", name="footprint_delete", methods={"DELETE"})
|
* @Route("/{id}", name="footprint_delete", methods={"DELETE"})
|
||||||
*/
|
*/
|
||||||
public function delete(Request $request, Footprint $entity, StructuralElementRecursionHelper $recursionHelper): \Symfony\Component\HttpFoundation\RedirectResponse
|
public function delete(Request $request, Footprint $entity, StructuralElementRecursionHelper $recursionHelper): RedirectResponse
|
||||||
{
|
{
|
||||||
return $this->_delete($request, $entity, $recursionHelper);
|
return $this->_delete($request, $entity, $recursionHelper);
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,8 +55,6 @@ use Symfony\Component\HttpFoundation\RedirectResponse;
|
||||||
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\Security\Http\Authenticator\AbstractPreAuthenticatedAuthenticator;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Route("/label_profile")
|
* @Route("/label_profile")
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -50,6 +50,7 @@ use App\Services\EntityExporter;
|
||||||
use App\Services\EntityImporter;
|
use App\Services\EntityImporter;
|
||||||
use App\Services\StructuralElementRecursionHelper;
|
use App\Services\StructuralElementRecursionHelper;
|
||||||
use Doctrine\ORM\EntityManagerInterface;
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
|
use Symfony\Component\HttpFoundation\RedirectResponse;
|
||||||
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;
|
||||||
|
@ -69,9 +70,9 @@ class ManufacturerController extends BaseAdminController
|
||||||
/**
|
/**
|
||||||
* @Route("/{id}", name="manufacturer_delete", methods={"DELETE"})
|
* @Route("/{id}", name="manufacturer_delete", methods={"DELETE"})
|
||||||
*
|
*
|
||||||
* @return \Symfony\Component\HttpFoundation\RedirectResponse
|
* @return RedirectResponse
|
||||||
*/
|
*/
|
||||||
public function delete(Request $request, Manufacturer $entity, StructuralElementRecursionHelper $recursionHelper): \Symfony\Component\HttpFoundation\RedirectResponse
|
public function delete(Request $request, Manufacturer $entity, StructuralElementRecursionHelper $recursionHelper): RedirectResponse
|
||||||
{
|
{
|
||||||
return $this->_delete($request, $entity, $recursionHelper);
|
return $this->_delete($request, $entity, $recursionHelper);
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,6 +51,7 @@ use App\Services\EntityExporter;
|
||||||
use App\Services\EntityImporter;
|
use App\Services\EntityImporter;
|
||||||
use App\Services\StructuralElementRecursionHelper;
|
use App\Services\StructuralElementRecursionHelper;
|
||||||
use Doctrine\ORM\EntityManagerInterface;
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
|
use Symfony\Component\HttpFoundation\RedirectResponse;
|
||||||
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;
|
||||||
|
@ -70,7 +71,7 @@ class MeasurementUnitController extends BaseAdminController
|
||||||
/**
|
/**
|
||||||
* @Route("/{id}", name="measurement_unit_delete", methods={"DELETE"})
|
* @Route("/{id}", name="measurement_unit_delete", methods={"DELETE"})
|
||||||
*/
|
*/
|
||||||
public function delete(Request $request, MeasurementUnit $entity, StructuralElementRecursionHelper $recursionHelper): \Symfony\Component\HttpFoundation\RedirectResponse
|
public function delete(Request $request, MeasurementUnit $entity, StructuralElementRecursionHelper $recursionHelper): RedirectResponse
|
||||||
{
|
{
|
||||||
return $this->_delete($request, $entity, $recursionHelper);
|
return $this->_delete($request, $entity, $recursionHelper);
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,6 +33,7 @@ use App\Services\ElementTypeNameGenerator;
|
||||||
use App\Services\LabelSystem\LabelGenerator;
|
use App\Services\LabelSystem\LabelGenerator;
|
||||||
use App\Services\Misc\RangeParser;
|
use App\Services\Misc\RangeParser;
|
||||||
use Doctrine\ORM\EntityManagerInterface;
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
|
use InvalidArgumentException;
|
||||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||||
use Symfony\Component\Form\FormError;
|
use Symfony\Component\Form\FormError;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
|
@ -146,7 +147,7 @@ class LabelController extends AbstractController
|
||||||
protected function findObjects(string $type, string $ids): array
|
protected function findObjects(string $type, string $ids): array
|
||||||
{
|
{
|
||||||
if (!isset(LabelGenerator::CLASS_SUPPORT_MAPPING[$type])) {
|
if (!isset(LabelGenerator::CLASS_SUPPORT_MAPPING[$type])) {
|
||||||
throw new \InvalidArgumentException('The given type is not known and can not be mapped to a class!');
|
throw new InvalidArgumentException('The given type is not known and can not be mapped to a class!');
|
||||||
}
|
}
|
||||||
|
|
||||||
$id_array = $this->rangeParser->parse($ids);
|
$id_array = $this->rangeParser->parse($ids);
|
||||||
|
|
|
@ -52,9 +52,11 @@ use App\Entity\LogSystem\ElementEditedLogEntry;
|
||||||
use App\Services\LogSystem\EventUndoHelper;
|
use App\Services\LogSystem\EventUndoHelper;
|
||||||
use App\Services\LogSystem\TimeTravel;
|
use App\Services\LogSystem\TimeTravel;
|
||||||
use Doctrine\ORM\EntityManagerInterface;
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
|
use InvalidArgumentException;
|
||||||
use Omines\DataTablesBundle\DataTableFactory;
|
use Omines\DataTablesBundle\DataTableFactory;
|
||||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||||
|
use Symfony\Component\HttpFoundation\RedirectResponse;
|
||||||
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;
|
||||||
|
@ -99,7 +101,7 @@ class LogController extends AbstractController
|
||||||
/**
|
/**
|
||||||
* @Route("/undo", name="log_undo", methods={"POST"})
|
* @Route("/undo", name="log_undo", methods={"POST"})
|
||||||
*/
|
*/
|
||||||
public function undoRevertLog(Request $request, EventUndoHelper $eventUndoHelper): \Symfony\Component\HttpFoundation\RedirectResponse
|
public function undoRevertLog(Request $request, EventUndoHelper $eventUndoHelper): RedirectResponse
|
||||||
{
|
{
|
||||||
$mode = EventUndoHelper::MODE_UNDO;
|
$mode = EventUndoHelper::MODE_UNDO;
|
||||||
$id = $request->request->get('undo');
|
$id = $request->request->get('undo');
|
||||||
|
@ -112,7 +114,7 @@ class LogController extends AbstractController
|
||||||
|
|
||||||
$log_element = $this->entityManager->find(AbstractLogEntry::class, $id);
|
$log_element = $this->entityManager->find(AbstractLogEntry::class, $id);
|
||||||
if (null === $log_element) {
|
if (null === $log_element) {
|
||||||
throw new \InvalidArgumentException('No log entry with the given ID is existing!');
|
throw new InvalidArgumentException('No log entry with the given ID is existing!');
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->denyAccessUnlessGranted('revert_element', $log_element->getTargetClass());
|
$this->denyAccessUnlessGranted('revert_element', $log_element->getTargetClass());
|
||||||
|
|
|
@ -60,7 +60,9 @@ use App\Services\LogSystem\HistoryHelper;
|
||||||
use App\Services\LogSystem\TimeTravel;
|
use App\Services\LogSystem\TimeTravel;
|
||||||
use App\Services\Parameters\ParameterExtractor;
|
use App\Services\Parameters\ParameterExtractor;
|
||||||
use App\Services\PricedetailHelper;
|
use App\Services\PricedetailHelper;
|
||||||
|
use DateTime;
|
||||||
use Doctrine\ORM\EntityManagerInterface;
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
|
use Exception;
|
||||||
use Omines\DataTablesBundle\DataTableFactory;
|
use Omines\DataTablesBundle\DataTableFactory;
|
||||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||||
use Symfony\Component\Form\FormInterface;
|
use Symfony\Component\Form\FormInterface;
|
||||||
|
@ -91,7 +93,7 @@ class PartController extends AbstractController
|
||||||
* @Route("/{id}/info/{timestamp}", name="part_info")
|
* @Route("/{id}/info/{timestamp}", name="part_info")
|
||||||
* @Route("/{id}", requirements={"id"="\d+"})
|
* @Route("/{id}", requirements={"id"="\d+"})
|
||||||
*
|
*
|
||||||
* @throws \Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function show(Part $part, Request $request, TimeTravel $timeTravel, HistoryHelper $historyHelper,
|
public function show(Part $part, Request $request, TimeTravel $timeTravel, HistoryHelper $historyHelper,
|
||||||
DataTableFactory $dataTable, ParameterExtractor $parameterExtractor, ?string $timestamp = null): Response
|
DataTableFactory $dataTable, ParameterExtractor $parameterExtractor, ?string $timestamp = null): Response
|
||||||
|
@ -104,10 +106,10 @@ class PartController extends AbstractController
|
||||||
$this->denyAccessUnlessGranted('show_history', $part);
|
$this->denyAccessUnlessGranted('show_history', $part);
|
||||||
//If the timestamp only contains numbers interpret it as unix timestamp
|
//If the timestamp only contains numbers interpret it as unix timestamp
|
||||||
if (ctype_digit($timestamp)) {
|
if (ctype_digit($timestamp)) {
|
||||||
$timeTravel_timestamp = new \DateTime();
|
$timeTravel_timestamp = new DateTime();
|
||||||
$timeTravel_timestamp->setTimestamp((int) $timestamp);
|
$timeTravel_timestamp->setTimestamp((int) $timestamp);
|
||||||
} else { //Try to parse it via DateTime
|
} else { //Try to parse it via DateTime
|
||||||
$timeTravel_timestamp = new \DateTime($timestamp);
|
$timeTravel_timestamp = new DateTime($timestamp);
|
||||||
}
|
}
|
||||||
$timeTravel->revertEntityToTimestamp($part, $timeTravel_timestamp);
|
$timeTravel->revertEntityToTimestamp($part, $timeTravel_timestamp);
|
||||||
}
|
}
|
||||||
|
@ -199,12 +201,11 @@ class PartController extends AbstractController
|
||||||
/**
|
/**
|
||||||
* @Route("/{id}/delete", name="part_delete", methods={"DELETE"})
|
* @Route("/{id}/delete", name="part_delete", methods={"DELETE"})
|
||||||
*/
|
*/
|
||||||
public function delete(Request $request, Part $part): RedirectResponse
|
public function delete(Request $request, Part $part, EntityManagerInterface $entityManager): RedirectResponse
|
||||||
{
|
{
|
||||||
$this->denyAccessUnlessGranted('delete', $part);
|
$this->denyAccessUnlessGranted('delete', $part);
|
||||||
|
|
||||||
if ($this->isCsrfTokenValid('delete'.$part->getId(), $request->request->get('_token'))) {
|
if ($this->isCsrfTokenValid('delete'.$part->getId(), $request->request->get('_token'))) {
|
||||||
$entityManager = $this->getDoctrine()->getManager();
|
|
||||||
|
|
||||||
$this->commentHelper->setMessage($request->request->get('log_comment', null));
|
$this->commentHelper->setMessage($request->request->get('log_comment', null));
|
||||||
|
|
||||||
|
|
|
@ -27,6 +27,7 @@ use App\Form\LabelSystem\ScanDialogType;
|
||||||
use App\Services\LabelSystem\Barcodes\BarcodeNormalizer;
|
use App\Services\LabelSystem\Barcodes\BarcodeNormalizer;
|
||||||
use App\Services\LabelSystem\Barcodes\BarcodeRedirector;
|
use App\Services\LabelSystem\Barcodes\BarcodeRedirector;
|
||||||
use Doctrine\ORM\EntityNotFoundException;
|
use Doctrine\ORM\EntityNotFoundException;
|
||||||
|
use InvalidArgumentException;
|
||||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
|
@ -67,7 +68,7 @@ class ScanController extends AbstractController
|
||||||
} catch (EntityNotFoundException $exception) {
|
} catch (EntityNotFoundException $exception) {
|
||||||
$this->addFlash('success', 'scan.qr_not_found');
|
$this->addFlash('success', 'scan.qr_not_found');
|
||||||
}
|
}
|
||||||
} catch (\InvalidArgumentException $exception) {
|
} catch (InvalidArgumentException $exception) {
|
||||||
$this->addFlash('error', 'scan.format_unknown');
|
$this->addFlash('error', 'scan.format_unknown');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,7 +55,9 @@ use Symfony\Component\Form\Extension\Core\Type\PasswordType;
|
||||||
use Symfony\Component\Form\Extension\Core\Type\RepeatedType;
|
use Symfony\Component\Form\Extension\Core\Type\RepeatedType;
|
||||||
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
||||||
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||||||
|
use Symfony\Component\HttpFoundation\RedirectResponse;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
|
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
|
||||||
use Symfony\Component\Routing\Annotation\Route;
|
use Symfony\Component\Routing\Annotation\Route;
|
||||||
use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
|
use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
|
||||||
|
@ -78,7 +80,7 @@ class SecurityController extends AbstractController
|
||||||
/**
|
/**
|
||||||
* @Route("/login", name="login", methods={"GET", "POST"})
|
* @Route("/login", name="login", methods={"GET", "POST"})
|
||||||
*/
|
*/
|
||||||
public function login(AuthenticationUtils $authenticationUtils): \Symfony\Component\HttpFoundation\Response
|
public function login(AuthenticationUtils $authenticationUtils): Response
|
||||||
{
|
{
|
||||||
// get the login error if there is one
|
// get the login error if there is one
|
||||||
$error = $authenticationUtils->getLastAuthenticationError();
|
$error = $authenticationUtils->getLastAuthenticationError();
|
||||||
|
@ -95,7 +97,7 @@ class SecurityController extends AbstractController
|
||||||
/**
|
/**
|
||||||
* @Route("/pw_reset/request", name="pw_reset_request")
|
* @Route("/pw_reset/request", name="pw_reset_request")
|
||||||
*
|
*
|
||||||
* @return \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response
|
* @return RedirectResponse|Response
|
||||||
*/
|
*/
|
||||||
public function requestPwReset(PasswordResetManager $passwordReset, Request $request)
|
public function requestPwReset(PasswordResetManager $passwordReset, Request $request)
|
||||||
{
|
{
|
||||||
|
@ -139,7 +141,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")
|
||||||
*
|
*
|
||||||
* @return \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response
|
* @return RedirectResponse|Response
|
||||||
*/
|
*/
|
||||||
public function pwResetNewPw(PasswordResetManager $passwordReset, Request $request, EntityManagerInterface $em, EventDispatcherInterface $eventDispatcher, ?string $user = null, ?string $token = null)
|
public function pwResetNewPw(PasswordResetManager $passwordReset, Request $request, EntityManagerInterface $em, EventDispatcherInterface $eventDispatcher, ?string $user = null, ?string $token = null)
|
||||||
{
|
{
|
||||||
|
|
|
@ -55,6 +55,7 @@ use App\Services\EntityExporter;
|
||||||
use App\Services\EntityImporter;
|
use App\Services\EntityImporter;
|
||||||
use App\Services\StructuralElementRecursionHelper;
|
use App\Services\StructuralElementRecursionHelper;
|
||||||
use Doctrine\ORM\EntityManagerInterface;
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
|
use Exception;
|
||||||
use InvalidArgumentException;
|
use InvalidArgumentException;
|
||||||
use Omines\DataTablesBundle\DataTableFactory;
|
use Omines\DataTablesBundle\DataTableFactory;
|
||||||
use Symfony\Component\Asset\Packages;
|
use Symfony\Component\Asset\Packages;
|
||||||
|
@ -98,7 +99,7 @@ class UserController extends AdminPages\BaseAdminController
|
||||||
* @Route("/{id}/edit/{timestamp}", requirements={"id"="\d+"}, name="user_edit")
|
* @Route("/{id}/edit/{timestamp}", requirements={"id"="\d+"}, name="user_edit")
|
||||||
* @Route("/{id}/", requirements={"id"="\d+"})
|
* @Route("/{id}/", requirements={"id"="\d+"})
|
||||||
*
|
*
|
||||||
* @throws \Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function edit(User $entity, Request $request, EntityManagerInterface $em, ?string $timestamp = null): Response
|
public function edit(User $entity, Request $request, EntityManagerInterface $em, ?string $timestamp = null): Response
|
||||||
{
|
{
|
||||||
|
|
|
@ -62,9 +62,9 @@ use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||||||
use Symfony\Component\Form\FormFactoryInterface;
|
use Symfony\Component\Form\FormFactoryInterface;
|
||||||
use Symfony\Component\HttpFoundation\RedirectResponse;
|
use Symfony\Component\HttpFoundation\RedirectResponse;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
use Symfony\Component\PasswordHasher\Hasher\UserPasswordHasherInterface;
|
use Symfony\Component\PasswordHasher\Hasher\UserPasswordHasherInterface;
|
||||||
use Symfony\Component\Routing\Annotation\Route;
|
use Symfony\Component\Routing\Annotation\Route;
|
||||||
use Symfony\Component\Security\Core\Encoder\UserPasswordEncoderInterface;
|
|
||||||
use Symfony\Component\Security\Core\Validator\Constraints\UserPassword;
|
use Symfony\Component\Security\Core\Validator\Constraints\UserPassword;
|
||||||
use Symfony\Component\Validator\Constraints\Length;
|
use Symfony\Component\Validator\Constraints\Length;
|
||||||
|
|
||||||
|
@ -199,7 +199,7 @@ class UserSettingsController extends AbstractController
|
||||||
/**
|
/**
|
||||||
* @Route("/settings", name="user_settings")
|
* @Route("/settings", name="user_settings")
|
||||||
*
|
*
|
||||||
* @return RedirectResponse|\Symfony\Component\HttpFoundation\Response
|
* @return RedirectResponse|Response
|
||||||
*/
|
*/
|
||||||
public function userSettings(Request $request, EntityManagerInterface $em, UserPasswordHasherInterface $passwordEncoder, GoogleAuthenticator $googleAuthenticator, BackupCodeManager $backupCodeManager, FormFactoryInterface $formFactory)
|
public function userSettings(Request $request, EntityManagerInterface $em, UserPasswordHasherInterface $passwordEncoder, GoogleAuthenticator $googleAuthenticator, BackupCodeManager $backupCodeManager, FormFactoryInterface $formFactory)
|
||||||
{
|
{
|
||||||
|
|
|
@ -35,6 +35,7 @@ use App\Entity\Parts\Supplier;
|
||||||
use App\Entity\PriceInformations\Orderdetail;
|
use App\Entity\PriceInformations\Orderdetail;
|
||||||
use App\Entity\PriceInformations\Pricedetail;
|
use App\Entity\PriceInformations\Pricedetail;
|
||||||
use Brick\Math\BigDecimal;
|
use Brick\Math\BigDecimal;
|
||||||
|
use DateTime;
|
||||||
use Doctrine\Bundle\FixturesBundle\Fixture;
|
use Doctrine\Bundle\FixturesBundle\Fixture;
|
||||||
use Doctrine\ORM\EntityManagerInterface;
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
use Doctrine\Persistence\ObjectManager;
|
use Doctrine\Persistence\ObjectManager;
|
||||||
|
@ -80,7 +81,7 @@ class PartFixtures extends Fixture
|
||||||
$part->addPartLot($partLot1);
|
$part->addPartLot($partLot1);
|
||||||
|
|
||||||
$partLot2 = new PartLot();
|
$partLot2 = new PartLot();
|
||||||
$partLot2->setExpirationDate(new \DateTime());
|
$partLot2->setExpirationDate(new DateTime());
|
||||||
$partLot2->setComment('Test');
|
$partLot2->setComment('Test');
|
||||||
$partLot2->setNeedsRefill(true);
|
$partLot2->setNeedsRefill(true);
|
||||||
$partLot2->setStorageLocation($manager->find(Storelocation::class, 3));
|
$partLot2->setStorageLocation($manager->find(Storelocation::class, 3));
|
||||||
|
|
|
@ -47,7 +47,6 @@ use Doctrine\Bundle\FixturesBundle\Fixture;
|
||||||
use Doctrine\ORM\EntityManagerInterface;
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
use Doctrine\Persistence\ObjectManager;
|
use Doctrine\Persistence\ObjectManager;
|
||||||
use Symfony\Component\PasswordHasher\Hasher\UserPasswordHasherInterface;
|
use Symfony\Component\PasswordHasher\Hasher\UserPasswordHasherInterface;
|
||||||
use Symfony\Component\Security\Core\Encoder\UserPasswordEncoderInterface;
|
|
||||||
|
|
||||||
class UserFixtures extends Fixture
|
class UserFixtures extends Fixture
|
||||||
{
|
{
|
||||||
|
|
|
@ -44,6 +44,7 @@ namespace App\DataTables\Column;
|
||||||
|
|
||||||
use DateTime;
|
use DateTime;
|
||||||
use DateTimeInterface;
|
use DateTimeInterface;
|
||||||
|
use Exception;
|
||||||
use IntlDateFormatter;
|
use IntlDateFormatter;
|
||||||
use Locale;
|
use Locale;
|
||||||
use Omines\DataTablesBundle\Column\AbstractColumn;
|
use Omines\DataTablesBundle\Column\AbstractColumn;
|
||||||
|
@ -58,7 +59,7 @@ class LocaleDateTimeColumn extends AbstractColumn
|
||||||
/**
|
/**
|
||||||
* @param $value
|
* @param $value
|
||||||
* @return bool|mixed|string
|
* @return bool|mixed|string
|
||||||
* @throws \Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function normalize($value): string
|
public function normalize($value): string
|
||||||
{
|
{
|
||||||
|
|
|
@ -288,7 +288,7 @@ class ResetAutoIncrementORMPurger implements PurgerInterface, ORMPurgerInterface
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param mixed[] $assoc
|
* @param array $assoc
|
||||||
*/
|
*/
|
||||||
private function getJoinTableName(
|
private function getJoinTableName(
|
||||||
array $assoc,
|
array $assoc,
|
||||||
|
|
|
@ -180,7 +180,7 @@ abstract class Attachment extends AbstractNamedDBElement
|
||||||
//After the %PLACEHOLDER% comes a slash, so we can check if we have a placeholder via explode
|
//After the %PLACEHOLDER% comes a slash, so we can check if we have a placeholder via explode
|
||||||
$tmp = explode('/', $this->path);
|
$tmp = explode('/', $this->path);
|
||||||
|
|
||||||
return !in_array($tmp[0], array_merge(static::INTERNAL_PLACEHOLDER, static::BUILTIN_PLACEHOLDER), false);
|
return !in_array($tmp[0], array_merge(static::INTERNAL_PLACEHOLDER, static::BUILTIN_PLACEHOLDER));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -23,6 +23,7 @@ declare(strict_types=1);
|
||||||
namespace App\Entity\Base;
|
namespace App\Entity\Base;
|
||||||
|
|
||||||
use Doctrine\ORM\Mapping as ORM;
|
use Doctrine\ORM\Mapping as ORM;
|
||||||
|
use JsonSerializable;
|
||||||
use Symfony\Component\Serializer\Annotation\DiscriminatorMap;
|
use Symfony\Component\Serializer\Annotation\DiscriminatorMap;
|
||||||
use Symfony\Component\Serializer\Annotation\Groups;
|
use Symfony\Component\Serializer\Annotation\Groups;
|
||||||
|
|
||||||
|
@ -55,7 +56,7 @@ use Symfony\Component\Serializer\Annotation\Groups;
|
||||||
* "user" = "App\Entity\User"
|
* "user" = "App\Entity\User"
|
||||||
* })
|
* })
|
||||||
*/
|
*/
|
||||||
abstract class AbstractDBElement implements \JsonSerializable
|
abstract class AbstractDBElement implements JsonSerializable
|
||||||
{
|
{
|
||||||
/** @var int|null The Identification number for this part. This value is unique for the element in this table.
|
/** @var int|null The Identification number for this part. This value is unique for the element in this table.
|
||||||
* Null if the element is not saved to DB yet.
|
* Null if the element is not saved to DB yet.
|
||||||
|
|
|
@ -43,6 +43,7 @@ declare(strict_types=1);
|
||||||
namespace App\Entity\Base;
|
namespace App\Entity\Base;
|
||||||
|
|
||||||
use App\Entity\Attachments\Attachment;
|
use App\Entity\Attachments\Attachment;
|
||||||
|
use Doctrine\ORM\Mapping as ORM;
|
||||||
use Symfony\Component\Validator\Constraints as Assert;
|
use Symfony\Component\Validator\Constraints as Assert;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -43,6 +43,7 @@ declare(strict_types=1);
|
||||||
namespace App\Entity\Base;
|
namespace App\Entity\Base;
|
||||||
|
|
||||||
use DateTime;
|
use DateTime;
|
||||||
|
use Doctrine\ORM\Mapping as ORM;
|
||||||
use Symfony\Component\Serializer\Annotation\Groups;
|
use Symfony\Component\Serializer\Annotation\Groups;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -24,6 +24,8 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Entity\Contracts;
|
namespace App\Entity\Contracts;
|
||||||
|
|
||||||
|
use DateTime;
|
||||||
|
|
||||||
interface TimeTravelInterface
|
interface TimeTravelInterface
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
@ -41,5 +43,5 @@ interface TimeTravelInterface
|
||||||
/**
|
/**
|
||||||
* Returns the the timestamp associated with this change.
|
* Returns the the timestamp associated with this change.
|
||||||
*/
|
*/
|
||||||
public function getTimestamp(): \DateTime;
|
public function getTimestamp(): DateTime;
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,6 +64,7 @@ use App\Entity\UserSystem\Group;
|
||||||
use App\Entity\UserSystem\User;
|
use App\Entity\UserSystem\User;
|
||||||
use DateTime;
|
use DateTime;
|
||||||
use Doctrine\ORM\Mapping as ORM;
|
use Doctrine\ORM\Mapping as ORM;
|
||||||
|
use InvalidArgumentException;
|
||||||
use Psr\Log\LogLevel;
|
use Psr\Log\LogLevel;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -263,7 +264,7 @@ abstract class AbstractLogEntry extends AbstractDBElement
|
||||||
public function setLevel(int $level): self
|
public function setLevel(int $level): self
|
||||||
{
|
{
|
||||||
if ($level < 0 || $this->level > 7) {
|
if ($level < 0 || $this->level > 7) {
|
||||||
throw new \InvalidArgumentException(sprintf('$level must be between 0 and 7! %d given!', $level));
|
throw new InvalidArgumentException(sprintf('$level must be between 0 and 7! %d given!', $level));
|
||||||
}
|
}
|
||||||
$this->level = $level;
|
$this->level = $level;
|
||||||
|
|
||||||
|
@ -387,7 +388,7 @@ abstract class AbstractLogEntry extends AbstractDBElement
|
||||||
final public static function levelIntToString(int $level): string
|
final public static function levelIntToString(int $level): string
|
||||||
{
|
{
|
||||||
if (!isset(self::LEVEL_ID_TO_STRING[$level])) {
|
if (!isset(self::LEVEL_ID_TO_STRING[$level])) {
|
||||||
throw new \InvalidArgumentException('No level with this int is existing!');
|
throw new InvalidArgumentException('No level with this int is existing!');
|
||||||
}
|
}
|
||||||
|
|
||||||
return self::LEVEL_ID_TO_STRING[$level];
|
return self::LEVEL_ID_TO_STRING[$level];
|
||||||
|
@ -404,7 +405,7 @@ abstract class AbstractLogEntry extends AbstractDBElement
|
||||||
{
|
{
|
||||||
$tmp = array_flip(self::LEVEL_ID_TO_STRING);
|
$tmp = array_flip(self::LEVEL_ID_TO_STRING);
|
||||||
if (!isset($tmp[$level])) {
|
if (!isset($tmp[$level])) {
|
||||||
throw new \InvalidArgumentException('No level with this string is existing!');
|
throw new InvalidArgumentException('No level with this string is existing!');
|
||||||
}
|
}
|
||||||
|
|
||||||
return $tmp[$level];
|
return $tmp[$level];
|
||||||
|
@ -418,7 +419,7 @@ abstract class AbstractLogEntry extends AbstractDBElement
|
||||||
final public static function targetTypeIdToClass(int $type_id): string
|
final public static function targetTypeIdToClass(int $type_id): string
|
||||||
{
|
{
|
||||||
if (!isset(self::TARGET_CLASS_MAPPING[$type_id])) {
|
if (!isset(self::TARGET_CLASS_MAPPING[$type_id])) {
|
||||||
throw new \InvalidArgumentException('No target type with this ID is existing!');
|
throw new InvalidArgumentException('No target type with this ID is existing!');
|
||||||
}
|
}
|
||||||
|
|
||||||
return self::TARGET_CLASS_MAPPING[$type_id];
|
return self::TARGET_CLASS_MAPPING[$type_id];
|
||||||
|
@ -446,6 +447,6 @@ abstract class AbstractLogEntry extends AbstractDBElement
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new \InvalidArgumentException('No target ID for this class is existing!');
|
throw new InvalidArgumentException('No target ID for this class is existing!');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,6 +27,7 @@ use App\Entity\Base\AbstractDBElement;
|
||||||
use App\Entity\Contracts\LogWithEventUndoInterface;
|
use App\Entity\Contracts\LogWithEventUndoInterface;
|
||||||
use App\Entity\Contracts\NamedElementInterface;
|
use App\Entity\Contracts\NamedElementInterface;
|
||||||
use Doctrine\ORM\Mapping as ORM;
|
use Doctrine\ORM\Mapping as ORM;
|
||||||
|
use InvalidArgumentException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ORM\Entity()
|
* @ORM\Entity()
|
||||||
|
@ -104,7 +105,7 @@ class CollectionElementDeleted extends AbstractLogEntry implements LogWithEventU
|
||||||
} elseif ('revert' === $mode) {
|
} elseif ('revert' === $mode) {
|
||||||
$this->extra['um'] = 2;
|
$this->extra['um'] = 2;
|
||||||
} else {
|
} else {
|
||||||
throw new \InvalidArgumentException('Passed invalid $mode!');
|
throw new InvalidArgumentException('Passed invalid $mode!');
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
|
|
|
@ -48,6 +48,7 @@ use App\Entity\Contracts\LogWithEventUndoInterface;
|
||||||
use App\Entity\UserSystem\Group;
|
use App\Entity\UserSystem\Group;
|
||||||
use App\Entity\UserSystem\User;
|
use App\Entity\UserSystem\User;
|
||||||
use Doctrine\ORM\Mapping as ORM;
|
use Doctrine\ORM\Mapping as ORM;
|
||||||
|
use InvalidArgumentException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ORM\Entity()
|
* @ORM\Entity()
|
||||||
|
@ -120,7 +121,7 @@ class ElementCreatedLogEntry extends AbstractLogEntry implements LogWithCommentI
|
||||||
} elseif ('revert' === $mode) {
|
} elseif ('revert' === $mode) {
|
||||||
$this->extra['um'] = 2;
|
$this->extra['um'] = 2;
|
||||||
} else {
|
} else {
|
||||||
throw new \InvalidArgumentException('Passed invalid $mode!');
|
throw new InvalidArgumentException('Passed invalid $mode!');
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
|
|
|
@ -50,6 +50,7 @@ use App\Entity\Contracts\TimeTravelInterface;
|
||||||
use App\Entity\UserSystem\Group;
|
use App\Entity\UserSystem\Group;
|
||||||
use App\Entity\UserSystem\User;
|
use App\Entity\UserSystem\User;
|
||||||
use Doctrine\ORM\Mapping as ORM;
|
use Doctrine\ORM\Mapping as ORM;
|
||||||
|
use InvalidArgumentException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ORM\Entity()
|
* @ORM\Entity()
|
||||||
|
@ -153,7 +154,7 @@ class ElementDeletedLogEntry extends AbstractLogEntry implements TimeTravelInter
|
||||||
} elseif ('revert' === $mode) {
|
} elseif ('revert' === $mode) {
|
||||||
$this->extra['um'] = 2;
|
$this->extra['um'] = 2;
|
||||||
} else {
|
} else {
|
||||||
throw new \InvalidArgumentException('Passed invalid $mode!');
|
throw new InvalidArgumentException('Passed invalid $mode!');
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
|
|
|
@ -47,6 +47,7 @@ use App\Entity\Contracts\LogWithCommentInterface;
|
||||||
use App\Entity\Contracts\LogWithEventUndoInterface;
|
use App\Entity\Contracts\LogWithEventUndoInterface;
|
||||||
use App\Entity\Contracts\TimeTravelInterface;
|
use App\Entity\Contracts\TimeTravelInterface;
|
||||||
use Doctrine\ORM\Mapping as ORM;
|
use Doctrine\ORM\Mapping as ORM;
|
||||||
|
use InvalidArgumentException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ORM\Entity()
|
* @ORM\Entity()
|
||||||
|
@ -157,7 +158,7 @@ class ElementEditedLogEntry extends AbstractLogEntry implements TimeTravelInterf
|
||||||
} elseif ('revert' === $mode) {
|
} elseif ('revert' === $mode) {
|
||||||
$this->extra['um'] = 2;
|
$this->extra['um'] = 2;
|
||||||
} else {
|
} else {
|
||||||
throw new \InvalidArgumentException('Passed invalid $mode!');
|
throw new InvalidArgumentException('Passed invalid $mode!');
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
|
|
|
@ -27,6 +27,7 @@ use App\Entity\Base\AbstractDBElement;
|
||||||
use App\Entity\UserSystem\User;
|
use App\Entity\UserSystem\User;
|
||||||
use App\Events\SecurityEvents;
|
use App\Events\SecurityEvents;
|
||||||
use Doctrine\ORM\Mapping as ORM;
|
use Doctrine\ORM\Mapping as ORM;
|
||||||
|
use InvalidArgumentException;
|
||||||
use Symfony\Component\HttpFoundation\IpUtils;
|
use Symfony\Component\HttpFoundation\IpUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -60,7 +61,7 @@ class SecurityEventLogEntry extends AbstractLogEntry
|
||||||
public function setTargetElement(?AbstractDBElement $element): AbstractLogEntry
|
public function setTargetElement(?AbstractDBElement $element): AbstractLogEntry
|
||||||
{
|
{
|
||||||
if (!$element instanceof User) {
|
if (!$element instanceof User) {
|
||||||
throw new \InvalidArgumentException('Target element must be a User object!');
|
throw new InvalidArgumentException('Target element must be a User object!');
|
||||||
}
|
}
|
||||||
|
|
||||||
return parent::setTargetElement($element);
|
return parent::setTargetElement($element);
|
||||||
|
@ -75,7 +76,7 @@ class SecurityEventLogEntry extends AbstractLogEntry
|
||||||
{
|
{
|
||||||
$key = array_search($type, static::SECURITY_TYPE_MAPPING, true);
|
$key = array_search($type, static::SECURITY_TYPE_MAPPING, true);
|
||||||
if (false === $key) {
|
if (false === $key) {
|
||||||
throw new \InvalidArgumentException('Given event type is not existing!');
|
throw new InvalidArgumentException('Given event type is not existing!');
|
||||||
}
|
}
|
||||||
$this->extra['e'] = $key;
|
$this->extra['e'] = $key;
|
||||||
|
|
||||||
|
|
|
@ -30,6 +30,8 @@ use InvalidArgumentException;
|
||||||
use LogicException;
|
use LogicException;
|
||||||
use Symfony\Component\Validator\Constraints as Assert;
|
use Symfony\Component\Validator\Constraints as Assert;
|
||||||
|
|
||||||
|
use function sprintf;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ORM\Entity()
|
* @ORM\Entity()
|
||||||
* @ORM\Table("parameters")
|
* @ORM\Table("parameters")
|
||||||
|
@ -376,7 +378,7 @@ abstract class AbstractParameter extends AbstractNamedDBElement
|
||||||
*/
|
*/
|
||||||
protected function formatWithUnit(float $value, string $format = '%g'): string
|
protected function formatWithUnit(float $value, string $format = '%g'): string
|
||||||
{
|
{
|
||||||
$str = \sprintf($format, $value);
|
$str = sprintf($format, $value);
|
||||||
if (!empty($this->unit)) {
|
if (!empty($this->unit)) {
|
||||||
return $str.' '.$this->unit;
|
return $str.' '.$this->unit;
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,6 +44,8 @@ namespace App\Entity\Parts\PartTraits;
|
||||||
|
|
||||||
use App\Entity\Parts\Part;
|
use App\Entity\Parts\Part;
|
||||||
use App\Security\Annotations\ColumnSecurity;
|
use App\Security\Annotations\ColumnSecurity;
|
||||||
|
use Doctrine\ORM\Mapping as ORM;
|
||||||
|
use Symfony\Component\Validator\Constraints as Assert;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Advanced properties of a part, not related to a more specific group.
|
* Advanced properties of a part, not related to a more specific group.
|
||||||
|
|
|
@ -46,6 +46,7 @@ use App\Entity\Parts\Category;
|
||||||
use App\Entity\Parts\Footprint;
|
use App\Entity\Parts\Footprint;
|
||||||
use App\Security\Annotations\ColumnSecurity;
|
use App\Security\Annotations\ColumnSecurity;
|
||||||
use App\Validator\Constraints\Selectable;
|
use App\Validator\Constraints\Selectable;
|
||||||
|
use Doctrine\ORM\Mapping as ORM;
|
||||||
use Symfony\Component\Validator\Constraints as Assert;
|
use Symfony\Component\Validator\Constraints as Assert;
|
||||||
|
|
||||||
trait BasicPropertyTrait
|
trait BasicPropertyTrait
|
||||||
|
|
|
@ -46,6 +46,8 @@ use App\Entity\Parts\MeasurementUnit;
|
||||||
use App\Entity\Parts\PartLot;
|
use App\Entity\Parts\PartLot;
|
||||||
use App\Security\Annotations\ColumnSecurity;
|
use App\Security\Annotations\ColumnSecurity;
|
||||||
use Doctrine\Common\Collections\Collection;
|
use Doctrine\Common\Collections\Collection;
|
||||||
|
use Doctrine\ORM\Mapping as ORM;
|
||||||
|
use Symfony\Component\Validator\Constraints as Assert;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This trait collects all aspects of a part related to instock, part lots.
|
* This trait collects all aspects of a part related to instock, part lots.
|
||||||
|
|
|
@ -46,6 +46,8 @@ use App\Entity\Parts\Manufacturer;
|
||||||
use App\Entity\Parts\Part;
|
use App\Entity\Parts\Part;
|
||||||
use App\Security\Annotations\ColumnSecurity;
|
use App\Security\Annotations\ColumnSecurity;
|
||||||
use App\Validator\Constraints\Selectable;
|
use App\Validator\Constraints\Selectable;
|
||||||
|
use Doctrine\ORM\Mapping as ORM;
|
||||||
|
use Symfony\Component\Validator\Constraints as Assert;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* In this trait all manufacturer related properties of a part are collected (like MPN, manufacturer URL).
|
* In this trait all manufacturer related properties of a part are collected (like MPN, manufacturer URL).
|
||||||
|
|
|
@ -44,6 +44,7 @@ namespace App\Entity\Parts\PartTraits;
|
||||||
|
|
||||||
use App\Entity\PriceInformations\Orderdetail;
|
use App\Entity\PriceInformations\Orderdetail;
|
||||||
use App\Security\Annotations\ColumnSecurity;
|
use App\Security\Annotations\ColumnSecurity;
|
||||||
|
use Symfony\Component\Validator\Constraints as Assert;
|
||||||
use function count;
|
use function count;
|
||||||
use Doctrine\Common\Collections\Collection;
|
use Doctrine\Common\Collections\Collection;
|
||||||
use Doctrine\ORM\Mapping as ORM;
|
use Doctrine\ORM\Mapping as ORM;
|
||||||
|
|
|
@ -235,7 +235,7 @@ class Pricedetail extends AbstractDBElement implements TimeStampableInterface
|
||||||
if ($this->orderdetail && $this->orderdetail->getPart() && !$this->orderdetail->getPart()->useFloatAmount()) {
|
if ($this->orderdetail && $this->orderdetail->getPart() && !$this->orderdetail->getPart()->useFloatAmount()) {
|
||||||
$tmp = round($this->min_discount_quantity);
|
$tmp = round($this->min_discount_quantity);
|
||||||
|
|
||||||
return $tmp < 1 ? 1 : $tmp;
|
return max($tmp, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->min_discount_quantity;
|
return $this->min_discount_quantity;
|
||||||
|
|
|
@ -518,8 +518,6 @@ class PermissionsEmbed
|
||||||
|
|
||||||
$mask = 0b11 << $n; //Mask all bits that should be written
|
$mask = 0b11 << $n; //Mask all bits that should be written
|
||||||
$newval = $new << $n; //The new value.
|
$newval = $new << $n; //The new value.
|
||||||
$data = ($data & ~$mask) | ($newval & $mask);
|
return ($data & ~$mask) | ($newval & $mask);
|
||||||
|
|
||||||
return $data;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -721,7 +721,7 @@ class User extends AttachmentContainingDBElement implements UserInterface, HasPe
|
||||||
*/
|
*/
|
||||||
public function isGoogleAuthenticatorEnabled(): bool
|
public function isGoogleAuthenticatorEnabled(): bool
|
||||||
{
|
{
|
||||||
return $this->googleAuthenticatorSecret ? true : false;
|
return (bool)$this->googleAuthenticatorSecret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -42,7 +42,9 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Exceptions;
|
namespace App\Exceptions;
|
||||||
|
|
||||||
class LogEntryObsoleteException extends \RuntimeException
|
use RuntimeException;
|
||||||
|
|
||||||
|
class LogEntryObsoleteException extends RuntimeException
|
||||||
{
|
{
|
||||||
protected $message = 'This log entry is obsolete and exists only for compatibility reasons with old Part-DB versions. You should not use it!';
|
protected $message = 'This log entry is obsolete and exists only for compatibility reasons with old Part-DB versions. You should not use it!';
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,9 +23,10 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Exceptions;
|
namespace App\Exceptions;
|
||||||
|
|
||||||
|
use RuntimeException;
|
||||||
use Twig\Error\Error;
|
use Twig\Error\Error;
|
||||||
|
|
||||||
class TwigModeException extends \RuntimeException
|
class TwigModeException extends RuntimeException
|
||||||
{
|
{
|
||||||
public function __construct(?Error $previous = null)
|
public function __construct(?Error $previous = null)
|
||||||
{
|
{
|
||||||
|
|
|
@ -25,6 +25,8 @@ namespace App\Form;
|
||||||
|
|
||||||
use Doctrine\Common\Collections\ArrayCollection;
|
use Doctrine\Common\Collections\ArrayCollection;
|
||||||
use Doctrine\Common\Collections\Collection;
|
use Doctrine\Common\Collections\Collection;
|
||||||
|
use ReflectionClass;
|
||||||
|
use ReflectionException;
|
||||||
use Symfony\Component\Form\AbstractTypeExtension;
|
use Symfony\Component\Form\AbstractTypeExtension;
|
||||||
use Symfony\Component\Form\Extension\Core\Type\CollectionType;
|
use Symfony\Component\Form\Extension\Core\Type\CollectionType;
|
||||||
use Symfony\Component\Form\FormBuilder;
|
use Symfony\Component\Form\FormBuilder;
|
||||||
|
@ -104,12 +106,12 @@ class CollectionTypeExtension extends AbstractTypeExtension
|
||||||
* Set the option of the form.
|
* Set the option of the form.
|
||||||
* This a bit hacky cause we access private properties....
|
* This a bit hacky cause we access private properties....
|
||||||
*
|
*
|
||||||
* @throws \ReflectionException
|
* @throws ReflectionException
|
||||||
*/
|
*/
|
||||||
public function setOption(FormBuilder $builder, string $option, $value): void
|
public function setOption(FormBuilder $builder, string $option, $value): void
|
||||||
{
|
{
|
||||||
//We have to use FormConfigBuilder::class here, because options is private and not available in sub classes
|
//We have to use FormConfigBuilder::class here, because options is private and not available in sub classes
|
||||||
$reflection = new \ReflectionClass(FormConfigBuilder::class);
|
$reflection = new ReflectionClass(FormConfigBuilder::class);
|
||||||
$property = $reflection->getProperty('options');
|
$property = $reflection->getProperty('options');
|
||||||
$property->setAccessible(true);
|
$property->setAccessible(true);
|
||||||
$tmp = $property->getValue($builder);
|
$tmp = $property->getValue($builder);
|
||||||
|
|
|
@ -47,6 +47,7 @@ use App\Entity\Base\AbstractStructuralDBElement;
|
||||||
use App\Entity\PriceInformations\Currency;
|
use App\Entity\PriceInformations\Currency;
|
||||||
use App\Services\Trees\NodesListBuilder;
|
use App\Services\Trees\NodesListBuilder;
|
||||||
use Doctrine\ORM\EntityManagerInterface;
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
|
use RuntimeException;
|
||||||
use Symfony\Component\Intl\Currencies;
|
use Symfony\Component\Intl\Currencies;
|
||||||
use Symfony\Component\OptionsResolver\Options;
|
use Symfony\Component\OptionsResolver\Options;
|
||||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||||
|
@ -96,7 +97,7 @@ class CurrencyEntityType extends StructuralEntityType
|
||||||
protected function getChoiceContent(AbstractStructuralDBElement $choice, $key, $value, $options): string
|
protected function getChoiceContent(AbstractStructuralDBElement $choice, $key, $value, $options): string
|
||||||
{
|
{
|
||||||
if(!$choice instanceof Currency) {
|
if(!$choice instanceof Currency) {
|
||||||
throw new \RuntimeException('$choice must be an instance of Currency!');
|
throw new RuntimeException('$choice must be an instance of Currency!');
|
||||||
}
|
}
|
||||||
|
|
||||||
//Generate the level spacing
|
//Generate the level spacing
|
||||||
|
|
|
@ -45,6 +45,7 @@ namespace App\Form\Type;
|
||||||
use App\Entity\Attachments\Attachment;
|
use App\Entity\Attachments\Attachment;
|
||||||
use App\Entity\Attachments\AttachmentContainingDBElement;
|
use App\Entity\Attachments\AttachmentContainingDBElement;
|
||||||
use App\Entity\Contracts\HasMasterAttachmentInterface;
|
use App\Entity\Contracts\HasMasterAttachmentInterface;
|
||||||
|
use RuntimeException;
|
||||||
use Symfony\Component\Form\AbstractType;
|
use Symfony\Component\Form\AbstractType;
|
||||||
use Symfony\Component\Form\ChoiceList\Loader\CallbackChoiceLoader;
|
use Symfony\Component\Form\ChoiceList\Loader\CallbackChoiceLoader;
|
||||||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
||||||
|
@ -85,7 +86,7 @@ class MasterPictureAttachmentType extends AbstractType
|
||||||
static function () use ($options) {
|
static function () use ($options) {
|
||||||
$entity = $options['entity'];
|
$entity = $options['entity'];
|
||||||
if (!$entity instanceof AttachmentContainingDBElement) {
|
if (!$entity instanceof AttachmentContainingDBElement) {
|
||||||
throw new \RuntimeException('$entity must have Attachments! (be of type AttachmentContainingDBElement)');
|
throw new RuntimeException('$entity must have Attachments! (be of type AttachmentContainingDBElement)');
|
||||||
}
|
}
|
||||||
|
|
||||||
return $entity->getAttachments()->toArray();
|
return $entity->getAttachments()->toArray();
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
namespace App\Helpers;
|
namespace App\Helpers;
|
||||||
|
|
||||||
use Brick\Math\BigDecimal;
|
use Brick\Math\BigDecimal;
|
||||||
|
use Brick\Math\BigNumber;
|
||||||
use Doctrine\DBAL\Platforms\AbstractPlatform;
|
use Doctrine\DBAL\Platforms\AbstractPlatform;
|
||||||
use Doctrine\DBAL\Types\Type;
|
use Doctrine\DBAL\Types\Type;
|
||||||
|
|
||||||
|
@ -36,7 +37,7 @@ class BigDecimalType extends Type
|
||||||
/**
|
/**
|
||||||
* @param string|null $value
|
* @param string|null $value
|
||||||
*
|
*
|
||||||
* @return BigDecimal|\Brick\Math\BigNumber|mixed
|
* @return BigDecimal|BigNumber|mixed
|
||||||
*/
|
*/
|
||||||
public function convertToPHPValue($value, AbstractPlatform $platform)
|
public function convertToPHPValue($value, AbstractPlatform $platform)
|
||||||
{
|
{
|
||||||
|
|
|
@ -23,9 +23,12 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Helpers;
|
namespace App\Helpers;
|
||||||
|
|
||||||
|
use DateTime;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
|
|
||||||
|
use function ord;
|
||||||
|
|
||||||
class LabelResponse extends Response
|
class LabelResponse extends Response
|
||||||
{
|
{
|
||||||
public function __construct($content = '', int $status = 200, array $headers = [])
|
public function __construct($content = '', int $status = 200, array $headers = [])
|
||||||
|
@ -63,7 +66,7 @@ class LabelResponse extends Response
|
||||||
*/
|
*/
|
||||||
public function setAutoLastModified(): LabelResponse
|
public function setAutoLastModified(): LabelResponse
|
||||||
{
|
{
|
||||||
$this->setLastModified(new \DateTime());
|
$this->setLastModified(new DateTime());
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
@ -95,7 +98,7 @@ class LabelResponse extends Response
|
||||||
for ($i = 0, $filenameLength = mb_strlen($filename, $encoding); $i < $filenameLength; ++$i) {
|
for ($i = 0, $filenameLength = mb_strlen($filename, $encoding); $i < $filenameLength; ++$i) {
|
||||||
$char = mb_substr($filename, $i, 1, $encoding);
|
$char = mb_substr($filename, $i, 1, $encoding);
|
||||||
|
|
||||||
if ('%' === $char || \ord($char) < 32 || \ord($char) > 126) {
|
if ('%' === $char || ord($char) < 32 || ord($char) > 126) {
|
||||||
$filenameFallback .= '_';
|
$filenameFallback .= '_';
|
||||||
} else {
|
} else {
|
||||||
$filenameFallback .= $char;
|
$filenameFallback .= $char;
|
||||||
|
|
|
@ -45,6 +45,7 @@ namespace App\Helpers\Trees;
|
||||||
use App\Entity\Base\AbstractStructuralDBElement;
|
use App\Entity\Base\AbstractStructuralDBElement;
|
||||||
use ArrayIterator;
|
use ArrayIterator;
|
||||||
use Doctrine\Common\Collections\Collection;
|
use Doctrine\Common\Collections\Collection;
|
||||||
|
use InvalidArgumentException;
|
||||||
use RecursiveIterator;
|
use RecursiveIterator;
|
||||||
|
|
||||||
final class StructuralDBElementIterator extends ArrayIterator implements RecursiveIterator
|
final class StructuralDBElementIterator extends ArrayIterator implements RecursiveIterator
|
||||||
|
@ -73,7 +74,7 @@ final class StructuralDBElementIterator extends ArrayIterator implements Recursi
|
||||||
} elseif ($subelements instanceof Collection) {
|
} elseif ($subelements instanceof Collection) {
|
||||||
$array = $subelements->toArray();
|
$array = $subelements->toArray();
|
||||||
} else {
|
} else {
|
||||||
throw new \InvalidArgumentException('Invalid subelements type on $element!');
|
throw new InvalidArgumentException('Invalid subelements type on $element!');
|
||||||
}
|
}
|
||||||
|
|
||||||
return new self($array);
|
return new self($array);
|
||||||
|
|
|
@ -23,6 +23,7 @@ namespace App\Repository;
|
||||||
use App\Entity\Base\AbstractPartsContainingDBElement;
|
use App\Entity\Base\AbstractPartsContainingDBElement;
|
||||||
use App\Entity\Base\PartsContainingRepositoryInterface;
|
use App\Entity\Base\PartsContainingRepositoryInterface;
|
||||||
use App\Entity\Parts\Part;
|
use App\Entity\Parts\Part;
|
||||||
|
use InvalidArgumentException;
|
||||||
|
|
||||||
abstract class AbstractPartsContainingRepository extends StructuralDBElementRepository implements PartsContainingRepositoryInterface
|
abstract class AbstractPartsContainingRepository extends StructuralDBElementRepository implements PartsContainingRepositoryInterface
|
||||||
{
|
{
|
||||||
|
@ -46,7 +47,7 @@ abstract class AbstractPartsContainingRepository extends StructuralDBElementRepo
|
||||||
protected function getPartsByField(object $element, array $order_by, string $field_name): array
|
protected function getPartsByField(object $element, array $order_by, string $field_name): array
|
||||||
{
|
{
|
||||||
if (!$element instanceof AbstractPartsContainingDBElement) {
|
if (!$element instanceof AbstractPartsContainingDBElement) {
|
||||||
throw new \InvalidArgumentException('$element must be an instance of AbstractPartContainingDBElement!');
|
throw new InvalidArgumentException('$element must be an instance of AbstractPartContainingDBElement!');
|
||||||
}
|
}
|
||||||
|
|
||||||
$repo = $this->getEntityManager()->getRepository(Part::class);
|
$repo = $this->getEntityManager()->getRepository(Part::class);
|
||||||
|
@ -57,7 +58,7 @@ abstract class AbstractPartsContainingRepository extends StructuralDBElementRepo
|
||||||
protected function getPartsCountByField(object $element, string $field_name): int
|
protected function getPartsCountByField(object $element, string $field_name): int
|
||||||
{
|
{
|
||||||
if (!$element instanceof AbstractPartsContainingDBElement) {
|
if (!$element instanceof AbstractPartsContainingDBElement) {
|
||||||
throw new \InvalidArgumentException('$element must be an instance of AbstractPartContainingDBElement!');
|
throw new InvalidArgumentException('$element must be an instance of AbstractPartContainingDBElement!');
|
||||||
}
|
}
|
||||||
|
|
||||||
$repo = $this->getEntityManager()->getRepository(Part::class);
|
$repo = $this->getEntityManager()->getRepository(Part::class);
|
||||||
|
|
|
@ -23,6 +23,9 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Repository;
|
namespace App\Repository;
|
||||||
|
|
||||||
|
use Doctrine\ORM\NonUniqueResultException;
|
||||||
|
use Doctrine\ORM\NoResultException;
|
||||||
|
|
||||||
class AttachmentRepository extends DBElementRepository
|
class AttachmentRepository extends DBElementRepository
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
@ -42,8 +45,8 @@ class AttachmentRepository extends DBElementRepository
|
||||||
/**
|
/**
|
||||||
* Gets the count of all external attachments (attachments only containing an URL).
|
* Gets the count of all external attachments (attachments only containing an URL).
|
||||||
*
|
*
|
||||||
* @throws \Doctrine\ORM\NoResultException
|
* @throws NoResultException
|
||||||
* @throws \Doctrine\ORM\NonUniqueResultException
|
* @throws NonUniqueResultException
|
||||||
*/
|
*/
|
||||||
public function getExternalAttachments(): int
|
public function getExternalAttachments(): int
|
||||||
{
|
{
|
||||||
|
@ -61,8 +64,8 @@ class AttachmentRepository extends DBElementRepository
|
||||||
/**
|
/**
|
||||||
* Gets the count of all attachments where an user uploaded an file.
|
* Gets the count of all attachments where an user uploaded an file.
|
||||||
*
|
*
|
||||||
* @throws \Doctrine\ORM\NoResultException
|
* @throws NoResultException
|
||||||
* @throws \Doctrine\ORM\NonUniqueResultException
|
* @throws NonUniqueResultException
|
||||||
*/
|
*/
|
||||||
public function getUserUploadedAttachments(): int
|
public function getUserUploadedAttachments(): int
|
||||||
{
|
{
|
||||||
|
|
|
@ -25,6 +25,7 @@ namespace App\Repository;
|
||||||
|
|
||||||
use App\Entity\Base\AbstractDBElement;
|
use App\Entity\Base\AbstractDBElement;
|
||||||
use Doctrine\ORM\EntityRepository;
|
use Doctrine\ORM\EntityRepository;
|
||||||
|
use ReflectionClass;
|
||||||
|
|
||||||
class DBElementRepository extends EntityRepository
|
class DBElementRepository extends EntityRepository
|
||||||
{
|
{
|
||||||
|
@ -68,7 +69,7 @@ class DBElementRepository extends EntityRepository
|
||||||
|
|
||||||
protected function setField(AbstractDBElement $element, string $field, int $new_value): void
|
protected function setField(AbstractDBElement $element, string $field, int $new_value): void
|
||||||
{
|
{
|
||||||
$reflection = new \ReflectionClass(get_class($element));
|
$reflection = new ReflectionClass(get_class($element));
|
||||||
$property = $reflection->getProperty($field);
|
$property = $reflection->getProperty($field);
|
||||||
$property->setAccessible(true);
|
$property->setAccessible(true);
|
||||||
$property->setValue($element, $new_value);
|
$property->setValue($element, $new_value);
|
||||||
|
|
|
@ -26,6 +26,7 @@ namespace App\Repository;
|
||||||
use App\Entity\LabelSystem\LabelOptions;
|
use App\Entity\LabelSystem\LabelOptions;
|
||||||
use App\Entity\LabelSystem\LabelProfile;
|
use App\Entity\LabelSystem\LabelProfile;
|
||||||
use App\Helpers\Trees\TreeViewNode;
|
use App\Helpers\Trees\TreeViewNode;
|
||||||
|
use InvalidArgumentException;
|
||||||
|
|
||||||
class LabelProfileRepository extends NamedDBElementRepository
|
class LabelProfileRepository extends NamedDBElementRepository
|
||||||
{
|
{
|
||||||
|
@ -36,7 +37,7 @@ class LabelProfileRepository extends NamedDBElementRepository
|
||||||
public function getDropdownProfiles(string $type): array
|
public function getDropdownProfiles(string $type): array
|
||||||
{
|
{
|
||||||
if (!in_array($type, LabelOptions::SUPPORTED_ELEMENTS, true)) {
|
if (!in_array($type, LabelOptions::SUPPORTED_ELEMENTS, true)) {
|
||||||
throw new \InvalidArgumentException('Invalid supported_element type given.');
|
throw new InvalidArgumentException('Invalid supported_element type given.');
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->findBy([
|
return $this->findBy([
|
||||||
|
@ -85,7 +86,7 @@ class LabelProfileRepository extends NamedDBElementRepository
|
||||||
public function findForSupportedElement(string $type, array $order_by = ['name' => 'ASC']): array
|
public function findForSupportedElement(string $type, array $order_by = ['name' => 'ASC']): array
|
||||||
{
|
{
|
||||||
if (!in_array($type, LabelOptions::SUPPORTED_ELEMENTS, true)) {
|
if (!in_array($type, LabelOptions::SUPPORTED_ELEMENTS, true)) {
|
||||||
throw new \InvalidArgumentException('Invalid supported_element type given.');
|
throw new InvalidArgumentException('Invalid supported_element type given.');
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->findBy(['options.supported_element' => $type], $order_by);
|
return $this->findBy(['options.supported_element' => $type], $order_by);
|
||||||
|
|
|
@ -49,6 +49,11 @@ use App\Entity\LogSystem\ElementCreatedLogEntry;
|
||||||
use App\Entity\LogSystem\ElementDeletedLogEntry;
|
use App\Entity\LogSystem\ElementDeletedLogEntry;
|
||||||
use App\Entity\LogSystem\ElementEditedLogEntry;
|
use App\Entity\LogSystem\ElementEditedLogEntry;
|
||||||
use App\Entity\UserSystem\User;
|
use App\Entity\UserSystem\User;
|
||||||
|
use DateTime;
|
||||||
|
use Doctrine\ORM\OptimisticLockException;
|
||||||
|
use Doctrine\ORM\ORMException;
|
||||||
|
use Doctrine\ORM\TransactionRequiredException;
|
||||||
|
use RuntimeException;
|
||||||
|
|
||||||
class LogEntryRepository extends DBElementRepository
|
class LogEntryRepository extends DBElementRepository
|
||||||
{
|
{
|
||||||
|
@ -108,7 +113,7 @@ class LogEntryRepository extends DBElementRepository
|
||||||
$results = $query->execute();
|
$results = $query->execute();
|
||||||
|
|
||||||
if (empty($results)) {
|
if (empty($results)) {
|
||||||
throw new \RuntimeException('No undelete data could be found for this element');
|
throw new RuntimeException('No undelete data could be found for this element');
|
||||||
}
|
}
|
||||||
|
|
||||||
return $results[0];
|
return $results[0];
|
||||||
|
@ -118,11 +123,11 @@ class LogEntryRepository extends DBElementRepository
|
||||||
* Gets all log entries that are related to time travelling.
|
* Gets all log entries that are related to time travelling.
|
||||||
*
|
*
|
||||||
* @param AbstractDBElement $element The element for which the time travel data should be retrieved
|
* @param AbstractDBElement $element The element for which the time travel data should be retrieved
|
||||||
* @param \DateTime $until Back to which timestamp should the data be get (including the timestamp)
|
* @param DateTime $until Back to which timestamp should the data be get (including the timestamp)
|
||||||
*
|
*
|
||||||
* @return AbstractLogEntry[]
|
* @return AbstractLogEntry[]
|
||||||
*/
|
*/
|
||||||
public function getTimetravelDataForElement(AbstractDBElement $element, \DateTime $until): array
|
public function getTimetravelDataForElement(AbstractDBElement $element, DateTime $until): array
|
||||||
{
|
{
|
||||||
$qb = $this->createQueryBuilder('log');
|
$qb = $this->createQueryBuilder('log');
|
||||||
$qb->select('log')
|
$qb->select('log')
|
||||||
|
@ -150,7 +155,7 @@ class LogEntryRepository extends DBElementRepository
|
||||||
*
|
*
|
||||||
* @return bool True if the element existed at the given timestamp
|
* @return bool True if the element existed at the given timestamp
|
||||||
*/
|
*/
|
||||||
public function getElementExistedAtTimestamp(AbstractDBElement $element, \DateTime $timestamp): bool
|
public function getElementExistedAtTimestamp(AbstractDBElement $element, DateTime $timestamp): bool
|
||||||
{
|
{
|
||||||
$qb = $this->createQueryBuilder('log');
|
$qb = $this->createQueryBuilder('log');
|
||||||
$qb->select('count(log)')
|
$qb->select('count(log)')
|
||||||
|
@ -190,9 +195,9 @@ class LogEntryRepository extends DBElementRepository
|
||||||
* @return AbstractDBElement|null returns the associated DBElement or null if the log either has no target or the element
|
* @return AbstractDBElement|null returns the associated DBElement or null if the log either has no target or the element
|
||||||
* was deleted from DB
|
* was deleted from DB
|
||||||
*
|
*
|
||||||
* @throws \Doctrine\ORM\ORMException
|
* @throws ORMException
|
||||||
* @throws \Doctrine\ORM\OptimisticLockException
|
* @throws OptimisticLockException
|
||||||
* @throws \Doctrine\ORM\TransactionRequiredException
|
* @throws TransactionRequiredException
|
||||||
*/
|
*/
|
||||||
public function getTargetElement(AbstractLogEntry $logEntry): ?AbstractDBElement
|
public function getTargetElement(AbstractLogEntry $logEntry): ?AbstractDBElement
|
||||||
{
|
{
|
||||||
|
|
|
@ -43,6 +43,8 @@ declare(strict_types=1);
|
||||||
namespace App\Repository;
|
namespace App\Repository;
|
||||||
|
|
||||||
use App\Entity\Parts\PartLot;
|
use App\Entity\Parts\PartLot;
|
||||||
|
use Doctrine\ORM\NonUniqueResultException;
|
||||||
|
use Doctrine\ORM\NoResultException;
|
||||||
use Doctrine\ORM\QueryBuilder;
|
use Doctrine\ORM\QueryBuilder;
|
||||||
|
|
||||||
class PartRepository extends NamedDBElementRepository
|
class PartRepository extends NamedDBElementRepository
|
||||||
|
@ -50,8 +52,8 @@ class PartRepository extends NamedDBElementRepository
|
||||||
/**
|
/**
|
||||||
* Gets the summed up instock of all parts (only parts without an measurent unit).
|
* Gets the summed up instock of all parts (only parts without an measurent unit).
|
||||||
*
|
*
|
||||||
* @throws \Doctrine\ORM\NoResultException
|
* @throws NoResultException
|
||||||
* @throws \Doctrine\ORM\NonUniqueResultException
|
* @throws NonUniqueResultException
|
||||||
*/
|
*/
|
||||||
public function getPartsInstockSum(): float
|
public function getPartsInstockSum(): float
|
||||||
{
|
{
|
||||||
|
@ -69,8 +71,8 @@ class PartRepository extends NamedDBElementRepository
|
||||||
/**
|
/**
|
||||||
* Gets the number of parts that has price informations.
|
* Gets the number of parts that has price informations.
|
||||||
*
|
*
|
||||||
* @throws \Doctrine\ORM\NoResultException
|
* @throws NoResultException
|
||||||
* @throws \Doctrine\ORM\NonUniqueResultException
|
* @throws NonUniqueResultException
|
||||||
*/
|
*/
|
||||||
public function getPartsCountWithPrice(): int
|
public function getPartsCountWithPrice(): int
|
||||||
{
|
{
|
||||||
|
|
|
@ -22,13 +22,14 @@ namespace App\Repository\Parts;
|
||||||
|
|
||||||
use App\Entity\Parts\Category;
|
use App\Entity\Parts\Category;
|
||||||
use App\Repository\AbstractPartsContainingRepository;
|
use App\Repository\AbstractPartsContainingRepository;
|
||||||
|
use InvalidArgumentException;
|
||||||
|
|
||||||
class CategoryRepository extends AbstractPartsContainingRepository
|
class CategoryRepository extends AbstractPartsContainingRepository
|
||||||
{
|
{
|
||||||
public function getParts(object $element, array $order_by = ['name' => 'ASC']): array
|
public function getParts(object $element, array $order_by = ['name' => 'ASC']): array
|
||||||
{
|
{
|
||||||
if (!$element instanceof Category) {
|
if (!$element instanceof Category) {
|
||||||
throw new \InvalidArgumentException('$element must be an Category!');
|
throw new InvalidArgumentException('$element must be an Category!');
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->getPartsByField($element, $order_by, 'category');
|
return $this->getPartsByField($element, $order_by, 'category');
|
||||||
|
@ -37,7 +38,7 @@ class CategoryRepository extends AbstractPartsContainingRepository
|
||||||
public function getPartsCount(object $element): int
|
public function getPartsCount(object $element): int
|
||||||
{
|
{
|
||||||
if (!$element instanceof Category) {
|
if (!$element instanceof Category) {
|
||||||
throw new \InvalidArgumentException('$element must be an Category!');
|
throw new InvalidArgumentException('$element must be an Category!');
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->getPartsCountByField($element, 'category');
|
return $this->getPartsCountByField($element, 'category');
|
||||||
|
|
|
@ -9,6 +9,7 @@ use App\Entity\Devices\Device;
|
||||||
use App\Entity\Parts\Category;
|
use App\Entity\Parts\Category;
|
||||||
use App\Entity\Parts\Part;
|
use App\Entity\Parts\Part;
|
||||||
use App\Repository\AbstractPartsContainingRepository;
|
use App\Repository\AbstractPartsContainingRepository;
|
||||||
|
use InvalidArgumentException;
|
||||||
|
|
||||||
class DeviceRepository extends AbstractPartsContainingRepository
|
class DeviceRepository extends AbstractPartsContainingRepository
|
||||||
{
|
{
|
||||||
|
@ -16,7 +17,7 @@ class DeviceRepository extends AbstractPartsContainingRepository
|
||||||
public function getParts(object $element, array $order_by = ['name' => 'ASC']): array
|
public function getParts(object $element, array $order_by = ['name' => 'ASC']): array
|
||||||
{
|
{
|
||||||
if (!$element instanceof Device) {
|
if (!$element instanceof Device) {
|
||||||
throw new \InvalidArgumentException('$element must be an Device!');
|
throw new InvalidArgumentException('$element must be an Device!');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -27,7 +28,7 @@ class DeviceRepository extends AbstractPartsContainingRepository
|
||||||
public function getPartsCount(object $element): int
|
public function getPartsCount(object $element): int
|
||||||
{
|
{
|
||||||
if (!$element instanceof Device) {
|
if (!$element instanceof Device) {
|
||||||
throw new \InvalidArgumentException('$element must be an Device!');
|
throw new InvalidArgumentException('$element must be an Device!');
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO: Change this later, when properly implemented devices
|
//TODO: Change this later, when properly implemented devices
|
||||||
|
|
|
@ -22,13 +22,14 @@ namespace App\Repository\Parts;
|
||||||
|
|
||||||
use App\Entity\Parts\Footprint;
|
use App\Entity\Parts\Footprint;
|
||||||
use App\Repository\AbstractPartsContainingRepository;
|
use App\Repository\AbstractPartsContainingRepository;
|
||||||
|
use InvalidArgumentException;
|
||||||
|
|
||||||
class FootprintRepository extends AbstractPartsContainingRepository
|
class FootprintRepository extends AbstractPartsContainingRepository
|
||||||
{
|
{
|
||||||
public function getParts(object $element, array $order_by = ['name' => 'ASC']): array
|
public function getParts(object $element, array $order_by = ['name' => 'ASC']): array
|
||||||
{
|
{
|
||||||
if (!$element instanceof Footprint) {
|
if (!$element instanceof Footprint) {
|
||||||
throw new \InvalidArgumentException('$element must be an Footprint!');
|
throw new InvalidArgumentException('$element must be an Footprint!');
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->getPartsByField($element, $order_by, 'footprint');
|
return $this->getPartsByField($element, $order_by, 'footprint');
|
||||||
|
@ -37,7 +38,7 @@ class FootprintRepository extends AbstractPartsContainingRepository
|
||||||
public function getPartsCount(object $element): int
|
public function getPartsCount(object $element): int
|
||||||
{
|
{
|
||||||
if (!$element instanceof Footprint) {
|
if (!$element instanceof Footprint) {
|
||||||
throw new \InvalidArgumentException('$element must be an Footprint!');
|
throw new InvalidArgumentException('$element must be an Footprint!');
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->getPartsCountByField($element, 'footprint');
|
return $this->getPartsCountByField($element, 'footprint');
|
||||||
|
|
|
@ -22,13 +22,14 @@ namespace App\Repository\Parts;
|
||||||
|
|
||||||
use App\Entity\Parts\Manufacturer;
|
use App\Entity\Parts\Manufacturer;
|
||||||
use App\Repository\AbstractPartsContainingRepository;
|
use App\Repository\AbstractPartsContainingRepository;
|
||||||
|
use InvalidArgumentException;
|
||||||
|
|
||||||
class ManufacturerRepository extends AbstractPartsContainingRepository
|
class ManufacturerRepository extends AbstractPartsContainingRepository
|
||||||
{
|
{
|
||||||
public function getParts(object $element, array $order_by = ['name' => 'ASC']): array
|
public function getParts(object $element, array $order_by = ['name' => 'ASC']): array
|
||||||
{
|
{
|
||||||
if (!$element instanceof Manufacturer) {
|
if (!$element instanceof Manufacturer) {
|
||||||
throw new \InvalidArgumentException('$element must be an Manufacturer!');
|
throw new InvalidArgumentException('$element must be an Manufacturer!');
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->getPartsByField($element, $order_by, 'manufacturer');
|
return $this->getPartsByField($element, $order_by, 'manufacturer');
|
||||||
|
@ -37,7 +38,7 @@ class ManufacturerRepository extends AbstractPartsContainingRepository
|
||||||
public function getPartsCount(object $element): int
|
public function getPartsCount(object $element): int
|
||||||
{
|
{
|
||||||
if (!$element instanceof Manufacturer) {
|
if (!$element instanceof Manufacturer) {
|
||||||
throw new \InvalidArgumentException('$element must be an Manufacturer!');
|
throw new InvalidArgumentException('$element must be an Manufacturer!');
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->getPartsCountByField($element, 'manufacturer');
|
return $this->getPartsCountByField($element, 'manufacturer');
|
||||||
|
|
|
@ -22,13 +22,14 @@ namespace App\Repository\Parts;
|
||||||
|
|
||||||
use App\Entity\Parts\MeasurementUnit;
|
use App\Entity\Parts\MeasurementUnit;
|
||||||
use App\Repository\AbstractPartsContainingRepository;
|
use App\Repository\AbstractPartsContainingRepository;
|
||||||
|
use InvalidArgumentException;
|
||||||
|
|
||||||
class MeasurementUnitRepository extends AbstractPartsContainingRepository
|
class MeasurementUnitRepository extends AbstractPartsContainingRepository
|
||||||
{
|
{
|
||||||
public function getParts(object $element, array $order_by = ['name' => 'ASC']): array
|
public function getParts(object $element, array $order_by = ['name' => 'ASC']): array
|
||||||
{
|
{
|
||||||
if (!$element instanceof MeasurementUnit) {
|
if (!$element instanceof MeasurementUnit) {
|
||||||
throw new \InvalidArgumentException('$element must be an MeasurementUnit!');
|
throw new InvalidArgumentException('$element must be an MeasurementUnit!');
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->getPartsByField($element, $order_by, 'partUnit');
|
return $this->getPartsByField($element, $order_by, 'partUnit');
|
||||||
|
@ -37,7 +38,7 @@ class MeasurementUnitRepository extends AbstractPartsContainingRepository
|
||||||
public function getPartsCount(object $element): int
|
public function getPartsCount(object $element): int
|
||||||
{
|
{
|
||||||
if (!$element instanceof MeasurementUnit) {
|
if (!$element instanceof MeasurementUnit) {
|
||||||
throw new \InvalidArgumentException('$element must be an MeasurementUnit!');
|
throw new InvalidArgumentException('$element must be an MeasurementUnit!');
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->getPartsCountByField($element, 'partUnit');
|
return $this->getPartsCountByField($element, 'partUnit');
|
||||||
|
|
|
@ -24,6 +24,7 @@ use App\Entity\Parts\Part;
|
||||||
use App\Entity\Parts\Storelocation;
|
use App\Entity\Parts\Storelocation;
|
||||||
use App\Repository\AbstractPartsContainingRepository;
|
use App\Repository\AbstractPartsContainingRepository;
|
||||||
use Doctrine\ORM\QueryBuilder;
|
use Doctrine\ORM\QueryBuilder;
|
||||||
|
use InvalidArgumentException;
|
||||||
|
|
||||||
class StorelocationRepository extends AbstractPartsContainingRepository
|
class StorelocationRepository extends AbstractPartsContainingRepository
|
||||||
{
|
{
|
||||||
|
@ -33,7 +34,7 @@ class StorelocationRepository extends AbstractPartsContainingRepository
|
||||||
public function getParts(object $element, array $order_by = ['name' => 'ASC']): array
|
public function getParts(object $element, array $order_by = ['name' => 'ASC']): array
|
||||||
{
|
{
|
||||||
if (!$element instanceof Storelocation) {
|
if (!$element instanceof Storelocation) {
|
||||||
throw new \InvalidArgumentException('$element must be an Storelocation!');
|
throw new InvalidArgumentException('$element must be an Storelocation!');
|
||||||
}
|
}
|
||||||
|
|
||||||
$qb = new QueryBuilder($this->getEntityManager());
|
$qb = new QueryBuilder($this->getEntityManager());
|
||||||
|
@ -54,7 +55,7 @@ class StorelocationRepository extends AbstractPartsContainingRepository
|
||||||
public function getPartsCount(object $element): int
|
public function getPartsCount(object $element): int
|
||||||
{
|
{
|
||||||
if (!$element instanceof Storelocation) {
|
if (!$element instanceof Storelocation) {
|
||||||
throw new \InvalidArgumentException('$element must be an Storelocation!');
|
throw new InvalidArgumentException('$element must be an Storelocation!');
|
||||||
}
|
}
|
||||||
|
|
||||||
$qb = new QueryBuilder($this->getEntityManager());
|
$qb = new QueryBuilder($this->getEntityManager());
|
||||||
|
|
|
@ -24,13 +24,14 @@ use App\Entity\Parts\Part;
|
||||||
use App\Entity\Parts\Supplier;
|
use App\Entity\Parts\Supplier;
|
||||||
use App\Repository\AbstractPartsContainingRepository;
|
use App\Repository\AbstractPartsContainingRepository;
|
||||||
use Doctrine\ORM\QueryBuilder;
|
use Doctrine\ORM\QueryBuilder;
|
||||||
|
use InvalidArgumentException;
|
||||||
|
|
||||||
class SupplierRepository extends AbstractPartsContainingRepository
|
class SupplierRepository extends AbstractPartsContainingRepository
|
||||||
{
|
{
|
||||||
public function getParts(object $element, array $order_by = ['name' => 'ASC']): array
|
public function getParts(object $element, array $order_by = ['name' => 'ASC']): array
|
||||||
{
|
{
|
||||||
if (!$element instanceof Supplier) {
|
if (!$element instanceof Supplier) {
|
||||||
throw new \InvalidArgumentException('$element must be an Supplier!');
|
throw new InvalidArgumentException('$element must be an Supplier!');
|
||||||
}
|
}
|
||||||
|
|
||||||
$qb = new QueryBuilder($this->getEntityManager());
|
$qb = new QueryBuilder($this->getEntityManager());
|
||||||
|
@ -51,7 +52,7 @@ class SupplierRepository extends AbstractPartsContainingRepository
|
||||||
public function getPartsCount(object $element): int
|
public function getPartsCount(object $element): int
|
||||||
{
|
{
|
||||||
if (!$element instanceof Supplier) {
|
if (!$element instanceof Supplier) {
|
||||||
throw new \InvalidArgumentException('$element must be an Supplier!');
|
throw new InvalidArgumentException('$element must be an Supplier!');
|
||||||
}
|
}
|
||||||
|
|
||||||
$qb = new QueryBuilder($this->getEntityManager());
|
$qb = new QueryBuilder($this->getEntityManager());
|
||||||
|
|
|
@ -63,6 +63,7 @@ use App\Entity\UserSystem\Group;
|
||||||
use App\Entity\UserSystem\User;
|
use App\Entity\UserSystem\User;
|
||||||
use App\Exceptions\EntityNotSupportedException;
|
use App\Exceptions\EntityNotSupportedException;
|
||||||
use App\Services\Attachments\AttachmentURLGenerator;
|
use App\Services\Attachments\AttachmentURLGenerator;
|
||||||
|
use DateTime;
|
||||||
use function array_key_exists;
|
use function array_key_exists;
|
||||||
use function get_class;
|
use function get_class;
|
||||||
use InvalidArgumentException;
|
use InvalidArgumentException;
|
||||||
|
@ -128,7 +129,7 @@ class EntityURLGenerator
|
||||||
/**
|
/**
|
||||||
* Gets the URL to view the given element at a given timestamp.
|
* Gets the URL to view the given element at a given timestamp.
|
||||||
*/
|
*/
|
||||||
public function timeTravelURL(AbstractDBElement $entity, \DateTime $dateTime): string
|
public function timeTravelURL(AbstractDBElement $entity, DateTime $dateTime): string
|
||||||
{
|
{
|
||||||
$map = [
|
$map = [
|
||||||
Part::class => 'part_info',
|
Part::class => 'part_info',
|
||||||
|
|
|
@ -26,6 +26,7 @@ namespace App\Services\LabelSystem;
|
||||||
use App\Entity\LabelSystem\LabelOptions;
|
use App\Entity\LabelSystem\LabelOptions;
|
||||||
use App\Services\LabelSystem\Barcodes\BarcodeContentGenerator;
|
use App\Services\LabelSystem\Barcodes\BarcodeContentGenerator;
|
||||||
use Com\Tecnick\Barcode\Barcode;
|
use Com\Tecnick\Barcode\Barcode;
|
||||||
|
use InvalidArgumentException;
|
||||||
|
|
||||||
final class BarcodeGenerator
|
final class BarcodeGenerator
|
||||||
{
|
{
|
||||||
|
@ -64,7 +65,7 @@ final class BarcodeGenerator
|
||||||
case 'none':
|
case 'none':
|
||||||
return null;
|
return null;
|
||||||
default:
|
default:
|
||||||
throw new \InvalidArgumentException('Unknown label type!');
|
throw new InvalidArgumentException('Unknown label type!');
|
||||||
}
|
}
|
||||||
|
|
||||||
$bobj = $barcode->getBarcodeObj($type, $this->getContent($options, $target));
|
$bobj = $barcode->getBarcodeObj($type, $this->getContent($options, $target));
|
||||||
|
@ -85,7 +86,7 @@ final class BarcodeGenerator
|
||||||
case 'none':
|
case 'none':
|
||||||
return null;
|
return null;
|
||||||
default:
|
default:
|
||||||
throw new \InvalidArgumentException('Unknown label type!');
|
throw new InvalidArgumentException('Unknown label type!');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,6 +27,7 @@ use App\Entity\Base\AbstractDBElement;
|
||||||
use App\Entity\Parts\Part;
|
use App\Entity\Parts\Part;
|
||||||
use App\Entity\Parts\PartLot;
|
use App\Entity\Parts\PartLot;
|
||||||
use App\Entity\Parts\Storelocation;
|
use App\Entity\Parts\Storelocation;
|
||||||
|
use InvalidArgumentException;
|
||||||
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
|
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
|
||||||
|
|
||||||
final class BarcodeContentGenerator
|
final class BarcodeContentGenerator
|
||||||
|
@ -88,6 +89,6 @@ final class BarcodeContentGenerator
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new \InvalidArgumentException('Unknown object class '.get_class($target));
|
throw new InvalidArgumentException('Unknown object class '.get_class($target));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,6 +30,9 @@ use App\Entity\Parts\Manufacturer;
|
||||||
use App\Entity\Parts\Part;
|
use App\Entity\Parts\Part;
|
||||||
use App\Entity\Parts\PartLot;
|
use App\Entity\Parts\PartLot;
|
||||||
use App\Entity\Parts\Storelocation;
|
use App\Entity\Parts\Storelocation;
|
||||||
|
use DateTime;
|
||||||
|
use InvalidArgumentException;
|
||||||
|
use ReflectionClass;
|
||||||
|
|
||||||
final class BarcodeExampleElementsGenerator
|
final class BarcodeExampleElementsGenerator
|
||||||
{
|
{
|
||||||
|
@ -43,7 +46,7 @@ final class BarcodeExampleElementsGenerator
|
||||||
case 'storelocation':
|
case 'storelocation':
|
||||||
return $this->getStorelocation();
|
return $this->getStorelocation();
|
||||||
default:
|
default:
|
||||||
throw new \InvalidArgumentException('Unknown $type.');
|
throw new InvalidArgumentException('Unknown $type.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,7 +81,7 @@ final class BarcodeExampleElementsGenerator
|
||||||
|
|
||||||
$lot->setDescription('Example Lot');
|
$lot->setDescription('Example Lot');
|
||||||
$lot->setComment('Lot comment');
|
$lot->setComment('Lot comment');
|
||||||
$lot->setExpirationDate(new \DateTime('+1 days'));
|
$lot->setExpirationDate(new DateTime('+1 days'));
|
||||||
$lot->setStorageLocation($this->getStructuralData(Storelocation::class));
|
$lot->setStorageLocation($this->getStructuralData(Storelocation::class));
|
||||||
$lot->setAmount(123);
|
$lot->setAmount(123);
|
||||||
|
|
||||||
|
@ -103,7 +106,7 @@ final class BarcodeExampleElementsGenerator
|
||||||
private function getStructuralData(string $class): AbstractStructuralDBElement
|
private function getStructuralData(string $class): AbstractStructuralDBElement
|
||||||
{
|
{
|
||||||
if (!is_a($class, AbstractStructuralDBElement::class, true)) {
|
if (!is_a($class, AbstractStructuralDBElement::class, true)) {
|
||||||
throw new \InvalidArgumentException('$class must be an child of AbstractStructuralDBElement');
|
throw new InvalidArgumentException('$class must be an child of AbstractStructuralDBElement');
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @var AbstractStructuralDBElement $parent */
|
/** @var AbstractStructuralDBElement $parent */
|
||||||
|
@ -112,7 +115,7 @@ final class BarcodeExampleElementsGenerator
|
||||||
|
|
||||||
/** @var AbstractStructuralDBElement $child */
|
/** @var AbstractStructuralDBElement $child */
|
||||||
$child = new $class();
|
$child = new $class();
|
||||||
$child->setName((new \ReflectionClass($class))->getShortName());
|
$child->setName((new ReflectionClass($class))->getShortName());
|
||||||
$child->setParent($parent);
|
$child->setParent($parent);
|
||||||
|
|
||||||
return $child;
|
return $child;
|
||||||
|
|
|
@ -23,6 +23,8 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Services\LabelSystem\Barcodes;
|
namespace App\Services\LabelSystem\Barcodes;
|
||||||
|
|
||||||
|
use InvalidArgumentException;
|
||||||
|
|
||||||
final class BarcodeNormalizer
|
final class BarcodeNormalizer
|
||||||
{
|
{
|
||||||
private const PREFIX_TYPE_MAP = [
|
private const PREFIX_TYPE_MAP = [
|
||||||
|
@ -54,7 +56,7 @@ final class BarcodeNormalizer
|
||||||
$id = (int) $matches[2];
|
$id = (int) $matches[2];
|
||||||
|
|
||||||
if (!isset(self::PREFIX_TYPE_MAP[$prefix])) {
|
if (!isset(self::PREFIX_TYPE_MAP[$prefix])) {
|
||||||
throw new \InvalidArgumentException('Unknown prefix '.$prefix);
|
throw new InvalidArgumentException('Unknown prefix '.$prefix);
|
||||||
}
|
}
|
||||||
|
|
||||||
return [self::PREFIX_TYPE_MAP[$prefix], $id];
|
return [self::PREFIX_TYPE_MAP[$prefix], $id];
|
||||||
|
@ -66,7 +68,7 @@ final class BarcodeNormalizer
|
||||||
$id = (int) $matches[2];
|
$id = (int) $matches[2];
|
||||||
|
|
||||||
if (!isset(self::PREFIX_TYPE_MAP[$prefix])) {
|
if (!isset(self::PREFIX_TYPE_MAP[$prefix])) {
|
||||||
throw new \InvalidArgumentException('Unknown prefix '.$prefix);
|
throw new InvalidArgumentException('Unknown prefix '.$prefix);
|
||||||
}
|
}
|
||||||
|
|
||||||
return [self::PREFIX_TYPE_MAP[$prefix], $id];
|
return [self::PREFIX_TYPE_MAP[$prefix], $id];
|
||||||
|
@ -82,6 +84,6 @@ final class BarcodeNormalizer
|
||||||
return ['part', (int) $matches[1]];
|
return ['part', (int) $matches[1]];
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new \InvalidArgumentException('Unknown barcode format!');
|
throw new InvalidArgumentException('Unknown barcode format!');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,6 +26,7 @@ namespace App\Services\LabelSystem\Barcodes;
|
||||||
use App\Entity\Parts\PartLot;
|
use App\Entity\Parts\PartLot;
|
||||||
use Doctrine\ORM\EntityManagerInterface;
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
use Doctrine\ORM\EntityNotFoundException;
|
use Doctrine\ORM\EntityNotFoundException;
|
||||||
|
use InvalidArgumentException;
|
||||||
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
|
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
|
||||||
|
|
||||||
final class BarcodeRedirector
|
final class BarcodeRedirector
|
||||||
|
@ -67,7 +68,7 @@ final class BarcodeRedirector
|
||||||
return $this->urlGenerator->generate('part_list_store_location', ['id' => $id]);
|
return $this->urlGenerator->generate('part_list_store_location', ['id' => $id]);
|
||||||
|
|
||||||
default:
|
default:
|
||||||
throw new \InvalidArgumentException('Unknown $type: '.$type);
|
throw new InvalidArgumentException('Unknown $type: '.$type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,6 +28,7 @@ use App\Entity\Parts\Part;
|
||||||
use App\Entity\Parts\PartLot;
|
use App\Entity\Parts\PartLot;
|
||||||
use App\Entity\Parts\Storelocation;
|
use App\Entity\Parts\Storelocation;
|
||||||
use Dompdf\Dompdf;
|
use Dompdf\Dompdf;
|
||||||
|
use InvalidArgumentException;
|
||||||
|
|
||||||
final class LabelGenerator
|
final class LabelGenerator
|
||||||
{
|
{
|
||||||
|
@ -52,7 +53,7 @@ final class LabelGenerator
|
||||||
public function generateLabel(LabelOptions $options, $elements): string
|
public function generateLabel(LabelOptions $options, $elements): string
|
||||||
{
|
{
|
||||||
if (!is_array($elements) && !is_object($elements)) {
|
if (!is_array($elements) && !is_object($elements)) {
|
||||||
throw new \InvalidArgumentException('$element must be an object or an array of objects!');
|
throw new InvalidArgumentException('$element must be an object or an array of objects!');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!is_array($elements)) {
|
if (!is_array($elements)) {
|
||||||
|
@ -61,7 +62,7 @@ final class LabelGenerator
|
||||||
|
|
||||||
foreach ($elements as $element) {
|
foreach ($elements as $element) {
|
||||||
if (!$this->supports($options, $element)) {
|
if (!$this->supports($options, $element)) {
|
||||||
throw new \InvalidArgumentException('The given options are not compatible with the given element!');
|
throw new InvalidArgumentException('The given options are not compatible with the given element!');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -80,7 +81,7 @@ final class LabelGenerator
|
||||||
{
|
{
|
||||||
$supported_type = $options->getSupportedElement();
|
$supported_type = $options->getSupportedElement();
|
||||||
if (!isset(static::CLASS_SUPPORT_MAPPING[$supported_type])) {
|
if (!isset(static::CLASS_SUPPORT_MAPPING[$supported_type])) {
|
||||||
throw new \InvalidArgumentException('Supported type name of the Label options not known!');
|
throw new InvalidArgumentException('Supported type name of the Label options not known!');
|
||||||
}
|
}
|
||||||
|
|
||||||
return is_a($element, static::CLASS_SUPPORT_MAPPING[$supported_type]);
|
return is_a($element, static::CLASS_SUPPORT_MAPPING[$supported_type]);
|
||||||
|
|
|
@ -27,6 +27,7 @@ use App\Entity\Contracts\NamedElementInterface;
|
||||||
use App\Entity\LabelSystem\LabelOptions;
|
use App\Entity\LabelSystem\LabelOptions;
|
||||||
use App\Exceptions\TwigModeException;
|
use App\Exceptions\TwigModeException;
|
||||||
use App\Services\ElementTypeNameGenerator;
|
use App\Services\ElementTypeNameGenerator;
|
||||||
|
use InvalidArgumentException;
|
||||||
use Symfony\Component\Security\Core\Security;
|
use Symfony\Component\Security\Core\Security;
|
||||||
use Twig\Environment;
|
use Twig\Environment;
|
||||||
use Twig\Error\Error;
|
use Twig\Error\Error;
|
||||||
|
@ -56,7 +57,7 @@ final class LabelHTMLGenerator
|
||||||
public function getLabelHTML(LabelOptions $options, array $elements): string
|
public function getLabelHTML(LabelOptions $options, array $elements): string
|
||||||
{
|
{
|
||||||
if (empty($elements)) {
|
if (empty($elements)) {
|
||||||
throw new \InvalidArgumentException('$elements must not be empty');
|
throw new InvalidArgumentException('$elements must not be empty');
|
||||||
}
|
}
|
||||||
|
|
||||||
$twig_elements = [];
|
$twig_elements = [];
|
||||||
|
|
|
@ -24,6 +24,7 @@ declare(strict_types=1);
|
||||||
namespace App\Services\LabelSystem\PlaceholderProviders;
|
namespace App\Services\LabelSystem\PlaceholderProviders;
|
||||||
|
|
||||||
use App\Entity\UserSystem\User;
|
use App\Entity\UserSystem\User;
|
||||||
|
use DateTime;
|
||||||
use IntlDateFormatter;
|
use IntlDateFormatter;
|
||||||
use Locale;
|
use Locale;
|
||||||
use Symfony\Component\Security\Core\Security;
|
use Symfony\Component\Security\Core\Security;
|
||||||
|
@ -65,7 +66,7 @@ final class GlobalProviders implements PlaceholderProviderInterface
|
||||||
return 'anonymous';
|
return 'anonymous';
|
||||||
}
|
}
|
||||||
|
|
||||||
$now = new \DateTime();
|
$now = new DateTime();
|
||||||
|
|
||||||
if ('[[DATETIME]]' === $placeholder) {
|
if ('[[DATETIME]]' === $placeholder) {
|
||||||
$formatter = IntlDateFormatter::create(
|
$formatter = IntlDateFormatter::create(
|
||||||
|
|
|
@ -25,6 +25,7 @@ namespace App\Services\LabelSystem\PlaceholderProviders;
|
||||||
|
|
||||||
use App\Entity\Parts\Part;
|
use App\Entity\Parts\Part;
|
||||||
use App\Services\SIFormatter;
|
use App\Services\SIFormatter;
|
||||||
|
use Parsedown;
|
||||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||||
|
|
||||||
final class PartProvider implements PlaceholderProviderInterface
|
final class PartProvider implements PlaceholderProviderInterface
|
||||||
|
@ -88,7 +89,7 @@ final class PartProvider implements PlaceholderProviderInterface
|
||||||
return $this->translator->trans('m_status.'.$part->getManufacturingStatus());
|
return $this->translator->trans('m_status.'.$part->getManufacturingStatus());
|
||||||
}
|
}
|
||||||
|
|
||||||
$parsedown = new \Parsedown();
|
$parsedown = new Parsedown();
|
||||||
|
|
||||||
if ('[[DESCRIPTION]]' === $placeholder) {
|
if ('[[DESCRIPTION]]' === $placeholder) {
|
||||||
return $parsedown->line($part->getDescription());
|
return $parsedown->line($part->getDescription());
|
||||||
|
|
|
@ -24,6 +24,7 @@ declare(strict_types=1);
|
||||||
namespace App\Services\LabelSystem\PlaceholderProviders;
|
namespace App\Services\LabelSystem\PlaceholderProviders;
|
||||||
|
|
||||||
use App\Entity\Contracts\TimeStampableInterface;
|
use App\Entity\Contracts\TimeStampableInterface;
|
||||||
|
use DateTime;
|
||||||
use IntlDateFormatter;
|
use IntlDateFormatter;
|
||||||
use Locale;
|
use Locale;
|
||||||
|
|
||||||
|
@ -35,11 +36,11 @@ final class TimestampableElementProvider implements PlaceholderProviderInterface
|
||||||
$formatter = new IntlDateFormatter(Locale::getDefault(), IntlDateFormatter::SHORT, IntlDateFormatter::SHORT);
|
$formatter = new IntlDateFormatter(Locale::getDefault(), IntlDateFormatter::SHORT, IntlDateFormatter::SHORT);
|
||||||
|
|
||||||
if ('[[LAST_MODIFIED]]' === $placeholder) {
|
if ('[[LAST_MODIFIED]]' === $placeholder) {
|
||||||
return $formatter->format($label_target->getLastModified() ?? new \DateTime());
|
return $formatter->format($label_target->getLastModified() ?? new DateTime());
|
||||||
}
|
}
|
||||||
|
|
||||||
if ('[[CREATION_DATE]]' === $placeholder) {
|
if ('[[CREATION_DATE]]' === $placeholder) {
|
||||||
return $formatter->format($label_target->getAddedDate() ?? new \DateTime());
|
return $formatter->format($label_target->getAddedDate() ?? new DateTime());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -43,9 +43,11 @@ use App\Entity\PriceInformations\Pricedetail;
|
||||||
use App\Entity\UserSystem\User;
|
use App\Entity\UserSystem\User;
|
||||||
use App\Twig\AppExtension;
|
use App\Twig\AppExtension;
|
||||||
use App\Twig\Sandbox\InheritanceSecurityPolicy;
|
use App\Twig\Sandbox\InheritanceSecurityPolicy;
|
||||||
|
use InvalidArgumentException;
|
||||||
use Twig\Environment;
|
use Twig\Environment;
|
||||||
use Twig\Extension\SandboxExtension;
|
use Twig\Extension\SandboxExtension;
|
||||||
use Twig\Extra\Intl\IntlExtension;
|
use Twig\Extra\Intl\IntlExtension;
|
||||||
|
use Twig\Loader\ArrayLoader;
|
||||||
use Twig\Sandbox\SecurityPolicyInterface;
|
use Twig\Sandbox\SecurityPolicyInterface;
|
||||||
|
|
||||||
final class SandboxedTwigProvider
|
final class SandboxedTwigProvider
|
||||||
|
@ -104,10 +106,10 @@ final class SandboxedTwigProvider
|
||||||
public function getTwig(LabelOptions $options): Environment
|
public function getTwig(LabelOptions $options): Environment
|
||||||
{
|
{
|
||||||
if ('twig' !== $options->getLinesMode()) {
|
if ('twig' !== $options->getLinesMode()) {
|
||||||
throw new \InvalidArgumentException('The LabelOptions must explicitly allow twig via lines_mode = "twig"!');
|
throw new InvalidArgumentException('The LabelOptions must explicitly allow twig via lines_mode = "twig"!');
|
||||||
}
|
}
|
||||||
|
|
||||||
$loader = new \Twig\Loader\ArrayLoader([
|
$loader = new ArrayLoader([
|
||||||
'lines' => $options->getLines(),
|
'lines' => $options->getLines(),
|
||||||
]);
|
]);
|
||||||
$twig = new Environment($loader);
|
$twig = new Environment($loader);
|
||||||
|
|
|
@ -24,6 +24,7 @@ declare(strict_types=1);
|
||||||
namespace App\Services\LogSystem;
|
namespace App\Services\LogSystem;
|
||||||
|
|
||||||
use App\Entity\LogSystem\AbstractLogEntry;
|
use App\Entity\LogSystem\AbstractLogEntry;
|
||||||
|
use InvalidArgumentException;
|
||||||
|
|
||||||
class EventUndoHelper
|
class EventUndoHelper
|
||||||
{
|
{
|
||||||
|
@ -44,7 +45,7 @@ class EventUndoHelper
|
||||||
public function setMode(string $mode): void
|
public function setMode(string $mode): void
|
||||||
{
|
{
|
||||||
if (!in_array($mode, self::ALLOWED_MODES, true)) {
|
if (!in_array($mode, self::ALLOWED_MODES, true)) {
|
||||||
throw new \InvalidArgumentException('Invalid mode passed!');
|
throw new InvalidArgumentException('Invalid mode passed!');
|
||||||
}
|
}
|
||||||
$this->mode = $mode;
|
$this->mode = $mode;
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,6 +26,7 @@ namespace App\Services\LogSystem;
|
||||||
use App\Entity\Attachments\AttachmentContainingDBElement;
|
use App\Entity\Attachments\AttachmentContainingDBElement;
|
||||||
use App\Entity\Base\AbstractDBElement;
|
use App\Entity\Base\AbstractDBElement;
|
||||||
use App\Entity\Base\AbstractStructuralDBElement;
|
use App\Entity\Base\AbstractStructuralDBElement;
|
||||||
|
use App\Entity\Parameters\AbstractParameter;
|
||||||
use App\Entity\Parts\Part;
|
use App\Entity\Parts\Part;
|
||||||
|
|
||||||
class HistoryHelper
|
class HistoryHelper
|
||||||
|
@ -38,7 +39,7 @@ class HistoryHelper
|
||||||
* Returns an array containing all elements that are associated with the argument.
|
* Returns an array containing all elements that are associated with the argument.
|
||||||
* The returned array contains the given element.
|
* The returned array contains the given element.
|
||||||
*
|
*
|
||||||
* @psalm-return array<\App\Entity\Parameters\AbstractParameter|array-key, mixed>
|
* @psalm-return array<AbstractParameter|array-key, mixed>
|
||||||
*/
|
*/
|
||||||
public function getAssociatedElements(AbstractDBElement $element): array
|
public function getAssociatedElements(AbstractDBElement $element): array
|
||||||
{
|
{
|
||||||
|
|
|
@ -33,9 +33,14 @@ use App\Entity\LogSystem\AbstractLogEntry;
|
||||||
use App\Entity\LogSystem\CollectionElementDeleted;
|
use App\Entity\LogSystem\CollectionElementDeleted;
|
||||||
use App\Entity\LogSystem\ElementEditedLogEntry;
|
use App\Entity\LogSystem\ElementEditedLogEntry;
|
||||||
use Brick\Math\BigDecimal;
|
use Brick\Math\BigDecimal;
|
||||||
|
use DateTime;
|
||||||
use Doctrine\Common\Collections\Collection;
|
use Doctrine\Common\Collections\Collection;
|
||||||
use Doctrine\ORM\EntityManagerInterface;
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
use Doctrine\ORM\Mapping\ClassMetadata;
|
use Doctrine\ORM\Mapping\ClassMetadata;
|
||||||
|
use Doctrine\ORM\Mapping\MappingException;
|
||||||
|
use Exception;
|
||||||
|
use InvalidArgumentException;
|
||||||
|
use ReflectionClass;
|
||||||
|
|
||||||
class TimeTravel
|
class TimeTravel
|
||||||
{
|
{
|
||||||
|
@ -74,16 +79,16 @@ class TimeTravel
|
||||||
*
|
*
|
||||||
* @param AbstractLogEntry[] $reverted_elements
|
* @param AbstractLogEntry[] $reverted_elements
|
||||||
*
|
*
|
||||||
* @throws \Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function revertEntityToTimestamp(AbstractDBElement $element, \DateTime $timestamp, array $reverted_elements = []): void
|
public function revertEntityToTimestamp(AbstractDBElement $element, DateTime $timestamp, array $reverted_elements = []): void
|
||||||
{
|
{
|
||||||
if (!$element instanceof TimeStampableInterface) {
|
if (!$element instanceof TimeStampableInterface) {
|
||||||
throw new \InvalidArgumentException('$element must have a Timestamp!');
|
throw new InvalidArgumentException('$element must have a Timestamp!');
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($timestamp > new \DateTime('now')) {
|
if ($timestamp > new DateTime('now')) {
|
||||||
throw new \InvalidArgumentException('You can not travel to the future (yet)...');
|
throw new InvalidArgumentException('You can not travel to the future (yet)...');
|
||||||
}
|
}
|
||||||
|
|
||||||
//Skip this process if already were reverted...
|
//Skip this process if already were reverted...
|
||||||
|
@ -168,7 +173,7 @@ class TimeTravel
|
||||||
/**
|
/**
|
||||||
* Apply the changeset in the given LogEntry to the element.
|
* Apply the changeset in the given LogEntry to the element.
|
||||||
*
|
*
|
||||||
* @throws \Doctrine\ORM\Mapping\MappingException
|
* @throws MappingException
|
||||||
*/
|
*/
|
||||||
public function applyEntry(AbstractDBElement $element, TimeTravelInterface $logEntry): void
|
public function applyEntry(AbstractDBElement $element, TimeTravelInterface $logEntry): void
|
||||||
{
|
{
|
||||||
|
@ -207,7 +212,7 @@ class TimeTravel
|
||||||
|
|
||||||
protected function getField(AbstractDBElement $element, string $field)
|
protected function getField(AbstractDBElement $element, string $field)
|
||||||
{
|
{
|
||||||
$reflection = new \ReflectionClass(get_class($element));
|
$reflection = new ReflectionClass(get_class($element));
|
||||||
$property = $reflection->getProperty($field);
|
$property = $reflection->getProperty($field);
|
||||||
$property->setAccessible(true);
|
$property->setAccessible(true);
|
||||||
|
|
||||||
|
@ -215,11 +220,11 @@ class TimeTravel
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param \DateTime|int|null $new_value
|
* @param DateTime|int|null $new_value
|
||||||
*/
|
*/
|
||||||
protected function setField(AbstractDBElement $element, string $field, $new_value): void
|
protected function setField(AbstractDBElement $element, string $field, $new_value): void
|
||||||
{
|
{
|
||||||
$reflection = new \ReflectionClass(get_class($element));
|
$reflection = new ReflectionClass(get_class($element));
|
||||||
$property = $reflection->getProperty($field);
|
$property = $reflection->getProperty($field);
|
||||||
$property->setAccessible(true);
|
$property->setAccessible(true);
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,8 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Services\Misc;
|
namespace App\Services\Misc;
|
||||||
|
|
||||||
|
use InvalidArgumentException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This Parser allows to parse number ranges like 1-3, 4, 5.
|
* This Parser allows to parse number ranges like 1-3, 4, 5.
|
||||||
*/
|
*/
|
||||||
|
@ -53,7 +55,7 @@ class RangeParser
|
||||||
} elseif (empty($number)) { //Allow empty tokens
|
} elseif (empty($number)) { //Allow empty tokens
|
||||||
continue;
|
continue;
|
||||||
} else {
|
} else {
|
||||||
throw new \InvalidArgumentException('Invalid range encoutered: '.$number);
|
throw new InvalidArgumentException('Invalid range encoutered: '.$number);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -74,7 +76,7 @@ class RangeParser
|
||||||
$this->parse($range_str);
|
$this->parse($range_str);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
} catch (\InvalidArgumentException $exception) {
|
} catch (InvalidArgumentException $exception) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -74,9 +74,9 @@ class MoneyFormatter
|
||||||
|
|
||||||
$number_formatter = new NumberFormatter($this->locale, NumberFormatter::CURRENCY);
|
$number_formatter = new NumberFormatter($this->locale, NumberFormatter::CURRENCY);
|
||||||
if ($show_all_digits) {
|
if ($show_all_digits) {
|
||||||
$number_formatter->setAttribute(\NumberFormatter::FRACTION_DIGITS, $decimals);
|
$number_formatter->setAttribute(NumberFormatter::FRACTION_DIGITS, $decimals);
|
||||||
} else {
|
} else {
|
||||||
$number_formatter->setAttribute(\NumberFormatter::MAX_FRACTION_DIGITS, $decimals);
|
$number_formatter->setAttribute(NumberFormatter::MAX_FRACTION_DIGITS, $decimals);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $number_formatter->formatCurrency((float) $value, $iso_code);
|
return $number_formatter->formatCurrency((float) $value, $iso_code);
|
||||||
|
|
|
@ -25,6 +25,9 @@ namespace App\Services\Parameters;
|
||||||
|
|
||||||
use App\Entity\Parameters\AbstractParameter;
|
use App\Entity\Parameters\AbstractParameter;
|
||||||
use App\Entity\Parameters\PartParameter;
|
use App\Entity\Parameters\PartParameter;
|
||||||
|
use InvalidArgumentException;
|
||||||
|
|
||||||
|
use function preg_match;
|
||||||
|
|
||||||
class ParameterExtractor
|
class ParameterExtractor
|
||||||
{
|
{
|
||||||
|
@ -41,7 +44,7 @@ class ParameterExtractor
|
||||||
public function extractParameters(string $input, string $class = PartParameter::class): array
|
public function extractParameters(string $input, string $class = PartParameter::class): array
|
||||||
{
|
{
|
||||||
if (!is_a($class, AbstractParameter::class, true)) {
|
if (!is_a($class, AbstractParameter::class, true)) {
|
||||||
throw new \InvalidArgumentException('$class must be a child class of AbstractParameter!');
|
throw new InvalidArgumentException('$class must be a child class of AbstractParameter!');
|
||||||
}
|
}
|
||||||
|
|
||||||
//Restrict search length
|
//Restrict search length
|
||||||
|
@ -67,7 +70,7 @@ class ParameterExtractor
|
||||||
$regex = '/^(.*) *(?:=|:) *(.+)/u';
|
$regex = '/^(.*) *(?:=|:) *(.+)/u';
|
||||||
|
|
||||||
$matches = [];
|
$matches = [];
|
||||||
\preg_match($regex, $input, $matches);
|
preg_match($regex, $input, $matches);
|
||||||
if (!empty($matches)) {
|
if (!empty($matches)) {
|
||||||
[, $name, $value] = $matches;
|
[, $name, $value] = $matches;
|
||||||
$value = trim($value);
|
$value = trim($value);
|
||||||
|
|
|
@ -28,6 +28,7 @@ use App\Entity\Parts\Part;
|
||||||
use App\Repository\DBElementRepository;
|
use App\Repository\DBElementRepository;
|
||||||
use App\Repository\PartRepository;
|
use App\Repository\PartRepository;
|
||||||
use Doctrine\ORM\EntityManagerInterface;
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
|
use InvalidArgumentException;
|
||||||
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
|
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
|
||||||
use Symfony\Component\Security\Core\Security;
|
use Symfony\Component\Security\Core\Security;
|
||||||
|
|
||||||
|
@ -67,7 +68,7 @@ final class PartsTableActionHandler
|
||||||
//Iterate over the parts and apply the action to it:
|
//Iterate over the parts and apply the action to it:
|
||||||
foreach ($selected_parts as $part) {
|
foreach ($selected_parts as $part) {
|
||||||
if (!$part instanceof Part) {
|
if (!$part instanceof Part) {
|
||||||
throw new \InvalidArgumentException('$selected_parts must be an array of Part elements!');
|
throw new InvalidArgumentException('$selected_parts must be an array of Part elements!');
|
||||||
}
|
}
|
||||||
|
|
||||||
//We modify parts, so you have to have the permission to modify it
|
//We modify parts, so you have to have the permission to modify it
|
||||||
|
@ -102,7 +103,7 @@ final class PartsTableActionHandler
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
throw new \InvalidArgumentException('The given action is unknown! ('.$action.')');
|
throw new InvalidArgumentException('The given action is unknown! ('.$action.')');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,15 +43,14 @@ declare(strict_types=1);
|
||||||
namespace App\Services;
|
namespace App\Services;
|
||||||
|
|
||||||
use App\Entity\UserSystem\User;
|
use App\Entity\UserSystem\User;
|
||||||
|
use DateTime;
|
||||||
use Doctrine\ORM\EntityManagerInterface;
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
use Symfony\Bridge\Twig\Mime\TemplatedEmail;
|
use Symfony\Bridge\Twig\Mime\TemplatedEmail;
|
||||||
use Symfony\Component\Mailer\MailerInterface;
|
use Symfony\Component\Mailer\MailerInterface;
|
||||||
use Symfony\Component\Mime\Address;
|
use Symfony\Component\Mime\Address;
|
||||||
use Symfony\Component\PasswordHasher\Hasher\PasswordHasherFactoryInterface;
|
use Symfony\Component\PasswordHasher\Hasher\PasswordHasherFactoryInterface;
|
||||||
use Symfony\Component\PasswordHasher\Hasher\UserPasswordHasherInterface;
|
use Symfony\Component\PasswordHasher\Hasher\UserPasswordHasherInterface;
|
||||||
use Symfony\Component\Security\Core\Encoder\EncoderFactoryInterface;
|
|
||||||
use Symfony\Component\Security\Core\Encoder\PasswordEncoderInterface;
|
|
||||||
use Symfony\Component\Security\Core\Encoder\UserPasswordEncoderInterface;
|
|
||||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||||
|
|
||||||
class PasswordResetManager
|
class PasswordResetManager
|
||||||
|
@ -88,7 +87,7 @@ class PasswordResetManager
|
||||||
$user->setPwResetToken($this->passwordEncoder->hash($unencrypted_token, null));
|
$user->setPwResetToken($this->passwordEncoder->hash($unencrypted_token, null));
|
||||||
|
|
||||||
//Determine the expiration datetime of
|
//Determine the expiration datetime of
|
||||||
$expiration_date = new \DateTime();
|
$expiration_date = new DateTime();
|
||||||
$expiration_date->add(date_interval_create_from_date_string('1 day'));
|
$expiration_date->add(date_interval_create_from_date_string('1 day'));
|
||||||
$user->setPwResetExpires($expiration_date);
|
$user->setPwResetExpires($expiration_date);
|
||||||
|
|
||||||
|
@ -135,7 +134,7 @@ class PasswordResetManager
|
||||||
}
|
}
|
||||||
|
|
||||||
//Check if token is expired yet
|
//Check if token is expired yet
|
||||||
if ($user->getPwResetExpires() < new \DateTime()) {
|
if ($user->getPwResetExpires() < new DateTime()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -149,7 +148,7 @@ class PasswordResetManager
|
||||||
|
|
||||||
//Remove token
|
//Remove token
|
||||||
$user->setPwResetToken(null);
|
$user->setPwResetToken(null);
|
||||||
$user->setPwResetExpires(new \DateTime());
|
$user->setPwResetExpires(new DateTime());
|
||||||
|
|
||||||
//Save to DB
|
//Save to DB
|
||||||
$this->em->flush();
|
$this->em->flush();
|
||||||
|
|
|
@ -46,6 +46,7 @@ use App\Configuration\PermissionsConfiguration;
|
||||||
use App\Entity\UserSystem\Group;
|
use App\Entity\UserSystem\Group;
|
||||||
use App\Entity\UserSystem\User;
|
use App\Entity\UserSystem\User;
|
||||||
use App\Security\Interfaces\HasPermissionsInterface;
|
use App\Security\Interfaces\HasPermissionsInterface;
|
||||||
|
use InvalidArgumentException;
|
||||||
use Symfony\Component\Config\ConfigCache;
|
use Symfony\Component\Config\ConfigCache;
|
||||||
use Symfony\Component\Config\Definition\Processor;
|
use Symfony\Component\Config\Definition\Processor;
|
||||||
use Symfony\Component\Config\Resource\FileResource;
|
use Symfony\Component\Config\Resource\FileResource;
|
||||||
|
@ -172,7 +173,7 @@ class PermissionResolver
|
||||||
public function listOperationsForPermission(string $permission): array
|
public function listOperationsForPermission(string $permission): array
|
||||||
{
|
{
|
||||||
if (!$this->isValidPermission($permission)) {
|
if (!$this->isValidPermission($permission)) {
|
||||||
throw new \InvalidArgumentException(sprintf('A permission with that name is not existing! Got %s.', $permission));
|
throw new InvalidArgumentException(sprintf('A permission with that name is not existing! Got %s.', $permission));
|
||||||
}
|
}
|
||||||
$operations = $this->permission_structure['perms'][$permission]['operations'];
|
$operations = $this->permission_structure['perms'][$permission]['operations'];
|
||||||
|
|
||||||
|
|
|
@ -50,6 +50,8 @@ use Brick\Math\RoundingMode;
|
||||||
use Doctrine\ORM\PersistentCollection;
|
use Doctrine\ORM\PersistentCollection;
|
||||||
use Locale;
|
use Locale;
|
||||||
|
|
||||||
|
use function count;
|
||||||
|
|
||||||
class PricedetailHelper
|
class PricedetailHelper
|
||||||
{
|
{
|
||||||
protected $base_currency;
|
protected $base_currency;
|
||||||
|
@ -74,7 +76,7 @@ class PricedetailHelper
|
||||||
foreach ($orderdetails as $orderdetail) {
|
foreach ($orderdetails as $orderdetail) {
|
||||||
$pricedetails = $orderdetail->getPricedetails();
|
$pricedetails = $orderdetail->getPricedetails();
|
||||||
//The orderdetail must have pricedetails, otherwise this will not work!
|
//The orderdetail must have pricedetails, otherwise this will not work!
|
||||||
if (0 === \count($pricedetails)) {
|
if (0 === count($pricedetails)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -121,7 +123,7 @@ class PricedetailHelper
|
||||||
foreach ($orderdetails as $orderdetail) {
|
foreach ($orderdetails as $orderdetail) {
|
||||||
$pricedetails = $orderdetail->getPricedetails();
|
$pricedetails = $orderdetail->getPricedetails();
|
||||||
//The orderdetail must have pricedetails, otherwise this will not work!
|
//The orderdetail must have pricedetails, otherwise this will not work!
|
||||||
if (0 === \count($pricedetails)) {
|
if (0 === count($pricedetails)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -36,6 +36,9 @@ use App\Entity\Parts\Supplier;
|
||||||
use App\Entity\PriceInformations\Currency;
|
use App\Entity\PriceInformations\Currency;
|
||||||
use Doctrine\ORM\EntityManagerInterface;
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
use Doctrine\ORM\EntityRepository;
|
use Doctrine\ORM\EntityRepository;
|
||||||
|
use Doctrine\ORM\NonUniqueResultException;
|
||||||
|
use Doctrine\ORM\NoResultException;
|
||||||
|
use InvalidArgumentException;
|
||||||
|
|
||||||
class StatisticsHelper
|
class StatisticsHelper
|
||||||
{
|
{
|
||||||
|
@ -61,8 +64,8 @@ class StatisticsHelper
|
||||||
/**
|
/**
|
||||||
* Returns the summed instocked over all parts (only parts without a measurement unit).
|
* Returns the summed instocked over all parts (only parts without a measurement unit).
|
||||||
*
|
*
|
||||||
* @throws \Doctrine\ORM\NoResultException
|
* @throws NoResultException
|
||||||
* @throws \Doctrine\ORM\NonUniqueResultException
|
* @throws NonUniqueResultException
|
||||||
*/
|
*/
|
||||||
public function getPartsInstockSum(): float
|
public function getPartsInstockSum(): float
|
||||||
{
|
{
|
||||||
|
@ -72,8 +75,8 @@ class StatisticsHelper
|
||||||
/**
|
/**
|
||||||
* Returns the number of all parts which have price informations.
|
* Returns the number of all parts which have price informations.
|
||||||
*
|
*
|
||||||
* @throws \Doctrine\ORM\NoResultException
|
* @throws NoResultException
|
||||||
* @throws \Doctrine\ORM\NonUniqueResultException
|
* @throws NonUniqueResultException
|
||||||
*/
|
*/
|
||||||
public function getPartsCountWithPrice(): int
|
public function getPartsCountWithPrice(): int
|
||||||
{
|
{
|
||||||
|
@ -98,7 +101,7 @@ class StatisticsHelper
|
||||||
];
|
];
|
||||||
|
|
||||||
if (!isset($arr[$type])) {
|
if (!isset($arr[$type])) {
|
||||||
throw new \InvalidArgumentException('No count for the given type available!');
|
throw new InvalidArgumentException('No count for the given type available!');
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @var EntityRepository $repo */
|
/** @var EntityRepository $repo */
|
||||||
|
@ -126,8 +129,8 @@ class StatisticsHelper
|
||||||
/**
|
/**
|
||||||
* Gets the count of all external (only containing an URL) attachments.
|
* Gets the count of all external (only containing an URL) attachments.
|
||||||
*
|
*
|
||||||
* @throws \Doctrine\ORM\NoResultException
|
* @throws NoResultException
|
||||||
* @throws \Doctrine\ORM\NonUniqueResultException
|
* @throws NonUniqueResultException
|
||||||
*/
|
*/
|
||||||
public function getExternalAttachmentsCount(): int
|
public function getExternalAttachmentsCount(): int
|
||||||
{
|
{
|
||||||
|
@ -137,8 +140,8 @@ class StatisticsHelper
|
||||||
/**
|
/**
|
||||||
* Gets the count of all attachments where the user uploaded an file.
|
* Gets the count of all attachments where the user uploaded an file.
|
||||||
*
|
*
|
||||||
* @throws \Doctrine\ORM\NoResultException
|
* @throws NoResultException
|
||||||
* @throws \Doctrine\ORM\NonUniqueResultException
|
* @throws NonUniqueResultException
|
||||||
*/
|
*/
|
||||||
public function getUserUploadedAttachmentsCount(): int
|
public function getUserUploadedAttachmentsCount(): int
|
||||||
{
|
{
|
||||||
|
|
|
@ -42,6 +42,9 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Services\TFA;
|
namespace App\Services\TFA;
|
||||||
|
|
||||||
|
use Exception;
|
||||||
|
use RuntimeException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class generates random backup codes for two factor authentication.
|
* This class generates random backup codes for two factor authentication.
|
||||||
*/
|
*/
|
||||||
|
@ -59,10 +62,10 @@ class BackupCodeGenerator
|
||||||
public function __construct(int $code_length, int $code_count)
|
public function __construct(int $code_length, int $code_count)
|
||||||
{
|
{
|
||||||
if ($code_length > 32) {
|
if ($code_length > 32) {
|
||||||
throw new \RuntimeException('Backup code can have maximum 32 digits!');
|
throw new RuntimeException('Backup code can have maximum 32 digits!');
|
||||||
}
|
}
|
||||||
if ($code_length < 6) {
|
if ($code_length < 6) {
|
||||||
throw new \RuntimeException('Code must have at least 6 digits to ensure security!');
|
throw new RuntimeException('Code must have at least 6 digits to ensure security!');
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->code_count = $code_count;
|
$this->code_count = $code_count;
|
||||||
|
@ -75,7 +78,7 @@ class BackupCodeGenerator
|
||||||
*
|
*
|
||||||
* @return string The generated backup code (e.g. 1f3870be2)
|
* @return string The generated backup code (e.g. 1f3870be2)
|
||||||
*
|
*
|
||||||
* @throws \Exception if no entropy source is available
|
* @throws Exception if no entropy source is available
|
||||||
*/
|
*/
|
||||||
public function generateSingleCode(): string
|
public function generateSingleCode(): string
|
||||||
{
|
{
|
||||||
|
|
|
@ -46,6 +46,8 @@ use App\Entity\Parts\Part;
|
||||||
use Doctrine\ORM\EntityManagerInterface;
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||||
|
|
||||||
|
use function array_slice;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A service related for searching for tags. Mostly useful for autocomplete reasons.
|
* A service related for searching for tags. Mostly useful for autocomplete reasons.
|
||||||
*/
|
*/
|
||||||
|
@ -101,7 +103,7 @@ class TagFinder
|
||||||
|
|
||||||
$results = array_unique($results);
|
$results = array_unique($results);
|
||||||
//Limit the returned tag count to specified value.
|
//Limit the returned tag count to specified value.
|
||||||
return \array_slice($results, 0, $options['return_limit']);
|
return array_slice($results, 0, $options['return_limit']);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function configureOptions(OptionsResolver $resolver): void
|
protected function configureOptions(OptionsResolver $resolver): void
|
||||||
|
|
|
@ -59,10 +59,14 @@ use App\Services\EntityURLGenerator;
|
||||||
use App\Services\MarkdownParser;
|
use App\Services\MarkdownParser;
|
||||||
use App\Services\UserCacheKeyGenerator;
|
use App\Services\UserCacheKeyGenerator;
|
||||||
use Doctrine\ORM\EntityManagerInterface;
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
|
use InvalidArgumentException;
|
||||||
|
use RecursiveIteratorIterator;
|
||||||
use Symfony\Contracts\Cache\ItemInterface;
|
use Symfony\Contracts\Cache\ItemInterface;
|
||||||
use Symfony\Contracts\Cache\TagAwareCacheInterface;
|
use Symfony\Contracts\Cache\TagAwareCacheInterface;
|
||||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||||
|
|
||||||
|
use function count;
|
||||||
|
|
||||||
class TreeViewGenerator
|
class TreeViewGenerator
|
||||||
{
|
{
|
||||||
protected $urlGenerator;
|
protected $urlGenerator;
|
||||||
|
@ -131,7 +135,7 @@ class TreeViewGenerator
|
||||||
|
|
||||||
$generic = $this->getGenericTree($class, $parent);
|
$generic = $this->getGenericTree($class, $parent);
|
||||||
$treeIterator = new TreeViewNodeIterator($generic);
|
$treeIterator = new TreeViewNodeIterator($generic);
|
||||||
$recursiveIterator = new \RecursiveIteratorIterator($treeIterator, \RecursiveIteratorIterator::SELF_FIRST);
|
$recursiveIterator = new RecursiveIteratorIterator($treeIterator, RecursiveIteratorIterator::SELF_FIRST);
|
||||||
foreach ($recursiveIterator as $item) {
|
foreach ($recursiveIterator as $item) {
|
||||||
/** @var TreeViewNode $item */
|
/** @var TreeViewNode $item */
|
||||||
if (null !== $selectedElement && $item->getId() === $selectedElement->getID()) {
|
if (null !== $selectedElement && $item->getId() === $selectedElement->getID()) {
|
||||||
|
@ -139,7 +143,7 @@ class TreeViewGenerator
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($item->getNodes())) {
|
if (!empty($item->getNodes())) {
|
||||||
$item->addTag((string) \count($item->getNodes()));
|
$item->addTag((string) count($item->getNodes()));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($href_type) && null !== $item->getId()) {
|
if (!empty($href_type) && null !== $item->getId()) {
|
||||||
|
@ -218,10 +222,10 @@ class TreeViewGenerator
|
||||||
public function getGenericTree(string $class, ?AbstractStructuralDBElement $parent = null): array
|
public function getGenericTree(string $class, ?AbstractStructuralDBElement $parent = null): array
|
||||||
{
|
{
|
||||||
if (!is_a($class, AbstractNamedDBElement::class, true)) {
|
if (!is_a($class, AbstractNamedDBElement::class, true)) {
|
||||||
throw new \InvalidArgumentException('$class must be a class string that implements StructuralDBElement or NamedDBElement!');
|
throw new InvalidArgumentException('$class must be a class string that implements StructuralDBElement or NamedDBElement!');
|
||||||
}
|
}
|
||||||
if (null !== $parent && !is_a($parent, $class)) {
|
if (null !== $parent && !is_a($parent, $class)) {
|
||||||
throw new \InvalidArgumentException('$parent must be of the type $class!');
|
throw new InvalidArgumentException('$parent must be of the type $class!');
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @var StructuralDBElementRepository $repo */
|
/** @var StructuralDBElementRepository $repo */
|
||||||
|
|
|
@ -43,6 +43,7 @@ declare(strict_types=1);
|
||||||
namespace App\Services;
|
namespace App\Services;
|
||||||
|
|
||||||
use App\Entity\UserSystem\User;
|
use App\Entity\UserSystem\User;
|
||||||
|
use Locale;
|
||||||
use Symfony\Component\Security\Core\Security;
|
use Symfony\Component\Security\Core\Security;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -65,7 +66,7 @@ class UserCacheKeyGenerator
|
||||||
*/
|
*/
|
||||||
public function generateKey(?User $user = null): string
|
public function generateKey(?User $user = null): string
|
||||||
{
|
{
|
||||||
$locale = \Locale::getDefault();
|
$locale = Locale::getDefault();
|
||||||
|
|
||||||
//If no user was specified, use the currently used one.
|
//If no user was specified, use the currently used one.
|
||||||
if (null === $user) {
|
if (null === $user) {
|
||||||
|
|
|
@ -61,6 +61,8 @@ use Twig\TwigFilter;
|
||||||
use Twig\TwigFunction;
|
use Twig\TwigFunction;
|
||||||
use Twig\TwigTest;
|
use Twig\TwigTest;
|
||||||
|
|
||||||
|
use function get_class;
|
||||||
|
|
||||||
class AppExtension extends AbstractExtension
|
class AppExtension extends AbstractExtension
|
||||||
{
|
{
|
||||||
protected $entityURLGenerator;
|
protected $entityURLGenerator;
|
||||||
|
@ -128,7 +130,7 @@ class AppExtension extends AbstractExtension
|
||||||
|
|
||||||
public function treeData(AbstractDBElement $element, string $type = 'newEdit'): string
|
public function treeData(AbstractDBElement $element, string $type = 'newEdit'): string
|
||||||
{
|
{
|
||||||
$tree = $this->treeBuilder->getTreeView(\get_class($element), null, $type, $element);
|
$tree = $this->treeBuilder->getTreeView(get_class($element), null, $type, $element);
|
||||||
|
|
||||||
return json_encode($tree);
|
return json_encode($tree);
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,13 +24,14 @@ declare(strict_types=1);
|
||||||
namespace App\Twig;
|
namespace App\Twig;
|
||||||
|
|
||||||
use App\Entity\LogSystem\AbstractLogEntry;
|
use App\Entity\LogSystem\AbstractLogEntry;
|
||||||
|
use App\Repository\LogEntryRepository;
|
||||||
use Doctrine\ORM\EntityManagerInterface;
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
use Twig\Extension\AbstractExtension;
|
use Twig\Extension\AbstractExtension;
|
||||||
use Twig\TwigFunction;
|
use Twig\TwigFunction;
|
||||||
|
|
||||||
class LastUserExtension extends AbstractExtension
|
class LastUserExtension extends AbstractExtension
|
||||||
{
|
{
|
||||||
/** @var \App\Repository\LogEntryRepository */
|
/** @var LogEntryRepository */
|
||||||
private $repo;
|
private $repo;
|
||||||
|
|
||||||
public function __construct(EntityManagerInterface $em)
|
public function __construct(EntityManagerInterface $em)
|
||||||
|
|
|
@ -22,6 +22,10 @@ use Twig\Sandbox\SecurityNotAllowedTagError;
|
||||||
use Twig\Sandbox\SecurityPolicyInterface;
|
use Twig\Sandbox\SecurityPolicyInterface;
|
||||||
use Twig\Template;
|
use Twig\Template;
|
||||||
|
|
||||||
|
use function get_class;
|
||||||
|
use function in_array;
|
||||||
|
use function is_array;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a security policy which need to be enforced when sandbox mode is enabled.
|
* Represents a security policy which need to be enforced when sandbox mode is enabled.
|
||||||
*
|
*
|
||||||
|
@ -61,7 +65,7 @@ final class InheritanceSecurityPolicy implements SecurityPolicyInterface
|
||||||
$this->allowedMethods = [];
|
$this->allowedMethods = [];
|
||||||
foreach ($methods as $class => $m) {
|
foreach ($methods as $class => $m) {
|
||||||
$this->allowedMethods[$class] = array_map(
|
$this->allowedMethods[$class] = array_map(
|
||||||
static function ($value) { return strtr($value, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz'); }, \is_array($m) ? $m : [$m]);
|
static function ($value) { return strtr($value, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz'); }, is_array($m) ? $m : [$m]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,19 +82,19 @@ final class InheritanceSecurityPolicy implements SecurityPolicyInterface
|
||||||
public function checkSecurity($tags, $filters, $functions): void
|
public function checkSecurity($tags, $filters, $functions): void
|
||||||
{
|
{
|
||||||
foreach ($tags as $tag) {
|
foreach ($tags as $tag) {
|
||||||
if (!\in_array($tag, $this->allowedTags, true)) {
|
if (!in_array($tag, $this->allowedTags, true)) {
|
||||||
throw new SecurityNotAllowedTagError(sprintf('Tag "%s" is not allowed.', $tag), $tag);
|
throw new SecurityNotAllowedTagError(sprintf('Tag "%s" is not allowed.', $tag), $tag);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($filters as $filter) {
|
foreach ($filters as $filter) {
|
||||||
if (!\in_array($filter, $this->allowedFilters, true)) {
|
if (!in_array($filter, $this->allowedFilters, true)) {
|
||||||
throw new SecurityNotAllowedFilterError(sprintf('Filter "%s" is not allowed.', $filter), $filter);
|
throw new SecurityNotAllowedFilterError(sprintf('Filter "%s" is not allowed.', $filter), $filter);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($functions as $function) {
|
foreach ($functions as $function) {
|
||||||
if (!\in_array($function, $this->allowedFunctions, true)) {
|
if (!in_array($function, $this->allowedFunctions, true)) {
|
||||||
throw new SecurityNotAllowedFunctionError(sprintf('Function "%s" is not allowed.', $function), $function);
|
throw new SecurityNotAllowedFunctionError(sprintf('Function "%s" is not allowed.', $function), $function);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -106,7 +110,7 @@ final class InheritanceSecurityPolicy implements SecurityPolicyInterface
|
||||||
$method = strtr($method, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz');
|
$method = strtr($method, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz');
|
||||||
foreach ($this->allowedMethods as $class => $methods) {
|
foreach ($this->allowedMethods as $class => $methods) {
|
||||||
if ($obj instanceof $class) {
|
if ($obj instanceof $class) {
|
||||||
$allowed = \in_array($method, $methods, true);
|
$allowed = in_array($method, $methods, true);
|
||||||
|
|
||||||
//CHANGED: Only break if we the method is allowed, otherwise try it on the other methods
|
//CHANGED: Only break if we the method is allowed, otherwise try it on the other methods
|
||||||
if ($allowed) {
|
if ($allowed) {
|
||||||
|
@ -116,7 +120,7 @@ final class InheritanceSecurityPolicy implements SecurityPolicyInterface
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$allowed) {
|
if (!$allowed) {
|
||||||
$class = \get_class($obj);
|
$class = get_class($obj);
|
||||||
|
|
||||||
throw new SecurityNotAllowedMethodError(sprintf('Calling "%s" method on a "%s" object is not allowed.', $method, $class), $class, $method);
|
throw new SecurityNotAllowedMethodError(sprintf('Calling "%s" method on a "%s" object is not allowed.', $method, $class), $class, $method);
|
||||||
}
|
}
|
||||||
|
@ -127,7 +131,7 @@ final class InheritanceSecurityPolicy implements SecurityPolicyInterface
|
||||||
$allowed = false;
|
$allowed = false;
|
||||||
foreach ($this->allowedProperties as $class => $properties) {
|
foreach ($this->allowedProperties as $class => $properties) {
|
||||||
if ($obj instanceof $class) {
|
if ($obj instanceof $class) {
|
||||||
$allowed = \in_array($property, \is_array($properties) ? $properties : [$properties], true);
|
$allowed = in_array($property, is_array($properties) ? $properties : [$properties], true);
|
||||||
|
|
||||||
//CHANGED: Only break if we the method is allowed, otherwise try it on the other methods
|
//CHANGED: Only break if we the method is allowed, otherwise try it on the other methods
|
||||||
if ($allowed) {
|
if ($allowed) {
|
||||||
|
@ -137,7 +141,7 @@ final class InheritanceSecurityPolicy implements SecurityPolicyInterface
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$allowed) {
|
if (!$allowed) {
|
||||||
$class = \get_class($obj);
|
$class = get_class($obj);
|
||||||
|
|
||||||
throw new SecurityNotAllowedPropertyError(sprintf('Calling "%s" property on a "%s" object is not allowed.', $property, $class), $class, $property);
|
throw new SecurityNotAllowedPropertyError(sprintf('Calling "%s" property on a "%s" object is not allowed.', $property, $class), $class, $property);
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,6 @@
|
||||||
namespace App\Validator\Constraints\BigDecimal;
|
namespace App\Validator\Constraints\BigDecimal;
|
||||||
|
|
||||||
use Symfony\Component\Validator\Constraints\GreaterThan;
|
use Symfony\Component\Validator\Constraints\GreaterThan;
|
||||||
use Symfony\Component\Validator\Constraints\NumberConstraintTrait;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Annotation
|
* @Annotation
|
||||||
|
|
|
@ -21,7 +21,6 @@
|
||||||
namespace App\Validator\Constraints\BigDecimal;
|
namespace App\Validator\Constraints\BigDecimal;
|
||||||
|
|
||||||
use Symfony\Component\Validator\Constraints\GreaterThanOrEqual;
|
use Symfony\Component\Validator\Constraints\GreaterThanOrEqual;
|
||||||
use Symfony\Component\Validator\Constraints\NumberConstraintTrait;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Annotation
|
* @Annotation
|
||||||
|
|
|
@ -4,13 +4,15 @@ namespace App\Validator\Constraints\BigDecimal;
|
||||||
|
|
||||||
use Symfony\Component\Validator\Exception\ConstraintDefinitionException;
|
use Symfony\Component\Validator\Exception\ConstraintDefinitionException;
|
||||||
|
|
||||||
|
use function is_array;
|
||||||
|
|
||||||
trait BigNumberConstraintTrait
|
trait BigNumberConstraintTrait
|
||||||
{
|
{
|
||||||
private function configureNumberConstraintOptions($options): array
|
private function configureNumberConstraintOptions($options): array
|
||||||
{
|
{
|
||||||
if (null === $options) {
|
if (null === $options) {
|
||||||
$options = [];
|
$options = [];
|
||||||
} elseif (!\is_array($options)) {
|
} elseif (!is_array($options)) {
|
||||||
$options = [$this->getDefaultOption() => $options];
|
$options = [$this->getDefaultOption() => $options];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -96,8 +96,6 @@ class NoneOfItsChildrenValidator extends ConstraintValidator
|
||||||
//Set the entity to a valid state
|
//Set the entity to a valid state
|
||||||
$entity->setParent(null);
|
$entity->setParent(null);
|
||||||
$this->context->buildViolation($constraint->children_message)->addViolation();
|
$this->context->buildViolation($constraint->children_message)->addViolation();
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,6 +47,9 @@ use Symfony\Component\Validator\Constraints\UrlValidator;
|
||||||
use Symfony\Component\Validator\Exception\UnexpectedTypeException;
|
use Symfony\Component\Validator\Exception\UnexpectedTypeException;
|
||||||
use Symfony\Component\Validator\Exception\UnexpectedValueException;
|
use Symfony\Component\Validator\Exception\UnexpectedValueException;
|
||||||
|
|
||||||
|
use function in_array;
|
||||||
|
use function is_object;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The validator for UrlOrBuiltin.
|
* The validator for UrlOrBuiltin.
|
||||||
* It checks if the value is either a builtin ressource or a valid url.
|
* It checks if the value is either a builtin ressource or a valid url.
|
||||||
|
@ -63,7 +66,7 @@ class UrlOrBuiltinValidator extends UrlValidator
|
||||||
if (null === $value || '' === $value) {
|
if (null === $value || '' === $value) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!is_scalar($value) && !(\is_object($value) && method_exists($value, '__toString'))) {
|
if (!is_scalar($value) && !(is_object($value) && method_exists($value, '__toString'))) {
|
||||||
throw new UnexpectedValueException($value, 'string');
|
throw new UnexpectedValueException($value, 'string');
|
||||||
}
|
}
|
||||||
$value = (string) $value;
|
$value = (string) $value;
|
||||||
|
@ -74,7 +77,7 @@ class UrlOrBuiltinValidator extends UrlValidator
|
||||||
//After the %PLACEHOLDER% comes a slash, so we can check if we have a placholder via explode
|
//After the %PLACEHOLDER% comes a slash, so we can check if we have a placholder via explode
|
||||||
$tmp = explode('/', $value);
|
$tmp = explode('/', $value);
|
||||||
//Builtins must have a %PLACEHOLDER% construction
|
//Builtins must have a %PLACEHOLDER% construction
|
||||||
if (\in_array($tmp[0], $constraint->allowed_placeholders, false)) {
|
if (in_array($tmp[0], $constraint->allowed_placeholders, false)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -48,6 +48,8 @@ use Symfony\Component\Validator\ConstraintValidator;
|
||||||
use Symfony\Component\Validator\Exception\UnexpectedTypeException;
|
use Symfony\Component\Validator\Exception\UnexpectedTypeException;
|
||||||
use Symfony\Component\Validator\Exception\UnexpectedValueException;
|
use Symfony\Component\Validator\Exception\UnexpectedValueException;
|
||||||
|
|
||||||
|
use function is_string;
|
||||||
|
|
||||||
class ValidFileFilterValidator extends ConstraintValidator
|
class ValidFileFilterValidator extends ConstraintValidator
|
||||||
{
|
{
|
||||||
protected $filterTools;
|
protected $filterTools;
|
||||||
|
@ -73,7 +75,7 @@ class ValidFileFilterValidator extends ConstraintValidator
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!\is_string($value)) {
|
if (!is_string($value)) {
|
||||||
// throw this exception if your validator cannot handle the passed type so that it can be marked as invalid
|
// throw this exception if your validator cannot handle the passed type so that it can be marked as invalid
|
||||||
throw new UnexpectedValueException($value, 'string');
|
throw new UnexpectedValueException($value, 'string');
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,6 +51,9 @@ use Symfony\Component\Validator\ConstraintValidator;
|
||||||
use Symfony\Component\Validator\Exception\UnexpectedTypeException;
|
use Symfony\Component\Validator\Exception\UnexpectedTypeException;
|
||||||
use Symfony\Component\Validator\Exception\UnexpectedValueException;
|
use Symfony\Component\Validator\Exception\UnexpectedValueException;
|
||||||
|
|
||||||
|
use function is_string;
|
||||||
|
use function strlen;
|
||||||
|
|
||||||
class ValidGoogleAuthCodeValidator extends ConstraintValidator
|
class ValidGoogleAuthCodeValidator extends ConstraintValidator
|
||||||
{
|
{
|
||||||
protected $googleAuthenticator;
|
protected $googleAuthenticator;
|
||||||
|
@ -70,7 +73,7 @@ class ValidGoogleAuthCodeValidator extends ConstraintValidator
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!\is_string($value)) {
|
if (!is_string($value)) {
|
||||||
throw new UnexpectedValueException($value, 'string');
|
throw new UnexpectedValueException($value, 'string');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -79,7 +82,7 @@ class ValidGoogleAuthCodeValidator extends ConstraintValidator
|
||||||
}
|
}
|
||||||
|
|
||||||
//Number must have 6 digits
|
//Number must have 6 digits
|
||||||
if (6 !== \strlen($value)) {
|
if (6 !== strlen($value)) {
|
||||||
$this->context->addViolation('validator.google_code.wrong_digit_count');
|
$this->context->addViolation('validator.google_code.wrong_digit_count');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -42,6 +42,7 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Tests;
|
namespace App\Tests;
|
||||||
|
|
||||||
|
use Generator;
|
||||||
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
|
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -73,7 +74,7 @@ class ApplicationAvailabilityFunctionalTest extends WebTestCase
|
||||||
$this->assertTrue($client->getResponse()->isSuccessful(), 'Request not successful. Status code is '.$client->getResponse()->getStatusCode());
|
$this->assertTrue($client->getResponse()->isSuccessful(), 'Request not successful. Status code is '.$client->getResponse()->getStatusCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function urlProvider(): ?\Generator
|
public function urlProvider(): ?Generator
|
||||||
{
|
{
|
||||||
//Homepage
|
//Homepage
|
||||||
//yield ['/'];
|
//yield ['/'];
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue