mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2026-02-16 14:39:37 +00:00
Ran rector
This commit is contained in:
parent
b21d294cf8
commit
097041a43a
14 changed files with 34 additions and 19 deletions
|
|
@ -20,12 +20,14 @@
|
||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
use Symfony\Config\DoctrineConfig;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class extends the default doctrine ORM configuration to enable native lazy objects on PHP 8.4+.
|
* This class extends the default doctrine ORM configuration to enable native lazy objects on PHP 8.4+.
|
||||||
* We have to do this in a PHP file, because the yaml file does not support conditionals on PHP version.
|
* We have to do this in a PHP file, because the yaml file does not support conditionals on PHP version.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
return static function(\Symfony\Config\DoctrineConfig $doctrine) {
|
return static function(DoctrineConfig $doctrine) {
|
||||||
//On PHP 8.4+ we can use native lazy objects, which are much more efficient than proxies.
|
//On PHP 8.4+ we can use native lazy objects, which are much more efficient than proxies.
|
||||||
if (PHP_VERSION_ID >= 80400) {
|
if (PHP_VERSION_ID >= 80400) {
|
||||||
$doctrine->orm()->enableNativeLazyObjects(true);
|
$doctrine->orm()->enableNativeLazyObjects(true);
|
||||||
|
|
|
||||||
|
|
@ -36,8 +36,6 @@ return RectorConfig::configure()
|
||||||
PHPUnitSetList::PHPUNIT_90,
|
PHPUnitSetList::PHPUNIT_90,
|
||||||
PHPUnitSetList::PHPUNIT_110,
|
PHPUnitSetList::PHPUNIT_110,
|
||||||
PHPUnitSetList::PHPUNIT_CODE_QUALITY,
|
PHPUnitSetList::PHPUNIT_CODE_QUALITY,
|
||||||
|
|
||||||
|
|
||||||
])
|
])
|
||||||
|
|
||||||
->withRules([
|
->withRules([
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,7 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Controller;
|
namespace App\Controller;
|
||||||
|
|
||||||
|
use App\Entity\InfoProviderSystem\BulkInfoProviderImportJob;
|
||||||
use App\DataTables\LogDataTable;
|
use App\DataTables\LogDataTable;
|
||||||
use App\Entity\Attachments\AttachmentUpload;
|
use App\Entity\Attachments\AttachmentUpload;
|
||||||
use App\Entity\Parts\Category;
|
use App\Entity\Parts\Category;
|
||||||
|
|
@ -151,7 +152,7 @@ final class PartController extends AbstractController
|
||||||
$jobId = $request->query->get('jobId');
|
$jobId = $request->query->get('jobId');
|
||||||
$bulkJob = null;
|
$bulkJob = null;
|
||||||
if ($jobId) {
|
if ($jobId) {
|
||||||
$bulkJob = $this->em->getRepository(\App\Entity\InfoProviderSystem\BulkInfoProviderImportJob::class)->find($jobId);
|
$bulkJob = $this->em->getRepository(BulkInfoProviderImportJob::class)->find($jobId);
|
||||||
// Verify user owns this job
|
// Verify user owns this job
|
||||||
if ($bulkJob && $bulkJob->getCreatedBy() !== $this->getUser()) {
|
if ($bulkJob && $bulkJob->getCreatedBy() !== $this->getUser()) {
|
||||||
$bulkJob = null;
|
$bulkJob = null;
|
||||||
|
|
@ -172,7 +173,7 @@ final class PartController extends AbstractController
|
||||||
throw $this->createAccessDeniedException('Invalid CSRF token');
|
throw $this->createAccessDeniedException('Invalid CSRF token');
|
||||||
}
|
}
|
||||||
|
|
||||||
$bulkJob = $this->em->getRepository(\App\Entity\InfoProviderSystem\BulkInfoProviderImportJob::class)->find($jobId);
|
$bulkJob = $this->em->getRepository(BulkInfoProviderImportJob::class)->find($jobId);
|
||||||
if (!$bulkJob || $bulkJob->getCreatedBy() !== $this->getUser()) {
|
if (!$bulkJob || $bulkJob->getCreatedBy() !== $this->getUser()) {
|
||||||
throw $this->createNotFoundException('Bulk import job not found');
|
throw $this->createNotFoundException('Bulk import job not found');
|
||||||
}
|
}
|
||||||
|
|
@ -338,7 +339,7 @@ final class PartController extends AbstractController
|
||||||
$jobId = $request->query->get('jobId');
|
$jobId = $request->query->get('jobId');
|
||||||
$bulkJob = null;
|
$bulkJob = null;
|
||||||
if ($jobId) {
|
if ($jobId) {
|
||||||
$bulkJob = $this->em->getRepository(\App\Entity\InfoProviderSystem\BulkInfoProviderImportJob::class)->find($jobId);
|
$bulkJob = $this->em->getRepository(BulkInfoProviderImportJob::class)->find($jobId);
|
||||||
// Verify user owns this job
|
// Verify user owns this job
|
||||||
if ($bulkJob && $bulkJob->getCreatedBy() !== $this->getUser()) {
|
if ($bulkJob && $bulkJob->getCreatedBy() !== $this->getUser()) {
|
||||||
$bulkJob = null;
|
$bulkJob = null;
|
||||||
|
|
|
||||||
|
|
@ -160,7 +160,7 @@ class PartSearchFilter implements FilterInterface
|
||||||
if ($search_dbId) {
|
if ($search_dbId) {
|
||||||
$expressions[] = $queryBuilder->expr()->eq('part.id', ':id_exact');
|
$expressions[] = $queryBuilder->expr()->eq('part.id', ':id_exact');
|
||||||
$queryBuilder->setParameter('id_exact', (int) $this->keyword,
|
$queryBuilder->setParameter('id_exact', (int) $this->keyword,
|
||||||
\Doctrine\DBAL\ParameterType::INTEGER);
|
ParameterType::INTEGER);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Guard condition
|
//Guard condition
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\EventSubscriber\UserSystem;
|
namespace App\EventSubscriber\UserSystem;
|
||||||
|
|
||||||
use App\Entity\Parts\Part;
|
use App\Entity\Parts\Part;
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,7 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Form\InfoProviderSystem;
|
namespace App\Form\InfoProviderSystem;
|
||||||
|
|
||||||
|
use Symfony\Component\Validator\Constraints\Range;
|
||||||
use Symfony\Component\Form\AbstractType;
|
use Symfony\Component\Form\AbstractType;
|
||||||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
||||||
use Symfony\Component\Form\Extension\Core\Type\IntegerType;
|
use Symfony\Component\Form\Extension\Core\Type\IntegerType;
|
||||||
|
|
@ -61,7 +62,7 @@ class FieldToProviderMappingType extends AbstractType
|
||||||
'style' => 'width: 80px;'
|
'style' => 'width: 80px;'
|
||||||
],
|
],
|
||||||
'constraints' => [
|
'constraints' => [
|
||||||
new \Symfony\Component\Validator\Constraints\Range(['min' => 1, 'max' => 10]),
|
new Range(['min' => 1, 'max' => 10]),
|
||||||
],
|
],
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,8 @@ declare(strict_types=1);
|
||||||
*/
|
*/
|
||||||
namespace App\Services\ImportExportSystem;
|
namespace App\Services\ImportExportSystem;
|
||||||
|
|
||||||
|
use App\Entity\Parts\Supplier;
|
||||||
|
use App\Entity\PriceInformations\Orderdetail;
|
||||||
use App\Entity\Parts\Part;
|
use App\Entity\Parts\Part;
|
||||||
use App\Entity\ProjectSystem\Project;
|
use App\Entity\ProjectSystem\Project;
|
||||||
use App\Entity\ProjectSystem\ProjectBOMEntry;
|
use App\Entity\ProjectSystem\ProjectBOMEntry;
|
||||||
|
|
@ -275,7 +277,7 @@ class BOMImporter
|
||||||
$mapped_entries = []; // Collect all mapped entries for validation
|
$mapped_entries = []; // Collect all mapped entries for validation
|
||||||
|
|
||||||
// Fetch suppliers once for efficiency
|
// Fetch suppliers once for efficiency
|
||||||
$suppliers = $this->entityManager->getRepository(\App\Entity\Parts\Supplier::class)->findAll();
|
$suppliers = $this->entityManager->getRepository(Supplier::class)->findAll();
|
||||||
$supplierSPNKeys = [];
|
$supplierSPNKeys = [];
|
||||||
$suppliersByName = []; // Map supplier names to supplier objects
|
$suppliersByName = []; // Map supplier names to supplier objects
|
||||||
foreach ($suppliers as $supplier) {
|
foreach ($suppliers as $supplier) {
|
||||||
|
|
@ -371,7 +373,7 @@ class BOMImporter
|
||||||
|
|
||||||
if ($supplier_spn !== null) {
|
if ($supplier_spn !== null) {
|
||||||
// Query for orderdetails with matching supplier and SPN
|
// Query for orderdetails with matching supplier and SPN
|
||||||
$orderdetail = $this->entityManager->getRepository(\App\Entity\PriceInformations\Orderdetail::class)
|
$orderdetail = $this->entityManager->getRepository(Orderdetail::class)
|
||||||
->findOneBy([
|
->findOneBy([
|
||||||
'supplier' => $supplier,
|
'supplier' => $supplier,
|
||||||
'supplierpartnr' => $supplier_spn,
|
'supplierpartnr' => $supplier_spn,
|
||||||
|
|
@ -535,7 +537,7 @@ class BOMImporter
|
||||||
];
|
];
|
||||||
|
|
||||||
// Add dynamic supplier fields based on available suppliers in the database
|
// Add dynamic supplier fields based on available suppliers in the database
|
||||||
$suppliers = $this->entityManager->getRepository(\App\Entity\Parts\Supplier::class)->findAll();
|
$suppliers = $this->entityManager->getRepository(Supplier::class)->findAll();
|
||||||
foreach ($suppliers as $supplier) {
|
foreach ($suppliers as $supplier) {
|
||||||
$supplierName = $supplier->getName();
|
$supplierName = $supplier->getName();
|
||||||
$targets[$supplierName . ' SPN'] = [
|
$targets[$supplierName . ' SPN'] = [
|
||||||
|
|
@ -570,7 +572,7 @@ class BOMImporter
|
||||||
];
|
];
|
||||||
|
|
||||||
// Add supplier-specific patterns
|
// Add supplier-specific patterns
|
||||||
$suppliers = $this->entityManager->getRepository(\App\Entity\Parts\Supplier::class)->findAll();
|
$suppliers = $this->entityManager->getRepository(Supplier::class)->findAll();
|
||||||
foreach ($suppliers as $supplier) {
|
foreach ($suppliers as $supplier) {
|
||||||
$supplierName = $supplier->getName();
|
$supplierName = $supplier->getName();
|
||||||
$supplierLower = strtolower($supplierName);
|
$supplierLower = strtolower($supplierName);
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,7 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Services\ImportExportSystem;
|
namespace App\Services\ImportExportSystem;
|
||||||
|
|
||||||
|
use PhpOffice\PhpSpreadsheet\Cell\Coordinate;
|
||||||
use App\Entity\Base\AbstractNamedDBElement;
|
use App\Entity\Base\AbstractNamedDBElement;
|
||||||
use App\Entity\Base\AbstractStructuralDBElement;
|
use App\Entity\Base\AbstractStructuralDBElement;
|
||||||
use App\Helpers\FilenameSanatizer;
|
use App\Helpers\FilenameSanatizer;
|
||||||
|
|
@ -177,7 +178,7 @@ class EntityExporter
|
||||||
$colIndex = 1;
|
$colIndex = 1;
|
||||||
|
|
||||||
foreach ($columns as $column) {
|
foreach ($columns as $column) {
|
||||||
$cellCoordinate = \PhpOffice\PhpSpreadsheet\Cell\Coordinate::stringFromColumnIndex($colIndex) . $rowIndex;
|
$cellCoordinate = Coordinate::stringFromColumnIndex($colIndex) . $rowIndex;
|
||||||
$worksheet->setCellValue($cellCoordinate, $column);
|
$worksheet->setCellValue($cellCoordinate, $column);
|
||||||
$colIndex++;
|
$colIndex++;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,7 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Services\ImportExportSystem;
|
namespace App\Services\ImportExportSystem;
|
||||||
|
|
||||||
|
use PhpOffice\PhpSpreadsheet\Cell\Coordinate;
|
||||||
use App\Entity\Base\AbstractNamedDBElement;
|
use App\Entity\Base\AbstractNamedDBElement;
|
||||||
use App\Entity\Base\AbstractStructuralDBElement;
|
use App\Entity\Base\AbstractStructuralDBElement;
|
||||||
use App\Entity\Parts\Category;
|
use App\Entity\Parts\Category;
|
||||||
|
|
@ -419,14 +420,14 @@ class EntityImporter
|
||||||
'worksheet_title' => $worksheet->getTitle()
|
'worksheet_title' => $worksheet->getTitle()
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$highestColumnIndex = \PhpOffice\PhpSpreadsheet\Cell\Coordinate::columnIndexFromString($highestColumn);
|
$highestColumnIndex = Coordinate::columnIndexFromString($highestColumn);
|
||||||
|
|
||||||
for ($row = 1; $row <= $highestRow; $row++) {
|
for ($row = 1; $row <= $highestRow; $row++) {
|
||||||
$rowData = [];
|
$rowData = [];
|
||||||
|
|
||||||
// Read all columns using numeric index
|
// Read all columns using numeric index
|
||||||
for ($colIndex = 1; $colIndex <= $highestColumnIndex; $colIndex++) {
|
for ($colIndex = 1; $colIndex <= $highestColumnIndex; $colIndex++) {
|
||||||
$col = \PhpOffice\PhpSpreadsheet\Cell\Coordinate::stringFromColumnIndex($colIndex);
|
$col = Coordinate::stringFromColumnIndex($colIndex);
|
||||||
try {
|
try {
|
||||||
$cellValue = $worksheet->getCell("{$col}{$row}")->getCalculatedValue();
|
$cellValue = $worksheet->getCell("{$col}{$row}")->getCalculatedValue();
|
||||||
$rowData[] = $cellValue ?? '';
|
$rowData[] = $cellValue ?? '';
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,7 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Services\InfoProviderSystem\DTOs;
|
namespace App\Services\InfoProviderSystem\DTOs;
|
||||||
|
|
||||||
|
use Doctrine\ORM\Exception\ORMException;
|
||||||
use App\Entity\Parts\Part;
|
use App\Entity\Parts\Part;
|
||||||
use Doctrine\ORM\EntityManagerInterface;
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
use Traversable;
|
use Traversable;
|
||||||
|
|
@ -176,7 +177,7 @@ readonly class BulkSearchResponseDTO implements \ArrayAccess, \IteratorAggregate
|
||||||
* @param array $data
|
* @param array $data
|
||||||
* @param EntityManagerInterface $entityManager
|
* @param EntityManagerInterface $entityManager
|
||||||
* @return BulkSearchResponseDTO
|
* @return BulkSearchResponseDTO
|
||||||
* @throws \Doctrine\ORM\Exception\ORMException
|
* @throws ORMException
|
||||||
*/
|
*/
|
||||||
public static function fromSerializableRepresentation(array $data, EntityManagerInterface $entityManager): BulkSearchResponseDTO
|
public static function fromSerializableRepresentation(array $data, EntityManagerInterface $entityManager): BulkSearchResponseDTO
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -365,7 +365,7 @@ class BuerklinProvider implements BatchInfoProviderInterface, URLHandlerInfoProv
|
||||||
* - prefers 'zoom' format, then 'product' format, then all others
|
* - prefers 'zoom' format, then 'product' format, then all others
|
||||||
*
|
*
|
||||||
* @param array|null $images
|
* @param array|null $images
|
||||||
* @return \App\Services\InfoProviderSystem\DTOs\FileDTO[]
|
* @return FileDTO[]
|
||||||
*/
|
*/
|
||||||
private function getProductImages(?array $images): array
|
private function getProductImages(?array $images): array
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,8 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Services\System;
|
namespace App\Services\System;
|
||||||
|
|
||||||
|
use Doctrine\DBAL\Platforms\AbstractMySQLPlatform;
|
||||||
|
use Doctrine\DBAL\Platforms\PostgreSQLPlatform;
|
||||||
use Doctrine\ORM\EntityManagerInterface;
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
use Psr\Log\LoggerInterface;
|
use Psr\Log\LoggerInterface;
|
||||||
use Shivas\VersioningBundle\Service\VersionManagerInterface;
|
use Shivas\VersioningBundle\Service\VersionManagerInterface;
|
||||||
|
|
@ -334,7 +336,7 @@ readonly class BackupManager
|
||||||
$params = $connection->getParams();
|
$params = $connection->getParams();
|
||||||
$platform = $connection->getDatabasePlatform();
|
$platform = $connection->getDatabasePlatform();
|
||||||
|
|
||||||
if ($platform instanceof \Doctrine\DBAL\Platforms\AbstractMySQLPlatform) {
|
if ($platform instanceof AbstractMySQLPlatform) {
|
||||||
// Use mysql command to import - need to use shell to handle input redirection
|
// Use mysql command to import - need to use shell to handle input redirection
|
||||||
$mysqlCmd = 'mysql';
|
$mysqlCmd = 'mysql';
|
||||||
if (isset($params['host'])) {
|
if (isset($params['host'])) {
|
||||||
|
|
@ -361,7 +363,7 @@ readonly class BackupManager
|
||||||
if (!$process->isSuccessful()) {
|
if (!$process->isSuccessful()) {
|
||||||
throw new \RuntimeException('MySQL import failed: ' . $process->getErrorOutput());
|
throw new \RuntimeException('MySQL import failed: ' . $process->getErrorOutput());
|
||||||
}
|
}
|
||||||
} elseif ($platform instanceof \Doctrine\DBAL\Platforms\PostgreSQLPlatform) {
|
} elseif ($platform instanceof PostgreSQLPlatform) {
|
||||||
// Use psql command to import
|
// Use psql command to import
|
||||||
$psqlCmd = 'psql';
|
$psqlCmd = 'psql';
|
||||||
if (isset($params['host'])) {
|
if (isset($params['host'])) {
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Validator\Constraints;
|
namespace App\Validator\Constraints;
|
||||||
|
|
||||||
use Attribute;
|
use Attribute;
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Validator\Constraints;
|
namespace App\Validator\Constraints;
|
||||||
|
|
||||||
use App\Entity\Parts\Part;
|
use App\Entity\Parts\Part;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue