mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-07-01 14:04:30 +02:00
Fixed code style.
This commit is contained in:
parent
2853e471c4
commit
d0b1024d80
212 changed files with 495 additions and 1005 deletions
|
@ -200,8 +200,6 @@ class EventLoggerSubscriber implements EventSubscriber
|
|||
|
||||
/**
|
||||
* Checks if the field of the given element should be saved (if it is not blacklisted).
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function shouldFieldBeSaved(AbstractDBElement $element, string $field_name): bool
|
||||
{
|
||||
|
@ -297,14 +295,12 @@ class EventLoggerSubscriber implements EventSubscriber
|
|||
|
||||
/**
|
||||
* Filter out every forbidden field and return the cleaned array.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function filterFieldRestrictions(AbstractDBElement $element, array $fields): array
|
||||
{
|
||||
unset($fields['lastModified']);
|
||||
|
||||
if (! $this->hasFieldRestrictions($element)) {
|
||||
if (!$this->hasFieldRestrictions($element)) {
|
||||
return $fields;
|
||||
}
|
||||
|
||||
|
@ -322,7 +318,7 @@ class EventLoggerSubscriber implements EventSubscriber
|
|||
{
|
||||
$uow = $em->getUnitOfWork();
|
||||
|
||||
if (! $logEntry instanceof ElementEditedLogEntry && ! $logEntry instanceof ElementDeletedLogEntry) {
|
||||
if (!$logEntry instanceof ElementEditedLogEntry && !$logEntry instanceof ElementDeletedLogEntry) {
|
||||
throw new \InvalidArgumentException('$logEntry must be ElementEditedLogEntry or ElementDeletedLogEntry!');
|
||||
}
|
||||
|
||||
|
@ -349,12 +345,12 @@ class EventLoggerSubscriber implements EventSubscriber
|
|||
/**
|
||||
* Check if the given entity can be logged.
|
||||
*
|
||||
* @return bool True, if the given entity can be logged.
|
||||
* @return bool true, if the given entity can be logged
|
||||
*/
|
||||
protected function validEntity(object $entity): bool
|
||||
{
|
||||
//Dont log logentries itself!
|
||||
if ($entity instanceof AbstractDBElement && ! $entity instanceof AbstractLogEntry) {
|
||||
if ($entity instanceof AbstractDBElement && !$entity instanceof AbstractLogEntry) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -49,7 +49,7 @@ class LogAccessDeniedSubscriber implements EventSubscriberInterface
|
|||
$throwable = $throwable->getPrevious();
|
||||
}
|
||||
//Ignore everything except AccessDeniedExceptions
|
||||
if (! $throwable instanceof AccessDeniedException) {
|
||||
if (!$throwable instanceof AccessDeniedException) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -48,7 +48,6 @@ use Doctrine\Common\EventSubscriber;
|
|||
use Doctrine\Migrations\DependencyFactory;
|
||||
use Doctrine\Migrations\Event\MigrationsEventArgs;
|
||||
use Doctrine\Migrations\Events;
|
||||
use Doctrine\Migrations\Version\AliasResolver;
|
||||
|
||||
/**
|
||||
* This subscriber logs databaseMigrations to Event log.
|
||||
|
|
|
@ -45,11 +45,7 @@ namespace App\EventSubscriber\LogSystem;
|
|||
use App\Entity\LogSystem\UserLogoutLogEntry;
|
||||
use App\Entity\UserSystem\User;
|
||||
use App\Services\LogSystem\EventLogger;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
|
||||
use Symfony\Component\Security\Http\Event\LogoutEvent;
|
||||
use Symfony\Component\Security\Http\Logout\LogoutHandlerInterface;
|
||||
|
||||
/**
|
||||
* This handler logs to event log, if a user logs out.
|
||||
|
@ -65,13 +61,12 @@ class LogoutLoggerListener
|
|||
$this->gpdr_compliance = $gpdr_compliance;
|
||||
}
|
||||
|
||||
|
||||
public function __invoke(LogoutEvent $event)
|
||||
{
|
||||
$request = $event->getRequest();
|
||||
$token = $event->getToken();
|
||||
|
||||
if ($token === null) {
|
||||
if (null === $token) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -82,7 +82,7 @@ final class SymfonyDebugToolbarSubscriber implements EventSubscriberInterface
|
|||
|
||||
public function onKernelResponse(ResponseEvent $event): void
|
||||
{
|
||||
if (! $this->kernel_debug) {
|
||||
if (!$this->kernel_debug) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -44,7 +44,6 @@ namespace App\EventSubscriber\UserSystem;
|
|||
|
||||
use App\Entity\UserSystem\User;
|
||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||
use Symfony\Component\HttpFoundation\Session\Flash\FlashBagInterface;
|
||||
use Symfony\Component\HttpFoundation\Session\Session;
|
||||
use Symfony\Component\HttpFoundation\Session\SessionInterface;
|
||||
use Symfony\Component\HttpKernel\Event\RequestEvent;
|
||||
|
@ -97,15 +96,15 @@ final class PasswordChangeNeededSubscriber implements EventSubscriberInterface
|
|||
$user = $this->security->getUser();
|
||||
$request = $event->getRequest();
|
||||
|
||||
if (! $event->isMasterRequest()) {
|
||||
if (!$event->isMasterRequest()) {
|
||||
return;
|
||||
}
|
||||
if (! $user instanceof User) {
|
||||
if (!$user instanceof User) {
|
||||
return;
|
||||
}
|
||||
|
||||
//Abort if we dont need to redirect the user.
|
||||
if (! $user->isNeedPwChange() && ! static::TFARedirectNeeded($user)) {
|
||||
if (!$user->isNeedPwChange() && !static::TFARedirectNeeded($user)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -140,15 +139,15 @@ final class PasswordChangeNeededSubscriber implements EventSubscriberInterface
|
|||
* That is the case if the group of the user enforces 2FA, but the user has neither Google Authenticator nor an
|
||||
* U2F key setup.
|
||||
*
|
||||
* @param User $user The user for which should be checked if it needs to be redirected.
|
||||
* @param User $user the user for which should be checked if it needs to be redirected
|
||||
*
|
||||
* @return bool True if the user needs to be redirected.
|
||||
* @return bool true if the user needs to be redirected
|
||||
*/
|
||||
public static function TFARedirectNeeded(User $user): bool
|
||||
{
|
||||
$tfa_enabled = $user->isU2FAuthEnabled() || $user->isGoogleAuthenticatorEnabled();
|
||||
|
||||
if (null !== $user->getGroup() && $user->getGroup()->isEnforce2FA() && ! $tfa_enabled) {
|
||||
if (null !== $user->getGroup() && $user->getGroup()->isEnforce2FA() && !$tfa_enabled) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -51,7 +51,6 @@ use R\U2FTwoFactorBundle\Event\RegisterEvent;
|
|||
use Symfony\Component\EventDispatcher\EventDispatcher;
|
||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||
use Symfony\Component\HttpFoundation\RedirectResponse;
|
||||
use Symfony\Component\HttpFoundation\Session\Flash\FlashBagInterface;
|
||||
use Symfony\Component\HttpFoundation\Session\Session;
|
||||
use Symfony\Component\HttpFoundation\Session\SessionInterface;
|
||||
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
|
||||
|
@ -96,9 +95,9 @@ final class RegisterU2FSubscriber implements EventSubscriberInterface
|
|||
public function onRegister(RegisterEvent $event): void
|
||||
{
|
||||
//Skip adding of U2F key on demo mode
|
||||
if (! $this->demo_mode) {
|
||||
if (!$this->demo_mode) {
|
||||
$user = $event->getUser();
|
||||
if (! $user instanceof User) {
|
||||
if (!$user instanceof User) {
|
||||
throw new \InvalidArgumentException('Only User objects can be registered for U2F!');
|
||||
}
|
||||
|
||||
|
|
|
@ -68,12 +68,12 @@ final class SetUserTimezoneSubscriber implements EventSubscriberInterface
|
|||
|
||||
//Check if the user has set a timezone
|
||||
$user = $this->security->getUser();
|
||||
if ($user instanceof User && ! empty($user->getTimezone())) {
|
||||
if ($user instanceof User && !empty($user->getTimezone())) {
|
||||
$timezone = $user->getTimezone();
|
||||
}
|
||||
|
||||
//Fill with default value if needed
|
||||
if (null === $timezone && ! empty($this->default_timezone)) {
|
||||
if (null === $timezone && !empty($this->default_timezone)) {
|
||||
$timezone = $this->default_timezone;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue