Use imports instead of FQNs

This commit is contained in:
Jan Böhmer 2023-06-11 14:55:06 +02:00
parent f63b6d7207
commit 5629215ce4
179 changed files with 792 additions and 597 deletions

View file

@ -64,7 +64,7 @@ class EntityColumn extends AbstractColumn
/** @var AbstractNamedDBElement|null $entity */
if ($entity instanceof \App\Entity\Base\AbstractNamedDBElement) {
if ($entity instanceof AbstractNamedDBElement) {
if (null !== $entity->getID()) {
return sprintf(
'<a href="%s">%s</a>',

View file

@ -41,17 +41,17 @@ declare(strict_types=1);
namespace App\DataTables\Column;
use Symfony\Bundle\SecurityBundle\Security;
use App\Entity\LogSystem\CollectionElementDeleted;
use App\Entity\LogSystem\ElementCreatedLogEntry;
use App\Entity\LogSystem\ElementDeletedLogEntry;
use App\Entity\LogSystem\ElementEditedLogEntry;
use Omines\DataTablesBundle\Column\AbstractColumn;
use Symfony\Component\Security\Core\Security;
use Symfony\Contracts\Translation\TranslatorInterface;
class RevertLogColumn extends AbstractColumn
{
public function __construct(protected TranslatorInterface $translator, protected \Symfony\Bundle\SecurityBundle\Security $security)
public function __construct(protected TranslatorInterface $translator, protected Security $security)
{
}

View file

@ -41,9 +41,9 @@ class EntityConstraint extends AbstractConstraint
* @param null $value
* @param string $operator
*/
public function __construct(protected ?\App\Services\Trees\NodesListBuilder $nodesListBuilder, protected string $class, string $property, string $identifier = null, protected $value = null, protected ?string $operator = '')
public function __construct(protected ?NodesListBuilder $nodesListBuilder, protected string $class, string $property, string $identifier = null, protected $value = null, protected ?string $operator = '')
{
if (!$nodesListBuilder instanceof \App\Services\Trees\NodesListBuilder && $this->isStructural()) {
if (!$nodesListBuilder instanceof NodesListBuilder && $this->isStructural()) {
throw new \InvalidArgumentException('NodesListBuilder must be provided for structural entities');
}
@ -128,7 +128,7 @@ class EntityConstraint extends AbstractConstraint
}
//We need to handle null values differently, as they can not be compared with == or !=
if (!$this->value instanceof \App\Entity\Base\AbstractDBElement) {
if (!$this->value instanceof AbstractDBElement) {
if($this->operator === '=' || $this->operator === 'INCLUDING_CHILDREN') {
$queryBuilder->andWhere(sprintf("%s IS NULL", $this->property));
return;

View file

@ -20,6 +20,7 @@
namespace App\DataTables\Filters\Constraints\Part;
use Doctrine\ORM\Query\Expr\Orx;
use App\DataTables\Filters\Constraints\AbstractConstraint;
use Doctrine\ORM\Query\Expr;
use Doctrine\ORM\QueryBuilder;
@ -88,7 +89,7 @@ class TagsConstraint extends AbstractConstraint
/**
* Builds an expression to query for a single tag
*/
protected function getExpressionForTag(QueryBuilder $queryBuilder, string $tag): Expr\Orx
protected function getExpressionForTag(QueryBuilder $queryBuilder, string $tag): Orx
{
$tag_identifier_prefix = uniqid($this->identifier . '_', false);

View file

@ -66,7 +66,7 @@ class LogFilter implements FilterInterface
/**
* @return IntConstraint|NumberConstraint
*/
public function getDbId(): \App\DataTables\Filters\Constraints\IntConstraint|\App\DataTables\Filters\Constraints\NumberConstraint
public function getDbId(): IntConstraint|NumberConstraint
{
return $this->dbId;
}

View file

@ -20,6 +20,8 @@
namespace App\DataTables\Helpers;
use App\Entity\ProjectSystem\Project;
use App\Entity\Attachments\Attachment;
use App\Entity\Parts\Part;
use App\Services\Attachments\AttachmentURLGenerator;
use App\Services\Attachments\PartPreviewGenerator;
@ -46,7 +48,7 @@ class PartDataTableHelper
if ($context->isNeedsReview()) {
$icon = sprintf('<i class="fa-solid fa-ambulance fa-fw me-1" title="%s"></i>', $this->translator->trans('part.needs_review.badge'));
}
if ($context->getBuiltProject() instanceof \App\Entity\ProjectSystem\Project) {
if ($context->getBuiltProject() instanceof Project) {
$icon = sprintf('<i class="fa-solid fa-box-archive fa-fw me-1" title="%s"></i>',
$this->translator->trans('part.info.projectBuildPart.hint') . ': ' . $context->getBuiltProject()->getName());
}
@ -63,7 +65,7 @@ class PartDataTableHelper
public function renderPicture(Part $context): string
{
$preview_attachment = $this->previewGenerator->getTablePreviewAttachment($context);
if (!$preview_attachment instanceof \App\Entity\Attachments\Attachment) {
if (!$preview_attachment instanceof Attachment) {
return '';
}

View file

@ -22,6 +22,7 @@ declare(strict_types=1);
namespace App\DataTables;
use Symfony\Bundle\SecurityBundle\Security;
use App\DataTables\Column\IconLinkColumn;
use App\DataTables\Column\LocaleDateTimeColumn;
use App\DataTables\Column\LogEntryExtraColumn;
@ -56,7 +57,6 @@ use Psr\Log\LogLevel;
use Symfony\Component\OptionsResolver\Options;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
use Symfony\Component\Security\Core\Security;
use Symfony\Contracts\Translation\TranslatorInterface;
class LogDataTable implements DataTableTypeInterface
@ -65,7 +65,7 @@ class LogDataTable implements DataTableTypeInterface
public function __construct(protected ElementTypeNameGenerator $elementTypeNameGenerator, protected TranslatorInterface $translator,
protected UrlGeneratorInterface $urlGenerator, protected EntityURLGenerator $entityURLGenerator, EntityManagerInterface $entityManager,
protected \Symfony\Bundle\SecurityBundle\Security $security, protected UserAvatarHelper $userAvatarHelper, protected LogLevelHelper $logLevelHelper)
protected Security $security, protected UserAvatarHelper $userAvatarHelper, protected LogLevelHelper $logLevelHelper)
{
$this->logRepo = $entityManager->getRepository(AbstractLogEntry::class);
}
@ -158,7 +158,7 @@ class LogDataTable implements DataTableTypeInterface
$user = $context->getUser();
//If user was deleted, show the info from the username field
if (!$user instanceof \App\Entity\UserSystem\User) {
if (!$user instanceof User) {
if ($context->isCLIEntry()) {
return sprintf('%s [%s]',
htmlentities($context->getCLIUsername()),
@ -219,7 +219,7 @@ class LogDataTable implements DataTableTypeInterface
) {
try {
$target = $this->logRepo->getTargetElement($context);
if ($target instanceof \App\Entity\Base\AbstractDBElement) {
if ($target instanceof AbstractDBElement) {
return $this->entityURLGenerator->timeTravelURL($target, $context->getTimestamp());
}
} catch (EntityNotSupportedException) {

View file

@ -22,6 +22,8 @@ declare(strict_types=1);
namespace App\DataTables;
use Symfony\Bundle\SecurityBundle\Security;
use App\Entity\Parts\Storelocation;
use App\DataTables\Adapters\CustomFetchJoinORMAdapter;
use App\DataTables\Column\EntityColumn;
use App\DataTables\Column\IconLinkColumn;
@ -49,12 +51,11 @@ use Omines\DataTablesBundle\Column\TextColumn;
use Omines\DataTablesBundle\DataTable;
use Omines\DataTablesBundle\DataTableTypeInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Security\Core\Security;
use Symfony\Contracts\Translation\TranslatorInterface;
final class PartsDataTable implements DataTableTypeInterface
{
public function __construct(private readonly EntityURLGenerator $urlGenerator, private readonly TranslatorInterface $translator, private readonly AmountFormatter $amountFormatter, private readonly PartDataTableHelper $partDataTableHelper, private readonly \Symfony\Bundle\SecurityBundle\Security $security)
public function __construct(private readonly EntityURLGenerator $urlGenerator, private readonly TranslatorInterface $translator, private readonly AmountFormatter $amountFormatter, private readonly PartDataTableHelper $partDataTableHelper, private readonly Security $security)
{
}
@ -139,7 +140,7 @@ final class PartsDataTable implements DataTableTypeInterface
$tmp = [];
foreach ($context->getPartLots() as $lot) {
//Ignore lots without storelocation
if (!$lot->getStorageLocation() instanceof \App\Entity\Parts\Storelocation) {
if (!$lot->getStorageLocation() instanceof Storelocation) {
continue;
}
$tmp[] = sprintf(

View file

@ -53,7 +53,7 @@ class ProjectBomEntriesDataTable implements DataTableTypeInterface
'label' => '',
'className' => 'no-colvis',
'render' => function ($value, ProjectBOMEntry $context) {
if(!$context->getPart() instanceof \App\Entity\Parts\Part) {
if(!$context->getPart() instanceof Part) {
return '';
}
return $this->partDataTableHelper->renderPicture($context->getPart());
@ -71,7 +71,7 @@ class ProjectBomEntriesDataTable implements DataTableTypeInterface
'orderField' => 'bom_entry.quantity',
'render' => function ($value, ProjectBOMEntry $context): float|string {
//If we have a non-part entry, only show the rounded quantity
if (!$context->getPart() instanceof \App\Entity\Parts\Part) {
if (!$context->getPart() instanceof Part) {
return round($context->getQuantity());
}
//Otherwise use the unit of the part to format the quantity
@ -83,10 +83,10 @@ class ProjectBomEntriesDataTable implements DataTableTypeInterface
'label' => $this->translator->trans('part.table.name'),
'orderField' => 'part.name',
'render' => function ($value, ProjectBOMEntry $context) {
if(!$context->getPart() instanceof \App\Entity\Parts\Part) {
if(!$context->getPart() instanceof Part) {
return htmlspecialchars($context->getName());
}
if($context->getPart() instanceof \App\Entity\Parts\Part) {
if($context->getPart() instanceof Part) {
$tmp = $this->partDataTableHelper->renderName($context->getPart());
if(!empty($context->getName())) {
$tmp .= '<br><b>'.htmlspecialchars($context->getName()).'</b>';
@ -100,7 +100,7 @@ class ProjectBomEntriesDataTable implements DataTableTypeInterface
->add('description', MarkdownColumn::class, [
'label' => $this->translator->trans('part.table.description'),
'data' => function (ProjectBOMEntry $context) {
if($context->getPart() instanceof \App\Entity\Parts\Part) {
if($context->getPart() instanceof Part) {
return $context->getPart()->getDescription();
}
//For non-part BOM entries show the comment field