mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-30 13:34:28 +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).
|
||||
*
|
||||
|
@ -34,35 +37,72 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
|
|||
* Similar to ORMAdapter this class allows to access objects from the doctrine ORM.
|
||||
* Unlike the default ORMAdapter supports Fetch Joins (additional entites are fetched from DB via joins) using
|
||||
* the Doctrine Paginator.
|
||||
*
|
||||
* @author Jan Böhmer
|
||||
*/
|
||||
class FetchJoinORMAdapter extends ORMAdapter
|
||||
{
|
||||
protected $use_simple_total;
|
||||
|
||||
public function configure(array $options)
|
||||
public function configure(array $options): void
|
||||
{
|
||||
parent::configure($options);
|
||||
$this->use_simple_total = $options['simple_total_query'];
|
||||
}
|
||||
|
||||
protected function configureOptions(OptionsResolver $resolver)
|
||||
public function getResults(AdapterQuery $query): \Traversable
|
||||
{
|
||||
$builder = $query->get('qb');
|
||||
$state = $query->getState();
|
||||
|
||||
// Apply definitive view state for current 'page' of the table
|
||||
foreach ($state->getOrderBy() as [$column, $direction]) {
|
||||
/** @var AbstractColumn $column */
|
||||
if ($column->isOrderable()) {
|
||||
$builder->addOrderBy($column->getOrderField(), $direction);
|
||||
}
|
||||
}
|
||||
if ($state->getLength() > 0) {
|
||||
$builder
|
||||
->setFirstResult($state->getStart())
|
||||
->setMaxResults($state->getLength());
|
||||
}
|
||||
|
||||
$query = $builder->getQuery();
|
||||
$event = new ORMAdapterQueryEvent($query);
|
||||
$state->getDataTable()->getEventDispatcher()->dispatch($event, ORMAdapterEvents::PRE_QUERY);
|
||||
|
||||
//Use Doctrine paginator for result iteration
|
||||
$paginator = new Paginator($query);
|
||||
|
||||
foreach ($paginator->getIterator() as $result) {
|
||||
yield $result;
|
||||
$this->manager->detach($result);
|
||||
}
|
||||
}
|
||||
|
||||
public function getCount(QueryBuilder $queryBuilder, $identifier)
|
||||
{
|
||||
$paginator = new Paginator($queryBuilder);
|
||||
|
||||
return $paginator->count();
|
||||
}
|
||||
|
||||
protected function configureOptions(OptionsResolver $resolver): void
|
||||
{
|
||||
parent::configureOptions($resolver);
|
||||
|
||||
//Enforce object hydration mode (fetch join only works for objects)
|
||||
$resolver->addAllowedValues('hydrate', Query::HYDRATE_OBJECT);
|
||||
|
||||
/**
|
||||
/*
|
||||
* Add the possibility to replace the query for total entity count through a very simple one, to improve performance.
|
||||
* You can only use this option, if you did not apply any criteria to your total count.
|
||||
*/
|
||||
$resolver->setDefault('simple_total_query', false);
|
||||
|
||||
return $resolver;
|
||||
}
|
||||
|
||||
protected function prepareQuery(AdapterQuery $query)
|
||||
protected function prepareQuery(AdapterQuery $query): void
|
||||
{
|
||||
$state = $query->getState();
|
||||
$query->set('qb', $builder = $this->createQueryBuilder($state));
|
||||
|
@ -96,43 +136,6 @@ class FetchJoinORMAdapter extends ORMAdapter
|
|||
$query->setIdentifierPropertyPath($this->mapFieldToPropertyPath($identifier, $aliases));
|
||||
}
|
||||
|
||||
public function getResults(AdapterQuery $query): \Traversable
|
||||
{
|
||||
$builder = $query->get('qb');
|
||||
$state = $query->getState();
|
||||
|
||||
// Apply definitive view state for current 'page' of the table
|
||||
foreach ($state->getOrderBy() as list($column, $direction)) {
|
||||
/** @var AbstractColumn $column */
|
||||
if ($column->isOrderable()) {
|
||||
$builder->addOrderBy($column->getOrderField(), $direction);
|
||||
}
|
||||
}
|
||||
if ($state->getLength() > 0) {
|
||||
$builder
|
||||
->setFirstResult($state->getStart())
|
||||
->setMaxResults($state->getLength());
|
||||
}
|
||||
|
||||
$query = $builder->getQuery();
|
||||
$event = new ORMAdapterQueryEvent($query);
|
||||
$state->getDataTable()->getEventDispatcher()->dispatch($event, ORMAdapterEvents::PRE_QUERY);
|
||||
|
||||
//Use Doctrine paginator for result iteration
|
||||
$paginator = new Paginator($query);
|
||||
|
||||
foreach ($paginator->getIterator() as $result) {
|
||||
yield $result;
|
||||
$this->manager->detach($result);
|
||||
}
|
||||
}
|
||||
|
||||
public function getCount(QueryBuilder $queryBuilder, $identifier)
|
||||
{
|
||||
$paginator = new Paginator($queryBuilder);
|
||||
return $paginator->count();
|
||||
}
|
||||
|
||||
protected function getSimpleTotalCount(QueryBuilder $queryBuilder)
|
||||
{
|
||||
/** The paginator count queries can be rather slow, so when query for total count (100ms or longer),
|
||||
|
@ -140,6 +143,7 @@ class FetchJoinORMAdapter extends ORMAdapter
|
|||
*/
|
||||
/** @var Query\Expr\From $from_expr */
|
||||
$from_expr = $queryBuilder->getDQLPart('from')[0];
|
||||
|
||||
return $this->manager->getRepository($from_expr->getFrom())->count([]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,28 +37,27 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
|
|||
*/
|
||||
class ORMAdapter extends AbstractAdapter
|
||||
{
|
||||
/** @var ManagerRegistry */
|
||||
private $registry;
|
||||
|
||||
/** @var EntityManager */
|
||||
protected $manager;
|
||||
|
||||
/** @var \Doctrine\ORM\Mapping\ClassMetadata */
|
||||
protected $metadata;
|
||||
|
||||
/** @var QueryBuilderProcessorInterface[] */
|
||||
protected $criteriaProcessors;
|
||||
/** @var ManagerRegistry */
|
||||
private $registry;
|
||||
|
||||
/** @var int */
|
||||
private $hydrationMode;
|
||||
|
||||
/** @var QueryBuilderProcessorInterface[] */
|
||||
private $queryBuilderProcessors;
|
||||
|
||||
/** @var QueryBuilderProcessorInterface[] */
|
||||
protected $criteriaProcessors;
|
||||
|
||||
/**
|
||||
* DoctrineAdapter constructor.
|
||||
*/
|
||||
public function __construct(ManagerRegistry $registry = null)
|
||||
public function __construct(?ManagerRegistry $registry = null)
|
||||
{
|
||||
if (null === $registry) {
|
||||
throw new MissingDependencyException('Install doctrine/doctrine-bundle to use the ORMAdapter');
|
||||
|
@ -68,10 +67,7 @@ class ORMAdapter extends AbstractAdapter
|
|||
$this->registry = $registry;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function configure(array $options)
|
||||
public function configure(array $options): void
|
||||
{
|
||||
$resolver = new OptionsResolver();
|
||||
$this->configureOptions($resolver);
|
||||
|
@ -92,15 +88,12 @@ class ORMAdapter extends AbstractAdapter
|
|||
$this->criteriaProcessors = $options['criteria'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $processor
|
||||
*/
|
||||
public function addCriteriaProcessor($processor)
|
||||
public function addCriteriaProcessor($processor): void
|
||||
{
|
||||
$this->criteriaProcessors[] = $this->normalizeProcessor($processor);
|
||||
}
|
||||
|
||||
protected function prepareQuery(AdapterQuery $query)
|
||||
protected function prepareQuery(AdapterQuery $query): void
|
||||
{
|
||||
$state = $query->getState();
|
||||
$query->set('qb', $builder = $this->createQueryBuilder($state));
|
||||
|
@ -150,7 +143,7 @@ class ORMAdapter extends AbstractAdapter
|
|||
continue;
|
||||
}
|
||||
|
||||
list($origin, $target) = explode('.', $join->getJoin());
|
||||
[$origin, $target] = explode('.', $join->getJoin());
|
||||
|
||||
$mapping = $aliases[$origin][1]->getAssociationMapping($target);
|
||||
$aliases[$join->getAlias()] = [$join->getJoin(), $this->manager->getMetadataFactory()->getMetadataFor($mapping['targetEntity'])];
|
||||
|
@ -160,9 +153,6 @@ class ORMAdapter extends AbstractAdapter
|
|||
return $aliases;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function mapPropertyPath(AdapterQuery $query, AbstractColumn $column)
|
||||
{
|
||||
return $this->mapFieldToPropertyPath($column->getField(), $query->get('aliases'));
|
||||
|
@ -175,7 +165,7 @@ class ORMAdapter extends AbstractAdapter
|
|||
$state = $query->getState();
|
||||
|
||||
// Apply definitive view state for current 'page' of the table
|
||||
foreach ($state->getOrderBy() as list($column, $direction)) {
|
||||
foreach ($state->getOrderBy() as [$column, $direction]) {
|
||||
/** @var AbstractColumn $column */
|
||||
if ($column->isOrderable()) {
|
||||
$builder->addOrderBy($column->getOrderField(), $direction);
|
||||
|
@ -200,7 +190,7 @@ class ORMAdapter extends AbstractAdapter
|
|||
}
|
||||
}
|
||||
|
||||
protected function buildCriteria(QueryBuilder $queryBuilder, DataTableState $state)
|
||||
protected function buildCriteria(QueryBuilder $queryBuilder, DataTableState $state): void
|
||||
{
|
||||
foreach ($this->criteriaProcessors as $provider) {
|
||||
$provider->process($queryBuilder, $state);
|
||||
|
@ -222,6 +212,7 @@ class ORMAdapter extends AbstractAdapter
|
|||
|
||||
/**
|
||||
* @param $identifier
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
protected function getCount(QueryBuilder $queryBuilder, $identifier)
|
||||
|
@ -230,21 +221,21 @@ class ORMAdapter extends AbstractAdapter
|
|||
|
||||
$qb->resetDQLPart('orderBy');
|
||||
$gb = $qb->getDQLPart('groupBy');
|
||||
if (empty($gb) || !$this->hasGroupByPart($identifier, $gb)) {
|
||||
if (empty($gb) || ! $this->hasGroupByPart($identifier, $gb)) {
|
||||
$qb->select($qb->expr()->count($identifier));
|
||||
|
||||
return (int) $qb->getQuery()->getSingleScalarResult();
|
||||
} else {
|
||||
$qb->resetDQLPart('groupBy');
|
||||
$qb->select($qb->expr()->countDistinct($identifier));
|
||||
|
||||
return (int) $qb->getQuery()->getSingleScalarResult();
|
||||
}
|
||||
$qb->resetDQLPart('groupBy');
|
||||
$qb->select($qb->expr()->countDistinct($identifier));
|
||||
|
||||
return (int) $qb->getQuery()->getSingleScalarResult();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $identifier
|
||||
* @param Query\Expr\GroupBy[] $gbList
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected function hasGroupByPart($identifier, array $gbList)
|
||||
|
@ -260,6 +251,7 @@ class ORMAdapter extends AbstractAdapter
|
|||
|
||||
/**
|
||||
* @param string $field
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function mapFieldToPropertyPath($field, array $aliases = [])
|
||||
|
@ -268,25 +260,25 @@ class ORMAdapter extends AbstractAdapter
|
|||
if (count($parts) < 2) {
|
||||
throw new InvalidConfigurationException(sprintf("Field name '%s' must consist at least of an alias and a field separated with a period", $field));
|
||||
}
|
||||
list($origin, $target) = $parts;
|
||||
[$origin, $target] = $parts;
|
||||
|
||||
$path = [$target];
|
||||
$current = $aliases[$origin][0];
|
||||
|
||||
while (null !== $current) {
|
||||
list($origin, $target) = explode('.', $current);
|
||||
[$origin, $target] = explode('.', $current);
|
||||
$path[] = $target;
|
||||
$current = $aliases[$origin][0];
|
||||
}
|
||||
|
||||
if (Query::HYDRATE_ARRAY === $this->hydrationMode) {
|
||||
return '[' . implode('][', array_reverse($path)) . ']';
|
||||
} else {
|
||||
return implode('.', array_reverse($path));
|
||||
return '['.implode('][', array_reverse($path)).']';
|
||||
}
|
||||
|
||||
return implode('.', array_reverse($path));
|
||||
}
|
||||
|
||||
protected function configureOptions(OptionsResolver $resolver)
|
||||
protected function configureOptions(OptionsResolver $resolver): void
|
||||
{
|
||||
$providerNormalizer = function (Options $options, $value) {
|
||||
return array_map([$this, 'normalizeProcessor'], (array) $value);
|
||||
|
@ -294,12 +286,12 @@ class ORMAdapter extends AbstractAdapter
|
|||
|
||||
$resolver
|
||||
->setDefaults([
|
||||
'hydrate' => Query::HYDRATE_OBJECT,
|
||||
'query' => [],
|
||||
'criteria' => function (Options $options) {
|
||||
return [new SearchCriteriaProvider()];
|
||||
},
|
||||
])
|
||||
'hydrate' => Query::HYDRATE_OBJECT,
|
||||
'query' => [],
|
||||
'criteria' => function (Options $options) {
|
||||
return [new SearchCriteriaProvider()];
|
||||
},
|
||||
])
|
||||
->setRequired('entity')
|
||||
->setAllowedTypes('entity', ['string'])
|
||||
->setAllowedTypes('hydrate', 'int')
|
||||
|
@ -312,6 +304,7 @@ class ORMAdapter extends AbstractAdapter
|
|||
|
||||
/**
|
||||
* @param callable|QueryBuilderProcessorInterface $provider
|
||||
*
|
||||
* @return QueryBuilderProcessorInterface
|
||||
*/
|
||||
private function normalizeProcessor($provider)
|
||||
|
|
|
@ -40,11 +40,11 @@ use Symfony\Contracts\Translation\TranslatorInterface;
|
|||
|
||||
final class AttachmentDataTable implements DataTableTypeInterface
|
||||
{
|
||||
protected $translator;
|
||||
protected $entityURLGenerator;
|
||||
protected $attachmentHelper;
|
||||
protected $elementTypeNameGenerator;
|
||||
protected $attachmentURLGenerator;
|
||||
private $translator;
|
||||
private $entityURLGenerator;
|
||||
private $attachmentHelper;
|
||||
private $elementTypeNameGenerator;
|
||||
private $attachmentURLGenerator;
|
||||
|
||||
public function __construct(TranslatorInterface $translator, EntityURLGenerator $entityURLGenerator,
|
||||
AttachmentManager $attachmentHelper, AttachmentURLGenerator $attachmentURLGenerator,
|
||||
|
@ -203,7 +203,7 @@ final class AttachmentDataTable implements DataTableTypeInterface
|
|||
]);
|
||||
}
|
||||
|
||||
protected function getQuery(QueryBuilder $builder): void
|
||||
private function getQuery(QueryBuilder $builder): void
|
||||
{
|
||||
$builder->distinct()->select('attachment')
|
||||
->addSelect('attachment_type')
|
||||
|
|
|
@ -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,16 +24,6 @@
|
|||
|
||||
namespace App\DataTables\Column;
|
||||
|
||||
|
||||
use App\Entity\LogSystem\DatabaseUpdatedLogEntry;
|
||||
use App\Entity\LogSystem\ElementCreatedLogEntry;
|
||||
use App\Entity\LogSystem\ElementDeletedLogEntry;
|
||||
use App\Entity\LogSystem\ElementEditedLogEntry;
|
||||
use App\Entity\LogSystem\ExceptionLogEntry;
|
||||
use App\Entity\LogSystem\InstockChangedLogEntry;
|
||||
use App\Entity\LogSystem\UserLoginLogEntry;
|
||||
use App\Entity\LogSystem\UserLogoutLogEntry;
|
||||
use App\Entity\LogSystem\UserNotAllowedLogEntry;
|
||||
use App\Services\LogSystem\LogEntryExtraFormatter;
|
||||
use Omines\DataTablesBundle\Column\AbstractColumn;
|
||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
|
@ -46,9 +39,6 @@ class LogEntryExtraColumn extends AbstractColumn
|
|||
$this->formatter = $formatter;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function normalize($value)
|
||||
{
|
||||
return $value;
|
||||
|
@ -58,4 +48,4 @@ class LogEntryExtraColumn extends AbstractColumn
|
|||
{
|
||||
return $this->formatter->format($context);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
|
@ -24,7 +27,6 @@ namespace App\DataTables\Column;
|
|||
use App\Entity\Base\DBElement;
|
||||
use App\Entity\Base\NamedDBElement;
|
||||
use App\Entity\LogSystem\AbstractLogEntry;
|
||||
use App\Repository\LogEntryRepository;
|
||||
use App\Services\ElementTypeNameGenerator;
|
||||
use App\Services\EntityURLGenerator;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
|
@ -34,7 +36,6 @@ use Symfony\Contracts\Translation\TranslatorInterface;
|
|||
|
||||
class LogEntryTargetColumn extends AbstractColumn
|
||||
{
|
||||
|
||||
protected $em;
|
||||
protected $entryRepository;
|
||||
protected $entityURLGenerator;
|
||||
|
@ -52,15 +53,12 @@ class LogEntryTargetColumn extends AbstractColumn
|
|||
$this->translator = $translator;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function normalize($value)
|
||||
{
|
||||
return $value;
|
||||
}
|
||||
|
||||
public function configureOptions(OptionsResolver $resolver)
|
||||
public function configureOptions(OptionsResolver $resolver): void
|
||||
{
|
||||
parent::configureOptions($resolver);
|
||||
}
|
||||
|
@ -89,7 +87,7 @@ class LogEntryTargetColumn extends AbstractColumn
|
|||
}
|
||||
|
||||
//Element was deleted
|
||||
if ($target === null && $context->hasTarget()) {
|
||||
if (null === $target && $context->hasTarget()) {
|
||||
return sprintf(
|
||||
'<i>%s</i>: %s [%s]',
|
||||
$this->elementTypeNameGenerator->getLocalizedTypeLabel($context->getTargetClass()),
|
||||
|
@ -99,6 +97,6 @@ class LogEntryTargetColumn extends AbstractColumn
|
|||
}
|
||||
|
||||
//Log is not associated with an element
|
||||
return "";
|
||||
return '';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,7 +24,6 @@ declare(strict_types=1);
|
|||
|
||||
namespace App\DataTables;
|
||||
|
||||
use App\DataTables\Adapter\CustomORMAdapter;
|
||||
use App\DataTables\Adapter\FetchJoinORMAdapter;
|
||||
use App\DataTables\Column\EntityColumn;
|
||||
use App\DataTables\Column\LocaleDateTimeColumn;
|
||||
|
@ -53,15 +52,15 @@ use Symfony\Contracts\Translation\TranslatorInterface;
|
|||
|
||||
final class PartsDataTable implements DataTableTypeInterface
|
||||
{
|
||||
protected $translator;
|
||||
protected $treeBuilder;
|
||||
protected $amountFormatter;
|
||||
protected $previewGenerator;
|
||||
protected $attachmentURLGenerator;
|
||||
private $translator;
|
||||
private $treeBuilder;
|
||||
private $amountFormatter;
|
||||
private $previewGenerator;
|
||||
private $attachmentURLGenerator;
|
||||
/**
|
||||
* @var EntityURLGenerator
|
||||
*/
|
||||
protected $urlGenerator;
|
||||
private $urlGenerator;
|
||||
|
||||
public function __construct(EntityURLGenerator $urlGenerator, TranslatorInterface $translator,
|
||||
NodesListBuilder $treeBuilder, AmountFormatter $amountFormatter,
|
||||
|
@ -231,7 +230,7 @@ final class PartsDataTable implements DataTableTypeInterface
|
|||
]);
|
||||
}
|
||||
|
||||
protected function getQuery(QueryBuilder $builder): void
|
||||
private function getQuery(QueryBuilder $builder): void
|
||||
{
|
||||
$builder->distinct()->select('part')
|
||||
->addSelect('category')
|
||||
|
@ -257,7 +256,7 @@ final class PartsDataTable implements DataTableTypeInterface
|
|||
->leftJoin('part.partUnit', 'partUnit');
|
||||
}
|
||||
|
||||
protected function buildCriteria(QueryBuilder $builder, array $options): void
|
||||
private function buildCriteria(QueryBuilder $builder, array $options): void
|
||||
{
|
||||
$em = $builder->getEntityManager();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue