mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-21 09:35:49 +02:00
Fixed coding style.
This commit is contained in:
parent
a5e1f02d27
commit
ae75e6844f
41 changed files with 147 additions and 163 deletions
|
@ -51,7 +51,6 @@ use Symfony\Component\Console\Input\InputArgument;
|
||||||
use Symfony\Component\Console\Input\InputInterface;
|
use Symfony\Component\Console\Input\InputInterface;
|
||||||
use Symfony\Component\Console\Output\OutputInterface;
|
use Symfony\Component\Console\Output\OutputInterface;
|
||||||
use Symfony\Component\Console\Style\SymfonyStyle;
|
use Symfony\Component\Console\Style\SymfonyStyle;
|
||||||
use Symfony\Component\EventDispatcher\EventDispatcher;
|
|
||||||
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
||||||
use Symfony\Component\Security\Core\Encoder\UserPasswordEncoderInterface;
|
use Symfony\Component\Security\Core\Encoder\UserPasswordEncoderInterface;
|
||||||
|
|
||||||
|
|
|
@ -222,7 +222,7 @@ abstract class BaseAdminController extends AbstractController
|
||||||
protected function _new(Request $request, EntityManagerInterface $em, EntityImporter $importer, ?AbstractNamedDBElement $entity = null)
|
protected function _new(Request $request, EntityManagerInterface $em, EntityImporter $importer, ?AbstractNamedDBElement $entity = null)
|
||||||
{
|
{
|
||||||
$master_picture_backup = null;
|
$master_picture_backup = null;
|
||||||
if ($entity === null) {
|
if (null === $entity) {
|
||||||
/** @var AbstractStructuralDBElement|User $new_entity */
|
/** @var AbstractStructuralDBElement|User $new_entity */
|
||||||
$new_entity = new $this->entity_class();
|
$new_entity = new $this->entity_class();
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -45,6 +45,7 @@ namespace App\Controller;
|
||||||
use App\DataTables\LogDataTable;
|
use App\DataTables\LogDataTable;
|
||||||
use App\Entity\Parts\Category;
|
use App\Entity\Parts\Category;
|
||||||
use App\Entity\Parts\Footprint;
|
use App\Entity\Parts\Footprint;
|
||||||
|
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;
|
||||||
|
@ -52,7 +53,6 @@ use App\Entity\Parts\Supplier;
|
||||||
use App\Entity\PriceInformations\Orderdetail;
|
use App\Entity\PriceInformations\Orderdetail;
|
||||||
use App\Exceptions\AttachmentDownloadException;
|
use App\Exceptions\AttachmentDownloadException;
|
||||||
use App\Form\Part\PartBaseType;
|
use App\Form\Part\PartBaseType;
|
||||||
use App\Services\Attachments\AttachmentManager;
|
|
||||||
use App\Services\Attachments\AttachmentSubmitHandler;
|
use App\Services\Attachments\AttachmentSubmitHandler;
|
||||||
use App\Services\Attachments\PartPreviewGenerator;
|
use App\Services\Attachments\PartPreviewGenerator;
|
||||||
use App\Services\LogSystem\EventCommentHelper;
|
use App\Services\LogSystem\EventCommentHelper;
|
||||||
|
@ -62,7 +62,6 @@ use App\Services\Parameters\ParameterExtractor;
|
||||||
use App\Services\PricedetailHelper;
|
use App\Services\PricedetailHelper;
|
||||||
use Doctrine\ORM\EntityManagerInterface;
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
use Omines\DataTablesBundle\DataTableFactory;
|
use Omines\DataTablesBundle\DataTableFactory;
|
||||||
use App\Entity\Parts\Manufacturer;
|
|
||||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||||
use Symfony\Component\Form\FormInterface;
|
use Symfony\Component\Form\FormInterface;
|
||||||
use Symfony\Component\HttpFoundation\RedirectResponse;
|
use Symfony\Component\HttpFoundation\RedirectResponse;
|
||||||
|
@ -256,7 +255,7 @@ class PartController extends AbstractController
|
||||||
}
|
}
|
||||||
|
|
||||||
$store_id = $request->get('storelocation', null);
|
$store_id = $request->get('storelocation', null);
|
||||||
$storelocation = $store_id ? $em->find(Storelocation::class, $store_id): null;
|
$storelocation = $store_id ? $em->find(Storelocation::class, $store_id) : null;
|
||||||
if (null !== $storelocation && $new_part->getPartLots()->isEmpty()) {
|
if (null !== $storelocation && $new_part->getPartLots()->isEmpty()) {
|
||||||
$partLot = new PartLot();
|
$partLot = new PartLot();
|
||||||
$partLot->setStorageLocation($storelocation);
|
$partLot->setStorageLocation($storelocation);
|
||||||
|
@ -265,14 +264,13 @@ class PartController extends AbstractController
|
||||||
}
|
}
|
||||||
|
|
||||||
$supplier_id = $request->get('supplier', null);
|
$supplier_id = $request->get('supplier', null);
|
||||||
$supplier = $supplier_id ? $em->find(Supplier::class, $supplier_id): null;
|
$supplier = $supplier_id ? $em->find(Supplier::class, $supplier_id) : null;
|
||||||
if (null !== $supplier && $new_part->getOrderdetails()->isEmpty()) {
|
if (null !== $supplier && $new_part->getOrderdetails()->isEmpty()) {
|
||||||
$orderdetail = new Orderdetail();
|
$orderdetail = new Orderdetail();
|
||||||
$orderdetail->setSupplier($supplier);
|
$orderdetail->setSupplier($supplier);
|
||||||
$new_part->addOrderdetail($orderdetail);
|
$new_part->addOrderdetail($orderdetail);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$form = $this->createForm(PartBaseType::class, $new_part);
|
$form = $this->createForm(PartBaseType::class, $new_part);
|
||||||
|
|
||||||
$form->handleRequest($request);
|
$form->handleRequest($request);
|
||||||
|
|
|
@ -46,7 +46,6 @@ use App\Services\Attachments\BuiltinAttachmentsFinder;
|
||||||
use App\Services\TagFinder;
|
use App\Services\TagFinder;
|
||||||
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\Request;
|
|
||||||
use Symfony\Component\Routing\Annotation\Route;
|
use Symfony\Component\Routing\Annotation\Route;
|
||||||
use Symfony\Component\Serializer\Encoder\JsonEncoder;
|
use Symfony\Component\Serializer\Encoder\JsonEncoder;
|
||||||
use Symfony\Component\Serializer\Normalizer\ObjectNormalizer;
|
use Symfony\Component\Serializer\Normalizer\ObjectNormalizer;
|
||||||
|
@ -62,8 +61,6 @@ class TypeaheadController extends AbstractController
|
||||||
/**
|
/**
|
||||||
* @Route("/builtInResources/search/{query}", name="typeahead_builtInRessources", requirements={"query"= ".+"})
|
* @Route("/builtInResources/search/{query}", name="typeahead_builtInRessources", requirements={"query"= ".+"})
|
||||||
*
|
*
|
||||||
* @param string $query
|
|
||||||
* @param BuiltinAttachmentsFinder $finder
|
|
||||||
* @return JsonResponse
|
* @return JsonResponse
|
||||||
*/
|
*/
|
||||||
public function builtInResources(string $query, BuiltinAttachmentsFinder $finder)
|
public function builtInResources(string $query, BuiltinAttachmentsFinder $finder)
|
||||||
|
|
|
@ -56,7 +56,6 @@ use Doctrine\ORM\EntityManagerInterface;
|
||||||
use InvalidArgumentException;
|
use InvalidArgumentException;
|
||||||
use Omines\DataTablesBundle\DataTableFactory;
|
use Omines\DataTablesBundle\DataTableFactory;
|
||||||
use Symfony\Component\Asset\Packages;
|
use Symfony\Component\Asset\Packages;
|
||||||
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
|
||||||
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;
|
||||||
|
@ -194,7 +193,6 @@ class UserController extends AdminPages\BaseAdminController
|
||||||
return $table->getResponse();
|
return $table->getResponse();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if ($this->getParameter('use_gravatar')) {
|
if ($this->getParameter('use_gravatar')) {
|
||||||
$avatar = $this->getGravatar($user->getEmail(), 200, 'identicon');
|
$avatar = $this->getGravatar($user->getEmail(), 200, 'identicon');
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -52,8 +52,8 @@ use App\Entity\Parts\MeasurementUnit;
|
||||||
use App\Entity\Parts\Storelocation;
|
use App\Entity\Parts\Storelocation;
|
||||||
use App\Entity\Parts\Supplier;
|
use App\Entity\Parts\Supplier;
|
||||||
use Doctrine\Bundle\FixturesBundle\Fixture;
|
use Doctrine\Bundle\FixturesBundle\Fixture;
|
||||||
use Doctrine\Persistence\ObjectManager;
|
|
||||||
use Doctrine\ORM\EntityManagerInterface;
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
|
use Doctrine\Persistence\ObjectManager;
|
||||||
use InvalidArgumentException;
|
use InvalidArgumentException;
|
||||||
|
|
||||||
class DataStructureFixtures extends Fixture
|
class DataStructureFixtures extends Fixture
|
||||||
|
|
|
@ -44,8 +44,8 @@ namespace App\DataFixtures;
|
||||||
|
|
||||||
use App\Entity\UserSystem\User;
|
use App\Entity\UserSystem\User;
|
||||||
use Doctrine\Bundle\FixturesBundle\Fixture;
|
use Doctrine\Bundle\FixturesBundle\Fixture;
|
||||||
use Doctrine\Persistence\ObjectManager;
|
|
||||||
use Doctrine\ORM\EntityManagerInterface;
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
|
use Doctrine\Persistence\ObjectManager;
|
||||||
use Symfony\Component\Security\Core\Encoder\UserPasswordEncoderInterface;
|
use Symfony\Component\Security\Core\Encoder\UserPasswordEncoderInterface;
|
||||||
|
|
||||||
class UserFixtures extends Fixture
|
class UserFixtures extends Fixture
|
||||||
|
|
|
@ -103,9 +103,10 @@ class LogDataTable implements DataTableTypeInterface
|
||||||
$optionsResolver->setAllowedTypes('mode', 'string');
|
$optionsResolver->setAllowedTypes('mode', 'string');
|
||||||
|
|
||||||
$optionsResolver->setNormalizer('filter_elements', function (Options $options, $value) {
|
$optionsResolver->setNormalizer('filter_elements', function (Options $options, $value) {
|
||||||
if (!is_array($value)) {
|
if (! is_array($value)) {
|
||||||
return [$value];
|
return [$value];
|
||||||
}
|
}
|
||||||
|
|
||||||
return $value;
|
return $value;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||||
*
|
*
|
||||||
|
@ -20,7 +23,6 @@
|
||||||
|
|
||||||
namespace App\Entity\LogSystem;
|
namespace App\Entity\LogSystem;
|
||||||
|
|
||||||
|
|
||||||
use App\Entity\Base\AbstractDBElement;
|
use App\Entity\Base\AbstractDBElement;
|
||||||
use App\Entity\UserSystem\User;
|
use App\Entity\UserSystem\User;
|
||||||
use App\Events\SecurityEvents;
|
use App\Events\SecurityEvents;
|
||||||
|
@ -57,24 +59,26 @@ 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);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the type of this log entry.
|
* Sets the type of this log entry.
|
||||||
* @param string $type
|
*
|
||||||
* @return $this
|
* @return $this
|
||||||
*/
|
*/
|
||||||
public function setEventType(string $type): self
|
public function setEventType(string $type): self
|
||||||
{
|
{
|
||||||
$key = array_search($type, static::SECURITY_TYPE_MAPPING);
|
$key = array_search($type, static::SECURITY_TYPE_MAPPING, true);
|
||||||
if ($key === false) {
|
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;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,7 +88,8 @@ class SecurityEventLogEntry extends AbstractLogEntry
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return what event this log entry represents (e.g. password_reset)
|
* Return what event this log entry represents (e.g. password_reset).
|
||||||
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getEventType(): string
|
public function getEventType(): string
|
||||||
|
@ -121,6 +126,7 @@ class SecurityEventLogEntry extends AbstractLogEntry
|
||||||
$ip = IpUtils::anonymize($ip);
|
$ip = IpUtils::anonymize($ip);
|
||||||
}
|
}
|
||||||
$this->extra['i'] = $ip;
|
$this->extra['i'] = $ip;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,7 +42,6 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Entity\LogSystem;
|
namespace App\Entity\LogSystem;
|
||||||
|
|
||||||
use App\Exceptions\LogEntryObsoleteException;
|
|
||||||
use Doctrine\ORM\Mapping as ORM;
|
use Doctrine\ORM\Mapping as ORM;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -62,6 +61,7 @@ class UserNotAllowedLogEntry extends AbstractLogEntry
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the path the user tried to accessed and what was denied.
|
* Returns the path the user tried to accessed and what was denied.
|
||||||
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getPath(): string
|
public function getPath(): string
|
||||||
|
|
|
@ -306,13 +306,13 @@ class PartLot extends AbstractDBElement implements TimeStampableInterface, Named
|
||||||
/**
|
/**
|
||||||
* Sets the amount of parts in the part lot.
|
* Sets the amount of parts in the part lot.
|
||||||
* If null is passed, amount will be set to unknown.
|
* If null is passed, amount will be set to unknown.
|
||||||
* @param float|null $new_amount
|
*
|
||||||
* @return $this
|
* @return $this
|
||||||
*/
|
*/
|
||||||
public function setAmount(?float $new_amount): self
|
public function setAmount(?float $new_amount): self
|
||||||
{
|
{
|
||||||
//Treat null like unknown amount
|
//Treat null like unknown amount
|
||||||
if ($new_amount === null) {
|
if (null === $new_amount) {
|
||||||
$this->instock_unknown = true;
|
$this->instock_unknown = true;
|
||||||
$new_amount = 0.0;
|
$new_amount = 0.0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,9 +44,9 @@ 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 Doctrine\ORM\Mapping as ORM;
|
|
||||||
use function count;
|
use function count;
|
||||||
use Doctrine\Common\Collections\Collection;
|
use Doctrine\Common\Collections\Collection;
|
||||||
|
use Doctrine\ORM\Mapping as ORM;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This trait collects all aspects of a part related to orders and priceinformations.
|
* This trait collects all aspects of a part related to orders and priceinformations.
|
||||||
|
|
|
@ -164,11 +164,10 @@ class Pricedetail extends AbstractDBElement implements TimeStampableInterface
|
||||||
*
|
*
|
||||||
* You will get the price for $multiplier parts. If you want the price which is stored
|
* You will get the price for $multiplier parts. If you want the price which is stored
|
||||||
* in the database, you have to pass the "price_related_quantity" count as $multiplier.
|
* in the database, you have to pass the "price_related_quantity" count as $multiplier.
|
||||||
*
|
|
||||||
* @param float|string $multiplier The returned price (float or string) will be multiplied
|
* @param float|string $multiplier The returned price (float or string) will be multiplied
|
||||||
* with this multiplier.
|
* with this multiplier.
|
||||||
*
|
*
|
||||||
* @return null|string the price as a bcmath string
|
* @return string|null the price as a bcmath string
|
||||||
*/
|
*/
|
||||||
public function getPricePerUnit($multiplier = 1.0): ?string
|
public function getPricePerUnit($multiplier = 1.0): ?string
|
||||||
{
|
{
|
||||||
|
|
|
@ -61,13 +61,16 @@ class U2FKey implements TwoFactorKeyInterface
|
||||||
/**
|
/**
|
||||||
* We have to restrict the length here, as InnoDB only supports key index with max. 767 Bytes.
|
* We have to restrict the length here, as InnoDB only supports key index with max. 767 Bytes.
|
||||||
* Max length of keyhandles should be 128. (According to U2F_MAX_KH_SIZE in FIDO example C code).
|
* Max length of keyhandles should be 128. (According to U2F_MAX_KH_SIZE in FIDO example C code).
|
||||||
|
*
|
||||||
* @ORM\Column(type="string", length=128)
|
* @ORM\Column(type="string", length=128)
|
||||||
|
*
|
||||||
* @var string
|
* @var string
|
||||||
**/
|
**/
|
||||||
public $keyHandle;
|
public $keyHandle;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ORM\Column(type="string")
|
* @ORM\Column(type="string")
|
||||||
|
*
|
||||||
* @var string
|
* @var string
|
||||||
**/
|
**/
|
||||||
public $publicKey;
|
public $publicKey;
|
||||||
|
|
|
@ -508,7 +508,7 @@ class User extends AttachmentContainingDBElement implements UserInterface, HasPe
|
||||||
{
|
{
|
||||||
$tmp = $this->getFirstName();
|
$tmp = $this->getFirstName();
|
||||||
//Dont add a space, if the name has only one part (it would look strange)
|
//Dont add a space, if the name has only one part (it would look strange)
|
||||||
if (!empty($this->getFirstName()) && !empty($this->getLastName())) {
|
if (! empty($this->getFirstName()) && ! empty($this->getLastName())) {
|
||||||
$tmp .= ' ';
|
$tmp .= ' ';
|
||||||
}
|
}
|
||||||
$tmp .= $this->getLastName();
|
$tmp .= $this->getLastName();
|
||||||
|
|
|
@ -87,7 +87,7 @@ class AttachmentDeleteListener
|
||||||
$real_path = $this->pathResolver->placeholderToRealPath($old_path);
|
$real_path = $this->pathResolver->placeholderToRealPath($old_path);
|
||||||
|
|
||||||
//If the attachment does not point to a valid file, ignore it!
|
//If the attachment does not point to a valid file, ignore it!
|
||||||
if ($real_path === null) {
|
if (null === $real_path) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -67,7 +67,6 @@ use Symfony\Component\Serializer\SerializerInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This event subscriber write to event log when entities are changed, removed, created.
|
* This event subscriber write to event log when entities are changed, removed, created.
|
||||||
* @package App\EventSubscriber\LogSystem
|
|
||||||
*/
|
*/
|
||||||
class EventLoggerSubscriber implements EventSubscriber
|
class EventLoggerSubscriber implements EventSubscriber
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||||
*
|
*
|
||||||
|
@ -20,7 +23,6 @@
|
||||||
|
|
||||||
namespace App\EventSubscriber\LogSystem;
|
namespace App\EventSubscriber\LogSystem;
|
||||||
|
|
||||||
|
|
||||||
use App\Entity\LogSystem\UserNotAllowedLogEntry;
|
use App\Entity\LogSystem\UserNotAllowedLogEntry;
|
||||||
use App\Services\LogSystem\EventLogger;
|
use App\Services\LogSystem\EventLogger;
|
||||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||||
|
@ -30,7 +32,6 @@ use Symfony\Component\Security\Core\Exception\AccessDeniedException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Write to event log when a user tries to access an forbidden page and recevies an 403 Access Denied message.
|
* Write to event log when a user tries to access an forbidden page and recevies an 403 Access Denied message.
|
||||||
* @package App\EventSubscriber\LogSystem
|
|
||||||
*/
|
*/
|
||||||
class LogAccessDeniedSubscriber implements EventSubscriberInterface
|
class LogAccessDeniedSubscriber implements EventSubscriberInterface
|
||||||
{
|
{
|
||||||
|
@ -41,14 +42,14 @@ class LogAccessDeniedSubscriber implements EventSubscriberInterface
|
||||||
$this->logger = $logger;
|
$this->logger = $logger;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onKernelException(ExceptionEvent $event)
|
public function onKernelException(ExceptionEvent $event): void
|
||||||
{
|
{
|
||||||
$throwable = $event->getThrowable();
|
$throwable = $event->getThrowable();
|
||||||
if ($throwable instanceof AccessDeniedHttpException) {
|
if ($throwable instanceof AccessDeniedHttpException) {
|
||||||
$throwable = $throwable->getPrevious();
|
$throwable = $throwable->getPrevious();
|
||||||
}
|
}
|
||||||
//Ignore everything except AccessDeniedExceptions
|
//Ignore everything except AccessDeniedExceptions
|
||||||
if (!$throwable instanceof AccessDeniedException) {
|
if (! $throwable instanceof AccessDeniedException) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,11 +58,8 @@ class LogAccessDeniedSubscriber implements EventSubscriberInterface
|
||||||
$this->logger->logAndFlush($log_entry);
|
$this->logger->logAndFlush($log_entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @inheritDoc
|
|
||||||
*/
|
|
||||||
public static function getSubscribedEvents()
|
public static function getSubscribedEvents()
|
||||||
{
|
{
|
||||||
return ['kernel.exception' => 'onKernelException'];
|
return ['kernel.exception' => 'onKernelException'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,7 +50,6 @@ use Doctrine\Migrations\Events;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This subscriber logs databaseMigrations to Event log.
|
* This subscriber logs databaseMigrations to Event log.
|
||||||
* @package App\EventSubscriber
|
|
||||||
*/
|
*/
|
||||||
class LogDBMigrationSubscriber implements EventSubscriber
|
class LogDBMigrationSubscriber implements EventSubscriber
|
||||||
{
|
{
|
||||||
|
|
|
@ -52,7 +52,6 @@ use Symfony\Component\Security\Http\Logout\LogoutHandlerInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This handler logs to event log, if a user logs out.
|
* This handler logs to event log, if a user logs out.
|
||||||
* @package App\EventSubscriber\LogSystem
|
|
||||||
*/
|
*/
|
||||||
class LogoutLoggerHandler implements LogoutHandlerInterface
|
class LogoutLoggerHandler implements LogoutHandlerInterface
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||||
*
|
*
|
||||||
|
@ -20,22 +23,18 @@
|
||||||
|
|
||||||
namespace App\EventSubscriber\LogSystem;
|
namespace App\EventSubscriber\LogSystem;
|
||||||
|
|
||||||
|
|
||||||
use App\Entity\LogSystem\SecurityEventLogEntry;
|
use App\Entity\LogSystem\SecurityEventLogEntry;
|
||||||
use App\Events\SecurityEvent;
|
use App\Events\SecurityEvent;
|
||||||
use App\Events\SecurityEvents;
|
use App\Events\SecurityEvents;
|
||||||
use App\Services\LogSystem\EventLogger;
|
use App\Services\LogSystem\EventLogger;
|
||||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
|
||||||
use Symfony\Component\HttpFoundation\RequestStack;
|
use Symfony\Component\HttpFoundation\RequestStack;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This subscriber writes entries to log if an security related event happens (e.g. the user changes its password).
|
* This subscriber writes entries to log if an security related event happens (e.g. the user changes its password).
|
||||||
* @package App\EventSubscriber\LogSystem
|
|
||||||
*/
|
*/
|
||||||
final class SecurityEventLoggerSubscriber implements EventSubscriberInterface
|
final class SecurityEventLoggerSubscriber implements EventSubscriberInterface
|
||||||
{
|
{
|
||||||
|
|
||||||
private $requestStack;
|
private $requestStack;
|
||||||
private $gpdr_compliant;
|
private $gpdr_compliant;
|
||||||
private $eventLogger;
|
private $eventLogger;
|
||||||
|
@ -47,27 +46,6 @@ final class SecurityEventLoggerSubscriber implements EventSubscriberInterface
|
||||||
$this->eventLogger = $eventLogger;
|
$this->eventLogger = $eventLogger;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function addLog(string $type, SecurityEvent $event): void
|
|
||||||
{
|
|
||||||
$anonymize = $this->gpdr_compliant;
|
|
||||||
|
|
||||||
$request = $this->requestStack->getCurrentRequest();
|
|
||||||
if ($request !== null) {
|
|
||||||
$ip = $request->getClientIp() ?? 'unknown';
|
|
||||||
} else {
|
|
||||||
$ip = "Console";
|
|
||||||
//Dont try to apply IP filter rules to non numeric string
|
|
||||||
$anonymize = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
$log = new SecurityEventLogEntry($type, $ip, $anonymize);
|
|
||||||
$log->setTargetElement($event->getTargetUser());
|
|
||||||
$this->eventLogger->logAndFlush($log);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @inheritDoc
|
|
||||||
*/
|
|
||||||
public static function getSubscribedEvents()
|
public static function getSubscribedEvents()
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
|
@ -127,4 +105,22 @@ final class SecurityEventLoggerSubscriber implements EventSubscriberInterface
|
||||||
{
|
{
|
||||||
$this->addLog(SecurityEvents::TRUSTED_DEVICE_RESET, $event);
|
$this->addLog(SecurityEvents::TRUSTED_DEVICE_RESET, $event);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
private function addLog(string $type, SecurityEvent $event): void
|
||||||
|
{
|
||||||
|
$anonymize = $this->gpdr_compliant;
|
||||||
|
|
||||||
|
$request = $this->requestStack->getCurrentRequest();
|
||||||
|
if (null !== $request) {
|
||||||
|
$ip = $request->getClientIp() ?? 'unknown';
|
||||||
|
} else {
|
||||||
|
$ip = 'Console';
|
||||||
|
//Dont try to apply IP filter rules to non numeric string
|
||||||
|
$anonymize = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$log = new SecurityEventLogEntry($type, $ip, $anonymize);
|
||||||
|
$log->setTargetElement($event->getTargetUser());
|
||||||
|
$this->eventLogger->logAndFlush($log);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -49,7 +49,6 @@ use Symfony\Component\Mime\Email;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This subscriber set the "From" field for all sent email, based on the global configured sender name and email.
|
* This subscriber set the "From" field for all sent email, based on the global configured sender name and email.
|
||||||
* @package App\EventSubscriber
|
|
||||||
*/
|
*/
|
||||||
final class SetMailFromSubscriber implements EventSubscriberInterface
|
final class SetMailFromSubscriber implements EventSubscriberInterface
|
||||||
{
|
{
|
||||||
|
|
|
@ -42,14 +42,11 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\EventSubscriber;
|
namespace App\EventSubscriber;
|
||||||
|
|
||||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
|
||||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||||
use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
|
|
||||||
use Symfony\Component\HttpKernel\Event\ResponseEvent;
|
use Symfony\Component\HttpKernel\Event\ResponseEvent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This subscriber sets an Header in Debug mode that signals the Symfony Profiler to also update on Ajax requests.
|
* This subscriber sets an Header in Debug mode that signals the Symfony Profiler to also update on Ajax requests.
|
||||||
* @package App\EventSubscriber
|
|
||||||
*/
|
*/
|
||||||
final class SymfonyDebugToolbarSubscriber implements EventSubscriberInterface
|
final class SymfonyDebugToolbarSubscriber implements EventSubscriberInterface
|
||||||
{
|
{
|
||||||
|
|
|
@ -53,7 +53,6 @@ use Symfony\Component\Security\Core\Security;
|
||||||
/**
|
/**
|
||||||
* This subscriber is used to log out a disabled user, as soon as he to do an request.
|
* This subscriber is used to log out a disabled user, as soon as he to do an request.
|
||||||
* It is not possible for him to login again, afterwards.
|
* It is not possible for him to login again, afterwards.
|
||||||
* @package App\EventSubscriber\UserSystem
|
|
||||||
*/
|
*/
|
||||||
final class LogoutDisabledUserSubscriber implements EventSubscriberInterface
|
final class LogoutDisabledUserSubscriber implements EventSubscriberInterface
|
||||||
{
|
{
|
||||||
|
|
|
@ -57,7 +57,6 @@ use Symfony\Contracts\EventDispatcher\EventDispatcherInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This subscriber is used to write U2F keys to DB, after user added them via GUI.
|
* This subscriber is used to write U2F keys to DB, after user added them via GUI.
|
||||||
* @package App\EventSubscriber\UserSystem
|
|
||||||
*/
|
*/
|
||||||
final class RegisterU2FSubscriber implements EventSubscriberInterface
|
final class RegisterU2FSubscriber implements EventSubscriberInterface
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||||
*
|
*
|
||||||
|
@ -20,14 +23,12 @@
|
||||||
|
|
||||||
namespace App\Events;
|
namespace App\Events;
|
||||||
|
|
||||||
|
|
||||||
use App\Entity\UserSystem\User;
|
use App\Entity\UserSystem\User;
|
||||||
use Symfony\Contracts\EventDispatcher\Event;
|
use Symfony\Contracts\EventDispatcher\Event;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This event is triggered when something security related to a user happens.
|
* This event is triggered when something security related to a user happens.
|
||||||
* For example when the password is reset or the an two factor authentication method was disabled.
|
* For example when the password is reset or the an two factor authentication method was disabled.
|
||||||
* @package App\Events
|
|
||||||
*/
|
*/
|
||||||
class SecurityEvent extends Event
|
class SecurityEvent extends Event
|
||||||
{
|
{
|
||||||
|
@ -41,10 +42,11 @@ class SecurityEvent extends Event
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the affected user.
|
* Returns the affected user.
|
||||||
|
*
|
||||||
* @return User
|
* @return User
|
||||||
*/
|
*/
|
||||||
public function getTargetUser()
|
public function getTargetUser()
|
||||||
{
|
{
|
||||||
return $this->targetUser;
|
return $this->targetUser;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||||
*
|
*
|
||||||
|
@ -20,7 +23,6 @@
|
||||||
|
|
||||||
namespace App\Events;
|
namespace App\Events;
|
||||||
|
|
||||||
|
|
||||||
class SecurityEvents
|
class SecurityEvents
|
||||||
{
|
{
|
||||||
public const PASSWORD_CHANGED = 'security.password_changed';
|
public const PASSWORD_CHANGED = 'security.password_changed';
|
||||||
|
@ -32,4 +34,4 @@ class SecurityEvents
|
||||||
public const GOOGLE_DISABLED = 'security.google_disabled';
|
public const GOOGLE_DISABLED = 'security.google_disabled';
|
||||||
public const TRUSTED_DEVICE_RESET = 'security.trusted_device_reset';
|
public const TRUSTED_DEVICE_RESET = 'security.trusted_device_reset';
|
||||||
public const TFA_ADMIN_RESET = 'security.2fa_admin_reset';
|
public const TFA_ADMIN_RESET = 'security.2fa_admin_reset';
|
||||||
}
|
}
|
||||||
|
|
|
@ -106,7 +106,7 @@ class AttachmentFormType extends AbstractType
|
||||||
'required' => false,
|
'required' => false,
|
||||||
'label' => 'attachment.edit.secure_file',
|
'label' => 'attachment.edit.secure_file',
|
||||||
'mapped' => false,
|
'mapped' => false,
|
||||||
'disabled' => !$this->security->isGranted('@parts_attachments.show_private'),
|
'disabled' => ! $this->security->isGranted('@parts_attachments.show_private'),
|
||||||
'attr' => [
|
'attr' => [
|
||||||
'class' => 'form-control-sm',
|
'class' => 'form-control-sm',
|
||||||
],
|
],
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||||
*
|
*
|
||||||
|
@ -20,7 +23,6 @@
|
||||||
|
|
||||||
namespace App\Form;
|
namespace App\Form;
|
||||||
|
|
||||||
|
|
||||||
use Doctrine\Common\Collections\ArrayCollection;
|
use Doctrine\Common\Collections\ArrayCollection;
|
||||||
use Doctrine\Common\Collections\Collection;
|
use Doctrine\Common\Collections\Collection;
|
||||||
use Symfony\Component\Form\AbstractTypeExtension;
|
use Symfony\Component\Form\AbstractTypeExtension;
|
||||||
|
@ -39,7 +41,6 @@ use Symfony\Component\PropertyAccess\PropertyAccessorInterface;
|
||||||
* This prevents issues when the collection that is edited uses a OrderBy annotation and therefore the direction of the
|
* This prevents issues when the collection that is edited uses a OrderBy annotation and therefore the direction of the
|
||||||
* elements can change during requests.
|
* elements can change during requests.
|
||||||
* Must me enabled by setting reindex_enable to true in Type options.
|
* Must me enabled by setting reindex_enable to true in Type options.
|
||||||
* @package App\Form
|
|
||||||
*/
|
*/
|
||||||
class CollectionTypeExtension extends AbstractTypeExtension
|
class CollectionTypeExtension extends AbstractTypeExtension
|
||||||
{
|
{
|
||||||
|
@ -55,26 +56,26 @@ class CollectionTypeExtension extends AbstractTypeExtension
|
||||||
return [CollectionType::class];
|
return [CollectionType::class];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function configureOptions(OptionsResolver $resolver)
|
public function configureOptions(OptionsResolver $resolver): void
|
||||||
{
|
{
|
||||||
/*$resolver->setDefault('error_mapping', function (Options $options) {
|
/*$resolver->setDefault('error_mapping', function (Options $options) {
|
||||||
$options->
|
$options->
|
||||||
});*/
|
});*/
|
||||||
|
|
||||||
$resolver->setDefaults([
|
$resolver->setDefaults([
|
||||||
'reindex_enable' => false,
|
'reindex_enable' => false,
|
||||||
'reindex_prefix' => 'db_',
|
'reindex_prefix' => 'db_',
|
||||||
'reindex_path' => 'id',
|
'reindex_path' => 'id',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$resolver->setAllowedTypes('reindex_enable', 'bool');
|
$resolver->setAllowedTypes('reindex_enable', 'bool');
|
||||||
$resolver->setAllowedTypes('reindex_prefix', 'string');
|
$resolver->setAllowedTypes('reindex_prefix', 'string');
|
||||||
$resolver->setAllowedTypes('reindex_path', 'string');
|
$resolver->setAllowedTypes('reindex_path', 'string');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
public function buildForm(FormBuilderInterface $builder, array $options): void
|
||||||
{
|
{
|
||||||
$builder->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) use ($options) {
|
$builder->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) use ($options): void {
|
||||||
$data = $event->getData();
|
$data = $event->getData();
|
||||||
$config = $event->getForm()->getConfig();
|
$config = $event->getForm()->getConfig();
|
||||||
//If enabled do a reindexing of the collection
|
//If enabled do a reindexing of the collection
|
||||||
|
@ -86,8 +87,8 @@ class CollectionTypeExtension extends AbstractTypeExtension
|
||||||
foreach ($data->toArray() as $key => $item) {
|
foreach ($data->toArray() as $key => $item) {
|
||||||
$id = $this->propertyAccess->getValue($item, $options['reindex_path']);
|
$id = $this->propertyAccess->getValue($item, $options['reindex_path']);
|
||||||
//If element has an ID then use it. otherwise use default key
|
//If element has an ID then use it. otherwise use default key
|
||||||
$index = $id === null ? $key : $options['reindex_prefix'] . $id;
|
$index = null === $id ? $key : $options['reindex_prefix'].$id;
|
||||||
$error_mapping['[' . $key . ']'] = $index;
|
$error_mapping['['.$key.']'] = $index;
|
||||||
$reindexed_data->set($index, $item);
|
$reindexed_data->set($index, $item);
|
||||||
}
|
}
|
||||||
$event->setData($reindexed_data);
|
$event->setData($reindexed_data);
|
||||||
|
@ -103,9 +104,7 @@ 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....
|
||||||
* @param FormBuilder $builder
|
*
|
||||||
* @param string $option
|
|
||||||
* @param mixed $value
|
|
||||||
* @throws \ReflectionException
|
* @throws \ReflectionException
|
||||||
*/
|
*/
|
||||||
public function setOption(FormBuilder $builder, string $option, $value): void
|
public function setOption(FormBuilder $builder, string $option, $value): void
|
||||||
|
@ -119,4 +118,4 @@ class CollectionTypeExtension extends AbstractTypeExtension
|
||||||
$property->setValue($builder, $tmp);
|
$property->setValue($builder, $tmp);
|
||||||
$property->setAccessible(false);
|
$property->setAccessible(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,9 +45,6 @@ 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 Doctrine\ORM\EntityRepository;
|
|
||||||
use ReflectionClass;
|
|
||||||
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
|
||||||
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;
|
||||||
|
@ -62,36 +59,37 @@ class MasterPictureAttachmentType extends AbstractType
|
||||||
$resolver->setAllowedTypes('entity', HasMasterAttachmentInterface::class);
|
$resolver->setAllowedTypes('entity', HasMasterAttachmentInterface::class);
|
||||||
|
|
||||||
$resolver->setDefaults([
|
$resolver->setDefaults([
|
||||||
'filter' => 'picture',
|
'filter' => 'picture',
|
||||||
'choice_translation_domain' => false,
|
'choice_translation_domain' => false,
|
||||||
'attr' => [
|
'attr' => [
|
||||||
'class' => 'selectpicker',
|
'class' => 'selectpicker',
|
||||||
],
|
],
|
||||||
'choice_attr' => function (Options $options) {
|
'choice_attr' => function (Options $options) {
|
||||||
return function ($choice, $key, $value) use ($options) {
|
return function ($choice, $key, $value) use ($options) {
|
||||||
/** @var Attachment $choice */
|
/** @var Attachment $choice */
|
||||||
$tmp = ['data-subtext' => $choice->getFilename() ?? 'URL'];
|
$tmp = ['data-subtext' => $choice->getFilename() ?? 'URL'];
|
||||||
|
|
||||||
if ('picture' === $options['filter'] && ! $choice->isPicture()) {
|
if ('picture' === $options['filter'] && ! $choice->isPicture()) {
|
||||||
$tmp += ['disabled' => 'disabled'];
|
$tmp += ['disabled' => 'disabled'];
|
||||||
} elseif ('3d_model' === $options['filter'] && ! $choice->is3DModel()) {
|
} elseif ('3d_model' === $options['filter'] && ! $choice->is3DModel()) {
|
||||||
$tmp += ['disabled' => 'disabled'];
|
$tmp += ['disabled' => 'disabled'];
|
||||||
}
|
}
|
||||||
|
|
||||||
return $tmp;
|
return $tmp;
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
'choice_label' => 'name',
|
'choice_label' => 'name',
|
||||||
'choice_loader' => function (Options $options) {
|
'choice_loader' => function (Options $options) {
|
||||||
return new CallbackChoiceLoader(function () use ($options) {
|
return new CallbackChoiceLoader(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();
|
||||||
}
|
});
|
||||||
]);
|
},
|
||||||
|
]);
|
||||||
|
|
||||||
$resolver->setAllowedValues('filter', ['', 'picture', '3d_model']);
|
$resolver->setAllowedValues('filter', ['', 'picture', '3d_model']);
|
||||||
}
|
}
|
||||||
|
|
|
@ -85,35 +85,35 @@ class StructuralEntityType extends AbstractType
|
||||||
function ($value) use ($options) {
|
function ($value) use ($options) {
|
||||||
return $this->transform($value, $options);
|
return $this->transform($value, $options);
|
||||||
}, function ($value) use ($options) {
|
}, function ($value) use ($options) {
|
||||||
return $this->reverseTransform($value, $options);
|
return $this->reverseTransform($value, $options);
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function configureOptions(OptionsResolver $resolver): void
|
public function configureOptions(OptionsResolver $resolver): void
|
||||||
{
|
{
|
||||||
$resolver->setRequired(['class']);
|
$resolver->setRequired(['class']);
|
||||||
$resolver->setDefaults([
|
$resolver->setDefaults([
|
||||||
'show_fullpath_in_subtext' => true, //When this is enabled, the full path will be shown in subtext
|
'show_fullpath_in_subtext' => true, //When this is enabled, the full path will be shown in subtext
|
||||||
'subentities_of' => null, //Only show entities with the given parent class
|
'subentities_of' => null, //Only show entities with the given parent class
|
||||||
'disable_not_selectable' => false, //Disable entries with not selectable property
|
'disable_not_selectable' => false, //Disable entries with not selectable property
|
||||||
'choice_value' => 'id', //Use the element id as option value and for comparing items
|
'choice_value' => 'id', //Use the element id as option value and for comparing items
|
||||||
'choice_loader' => function (Options $options) {
|
'choice_loader' => function (Options $options) {
|
||||||
return new CallbackChoiceLoader(function () use ($options) {
|
return new CallbackChoiceLoader(function () use ($options) {
|
||||||
return $this->getEntries($options);
|
return $this->getEntries($options);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
'choice_label' => function (Options $options) {
|
'choice_label' => function (Options $options) {
|
||||||
return function ($choice, $key, $value) use ($options) {
|
return function ($choice, $key, $value) use ($options) {
|
||||||
return $this->generateChoiceLabels($choice, $key, $value, $options);
|
return $this->generateChoiceLabels($choice, $key, $value, $options);
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
'choice_attr' => function (Options $options) {
|
'choice_attr' => function (Options $options) {
|
||||||
return function ($choice, $key, $value) use ($options) {
|
return function ($choice, $key, $value) use ($options) {
|
||||||
return $this->generateChoiceAttr($choice, $key, $value, $options);
|
return $this->generateChoiceAttr($choice, $key, $value, $options);
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
'choice_translation_domain' => false, //Don't translate the entity names
|
'choice_translation_domain' => false, //Don't translate the entity names
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$resolver->setDefault('empty_message', null);
|
$resolver->setDefault('empty_message', null);
|
||||||
|
|
||||||
|
|
|
@ -12,23 +12,23 @@ use Doctrine\Migrations\AbstractMigration;
|
||||||
*/
|
*/
|
||||||
final class Version20200409130946 extends AbstractMigration
|
final class Version20200409130946 extends AbstractMigration
|
||||||
{
|
{
|
||||||
public function getDescription() : string
|
public function getDescription(): string
|
||||||
{
|
{
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function up(Schema $schema) : void
|
public function up(Schema $schema): void
|
||||||
{
|
{
|
||||||
// this up() migration is auto-generated, please modify it to your needs
|
// this up() migration is auto-generated, please modify it to your needs
|
||||||
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.');
|
$this->abortIf('mysql' !== $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'mysql\'.');
|
||||||
|
|
||||||
$this->addSql('ALTER TABLE u2f_keys CHANGE key_handle key_handle VARCHAR(128) NOT NULL');
|
$this->addSql('ALTER TABLE u2f_keys CHANGE key_handle key_handle VARCHAR(128) NOT NULL');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function down(Schema $schema) : void
|
public function down(Schema $schema): void
|
||||||
{
|
{
|
||||||
// this down() migration is auto-generated, please modify it to your needs
|
// this down() migration is auto-generated, please modify it to your needs
|
||||||
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.');
|
$this->abortIf('mysql' !== $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'mysql\'.');
|
||||||
|
|
||||||
$this->addSql('ALTER TABLE u2f_keys CHANGE key_handle key_handle VARCHAR(64) CHARACTER SET utf8mb4 NOT NULL COLLATE `utf8mb4_unicode_ci`');
|
$this->addSql('ALTER TABLE u2f_keys CHANGE key_handle key_handle VARCHAR(64) CHARACTER SET utf8mb4 NOT NULL COLLATE `utf8mb4_unicode_ci`');
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,7 +52,6 @@ use App\Entity\Parts\Storelocation;
|
||||||
use App\Entity\Parts\Supplier;
|
use App\Entity\Parts\Supplier;
|
||||||
use App\Entity\PriceInformations\Currency;
|
use App\Entity\PriceInformations\Currency;
|
||||||
use App\Entity\UserSystem\User;
|
use App\Entity\UserSystem\User;
|
||||||
|
|
||||||
use function get_class;
|
use function get_class;
|
||||||
use function is_object;
|
use function is_object;
|
||||||
|
|
||||||
|
|
|
@ -63,8 +63,8 @@ class AmountFormatter
|
||||||
* Formats the given value using the measurement unit and options.
|
* Formats the given value using the measurement unit and options.
|
||||||
*
|
*
|
||||||
* @param float|string|int $value
|
* @param float|string|int $value
|
||||||
* @param MeasurementUnit|null $unit The measurement unit, whose unit symbol should be used for formatting.
|
* @param MeasurementUnit|null $unit The measurement unit, whose unit symbol should be used for formatting.
|
||||||
* If set to null, it is assumed that the part amount is measured in pieces.
|
* If set to null, it is assumed that the part amount is measured in pieces.
|
||||||
*
|
*
|
||||||
* @return string The formatted string
|
* @return string The formatted string
|
||||||
*
|
*
|
||||||
|
|
|
@ -130,7 +130,7 @@ class AttachmentURLGenerator
|
||||||
throw new InvalidArgumentException('Thumbnail creation only works for picture attachments!');
|
throw new InvalidArgumentException('Thumbnail creation only works for picture attachments!');
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($attachment->isExternal() && !empty($attachment->getURL())) {
|
if ($attachment->isExternal() && ! empty($attachment->getURL())) {
|
||||||
return $attachment->getURL();
|
return $attachment->getURL();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -43,10 +43,10 @@ declare(strict_types=1);
|
||||||
namespace App\Services\Attachments;
|
namespace App\Services\Attachments;
|
||||||
|
|
||||||
use App\Entity\Attachments\Attachment;
|
use App\Entity\Attachments\Attachment;
|
||||||
|
use Psr\Cache\InvalidArgumentException;
|
||||||
use Symfony\Component\Finder\Finder;
|
use Symfony\Component\Finder\Finder;
|
||||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||||
use Symfony\Contracts\Cache\CacheInterface;
|
use Symfony\Contracts\Cache\CacheInterface;
|
||||||
use Psr\Cache\InvalidArgumentException;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This service is used to find builtin attachment ressources.
|
* This service is used to find builtin attachment ressources.
|
||||||
|
|
|
@ -44,7 +44,6 @@ namespace App\Services;
|
||||||
|
|
||||||
use App\Entity\Attachments\Attachment;
|
use App\Entity\Attachments\Attachment;
|
||||||
use App\Entity\Attachments\AttachmentType;
|
use App\Entity\Attachments\AttachmentType;
|
||||||
use App\Entity\Base\AbstractDBElement;
|
|
||||||
use App\Entity\Contracts\NamedElementInterface;
|
use App\Entity\Contracts\NamedElementInterface;
|
||||||
use App\Entity\Devices\Device;
|
use App\Entity\Devices\Device;
|
||||||
use App\Entity\Parameters\AbstractParameter;
|
use App\Entity\Parameters\AbstractParameter;
|
||||||
|
|
|
@ -79,7 +79,7 @@ class EntityExporter
|
||||||
/**
|
/**
|
||||||
* Exports an Entity or an array of entities to multiple file formats.
|
* Exports an Entity or an array of entities to multiple file formats.
|
||||||
*
|
*
|
||||||
* @param Request $request the request that should be used for option resolving
|
* @param Request $request the request that should be used for option resolving
|
||||||
* @param AbstractNamedDBElement|object[] $entity
|
* @param AbstractNamedDBElement|object[] $entity
|
||||||
*
|
*
|
||||||
* @return Response the generated response containing the exported data
|
* @return Response the generated response containing the exported data
|
||||||
|
|
|
@ -94,7 +94,7 @@ class EntityURLGenerator
|
||||||
* @param mixed $entity The element for which the page should be generated
|
* @param mixed $entity The element for which the page should be generated
|
||||||
* @param string $type The page type. Currently supported: 'info', 'edit', 'create', 'clone', 'list'/'list_parts'
|
* @param string $type The page type. Currently supported: 'info', 'edit', 'create', 'clone', 'list'/'list_parts'
|
||||||
*
|
*
|
||||||
* @return null|string the link to the desired page
|
* @return string|null the link to the desired page
|
||||||
*
|
*
|
||||||
* @throws EntityNotSupportedException thrown if the entity is not supported for the given type
|
* @throws EntityNotSupportedException thrown if the entity is not supported for the given type
|
||||||
* @throws InvalidArgumentException thrown if the givent type is not existing
|
* @throws InvalidArgumentException thrown if the givent type is not existing
|
||||||
|
|
|
@ -49,7 +49,6 @@ use App\Security\Interfaces\HasPermissionsInterface;
|
||||||
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;
|
||||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
|
||||||
use Symfony\Component\Yaml\Yaml;
|
use Symfony\Component\Yaml\Yaml;
|
||||||
|
|
||||||
class PermissionResolver
|
class PermissionResolver
|
||||||
|
|
|
@ -176,7 +176,7 @@ class PricedetailHelper
|
||||||
|
|
||||||
$converted = $this->convertMoneyToCurrency($pricedetail->getPricePerUnit(), $pricedetail->getCurrency(), $currency);
|
$converted = $this->convertMoneyToCurrency($pricedetail->getPricePerUnit(), $pricedetail->getCurrency(), $currency);
|
||||||
//Ignore price informations that can not be converted to base currency.
|
//Ignore price informations that can not be converted to base currency.
|
||||||
if ($converted !== null) {
|
if (null !== $converted) {
|
||||||
$avg = bcadd($avg, $converted, Pricedetail::PRICE_PRECISION);
|
$avg = bcadd($avg, $converted, Pricedetail::PRICE_PRECISION);
|
||||||
++$count;
|
++$count;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue