mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-22 01:49:05 +02:00
Fixed coding style.
This commit is contained in:
parent
0a94689d98
commit
f2ff77a8b3
44 changed files with 435 additions and 387 deletions
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
|
@ -21,14 +24,10 @@
|
|||
|
||||
namespace App\DataTables;
|
||||
|
||||
|
||||
use App\DataTables\Column\EntityColumn;
|
||||
use App\DataTables\Column\LocaleDateTimeColumn;
|
||||
use App\DataTables\Column\LogEntryExtraColumn;
|
||||
use App\DataTables\Column\LogEntryTargetColumn;
|
||||
use App\Entity\Attachments\Attachment;
|
||||
use App\Entity\LogSystem\AbstractLogEntry;
|
||||
use App\Entity\UserSystem\User;
|
||||
use App\Services\ElementTypeNameGenerator;
|
||||
use Doctrine\ORM\QueryBuilder;
|
||||
use Omines\DataTablesBundle\Adapter\Doctrine\ORMAdapter;
|
||||
|
@ -36,7 +35,6 @@ use Omines\DataTablesBundle\Column\TextColumn;
|
|||
use Omines\DataTablesBundle\DataTable;
|
||||
use Omines\DataTablesBundle\DataTableTypeInterface;
|
||||
use Psr\Log\LogLevel;
|
||||
use SebastianBergmann\CodeCoverage\Report\Text;
|
||||
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
|
||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
|
||||
|
@ -54,7 +52,7 @@ class LogDataTable implements DataTableTypeInterface
|
|||
$this->urlGenerator = $urlGenerator;
|
||||
}
|
||||
|
||||
public function configure(DataTable $dataTable, array $options)
|
||||
public function configure(DataTable $dataTable, array $options): void
|
||||
{
|
||||
$dataTable->add('symbol', TextColumn::class, [
|
||||
'label' => '',
|
||||
|
@ -62,35 +60,44 @@ class LogDataTable implements DataTableTypeInterface
|
|||
switch ($context->getLevelString()) {
|
||||
case LogLevel::DEBUG:
|
||||
$symbol = 'fa-bug';
|
||||
|
||||
break;
|
||||
case LogLevel::INFO:
|
||||
$symbol = 'fa-info';
|
||||
|
||||
break;
|
||||
case LogLevel::NOTICE:
|
||||
$symbol = 'fa-flag';
|
||||
|
||||
break;
|
||||
case LogLevel::WARNING:
|
||||
$symbol = 'fa-exclamation-circle';
|
||||
|
||||
break;
|
||||
case LogLevel::ERROR:
|
||||
$symbol = 'fa-exclamation-triangle';
|
||||
|
||||
break;
|
||||
case LogLevel::CRITICAL:
|
||||
$symbol = 'fa-bolt';
|
||||
|
||||
break;
|
||||
case LogLevel::ALERT:
|
||||
$symbol = 'fa-radiation';
|
||||
|
||||
break;
|
||||
case LogLevel::EMERGENCY:
|
||||
$symbol = 'fa-skull-crossbones';
|
||||
|
||||
break;
|
||||
default:
|
||||
$symbol = 'fa-question-circle';
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
return sprintf('<i class="fas fa-fw %s"></i>', $symbol);
|
||||
}
|
||||
},
|
||||
]);
|
||||
|
||||
$dataTable->add('id', TextColumn::class, [
|
||||
|
@ -100,16 +107,15 @@ class LogDataTable implements DataTableTypeInterface
|
|||
|
||||
$dataTable->add('timestamp', LocaleDateTimeColumn::class, [
|
||||
'label' => $this->translator->trans('log.timestamp'),
|
||||
'timeFormat' => 'medium'
|
||||
'timeFormat' => 'medium',
|
||||
]);
|
||||
|
||||
$dataTable->add('type', TextColumn::class, [
|
||||
'label' => $this->translator->trans('log.type'),
|
||||
'propertyPath' => 'type',
|
||||
'render' => function (string $value, AbstractLogEntry $context) {
|
||||
return $this->translator->trans('log.type.' . $value);
|
||||
}
|
||||
|
||||
return $this->translator->trans('log.type.'.$value);
|
||||
},
|
||||
]);
|
||||
|
||||
$dataTable->add('level', TextColumn::class, [
|
||||
|
@ -117,42 +123,41 @@ class LogDataTable implements DataTableTypeInterface
|
|||
'propertyPath' => 'levelString',
|
||||
'render' => function (string $value, AbstractLogEntry $context) {
|
||||
return $value;
|
||||
}
|
||||
},
|
||||
]);
|
||||
|
||||
|
||||
$dataTable->add('user', TextColumn::class, [
|
||||
'label' => $this->translator->trans('log.user'),
|
||||
'render' => function ($value, AbstractLogEntry $context) {
|
||||
$user = $context->getUser();
|
||||
|
||||
return sprintf(
|
||||
'<a href="%s">%s</a>',
|
||||
$this->urlGenerator->generate('user_info', ['id' => $user->getID()]),
|
||||
$user->getFullName(true)
|
||||
);
|
||||
}
|
||||
},
|
||||
]);
|
||||
|
||||
|
||||
|
||||
$dataTable->add('target_type', TextColumn::class, [
|
||||
'label' => $this->translator->trans('log.target_type'),
|
||||
'visible' => false,
|
||||
'render' => function ($value, AbstractLogEntry $context) {
|
||||
$class = $context->getTargetClass();
|
||||
if ($class !== null) {
|
||||
if (null !== $class) {
|
||||
return $this->elementTypeNameGenerator->getLocalizedTypeLabel($class);
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
},
|
||||
]);
|
||||
|
||||
$dataTable->add('target', LogEntryTargetColumn::class, [
|
||||
'label' => $this->translator->trans('log.target')
|
||||
'label' => $this->translator->trans('log.target'),
|
||||
]);
|
||||
|
||||
$dataTable->add('extra', LogEntryExtraColumn::class, [
|
||||
'label' => $this->translator->trans('log.extra')
|
||||
'label' => $this->translator->trans('log.extra'),
|
||||
]);
|
||||
|
||||
$dataTable->addOrderBy('timestamp', DataTable::SORT_DESCENDING);
|
||||
|
@ -172,4 +177,4 @@ class LogDataTable implements DataTableTypeInterface
|
|||
->from(AbstractLogEntry::class, 'log')
|
||||
->leftJoin('log.user', 'user');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue