diff --git a/config/packages/dev/easy_log_handler.yaml b/config/packages/dev/easy_log_handler.yaml new file mode 100644 index 00000000..27bfc608 --- /dev/null +++ b/config/packages/dev/easy_log_handler.yaml @@ -0,0 +1,16 @@ +services: + EasyCorp\EasyLog\EasyLogHandler: + public: false + arguments: ['%kernel.logs_dir%/%kernel.environment%.log'] + +#// FIXME: How to add this configuration automatically without messing up with the monolog configuration? +#monolog: +# handlers: +# buffered: +# type: buffer +# handler: easylog +# channels: ['!event'] +# level: debug +# easylog: +# type: service +# id: EasyCorp\EasyLog\EasyLogHandler diff --git a/config/packages/doctrine.php b/config/packages/doctrine.php index f62cdcfb..e5be011f 100644 --- a/config/packages/doctrine.php +++ b/config/packages/doctrine.php @@ -20,16 +20,16 @@ declare(strict_types=1); +use Symfony\Config\DoctrineConfig; + /** - * This file enables 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. - * - * TODO: Remove this file when we drop support for PHP < 8.4 */ -// On PHP 8.4+ we can use native lazy objects, which are much more efficient than proxies. -if (PHP_VERSION_ID >= 80400) { - return ['doctrine' => ['orm' => ['enable_native_lazy_objects' => true]]]; -} - -return []; +return static function(DoctrineConfig $doctrine) { + //On PHP 8.4+ we can use native lazy objects, which are much more efficient than proxies. + if (PHP_VERSION_ID >= 80400) { + $doctrine->orm()->enableNativeLazyObjects(true); + } +}; diff --git a/src/Doctrine/Middleware/SQLiteRegexExtensionMiddlewareDriver.php b/src/Doctrine/Middleware/SQLiteRegexExtensionMiddlewareDriver.php index f721f986..aa6108c9 100644 --- a/src/Doctrine/Middleware/SQLiteRegexExtensionMiddlewareDriver.php +++ b/src/Doctrine/Middleware/SQLiteRegexExtensionMiddlewareDriver.php @@ -27,7 +27,6 @@ use App\Doctrine\Functions\SiValueSort; use App\Exceptions\InvalidRegexException; use Doctrine\DBAL\Driver\Connection; use Doctrine\DBAL\Driver\Middleware\AbstractDriverMiddleware; -use Pdo\Sqlite; /** * This middleware is used to add the regexp operator to the SQLite platform. @@ -45,30 +44,17 @@ class SQLiteRegexExtensionMiddlewareDriver extends AbstractDriverMiddleware if ($params['driver'] === 'pdo_sqlite') { $native_connection = $connection->getNativeConnection(); + //Ensure that the function really exists on the connection, as it is marked as experimental according to PHP documentation if($native_connection instanceof \PDO) { + $native_connection->sqliteCreateFunction('REGEXP', self::regexp(...), 2, \PDO::SQLITE_DETERMINISTIC); + $native_connection->sqliteCreateFunction('FIELD', self::field(...), -1, \PDO::SQLITE_DETERMINISTIC); + $native_connection->sqliteCreateFunction('FIELD2', self::field2(...), 2, \PDO::SQLITE_DETERMINISTIC); - //Use the new PDO::createFunction and PDO::createCollation methods if available (PHP 8.4+) - if (is_a($native_connection, Sqlite::class)) { #TODO: Remove this check when PHP 8.4 is the minimum requirement - $native_connection->createFunction('REGEXP', self::regexp(...), 2, Sqlite::DETERMINISTIC); - $native_connection->createFunction('FIELD', self::field(...), -1, Sqlite::DETERMINISTIC); - $native_connection->createFunction('FIELD2', self::field2(...), 2, Sqlite::DETERMINISTIC); + //Create a new collation for natural sorting + $native_connection->sqliteCreateCollation('NATURAL_CMP', strnatcmp(...)); - //Create a new collation for natural sorting - $native_connection->createCollation('NATURAL_CMP', strnatcmp(...)); - - //Create a function for SI prefix value sorting - $native_connection->createFunction('SI_VALUE', SiValueSort::sqliteSiValue(...), 1, Sqlite::DETERMINISTIC); - } else { - $native_connection->sqliteCreateFunction('REGEXP', self::regexp(...), 2, \PDO::SQLITE_DETERMINISTIC); - $native_connection->sqliteCreateFunction('FIELD', self::field(...), -1, \PDO::SQLITE_DETERMINISTIC); - $native_connection->sqliteCreateFunction('FIELD2', self::field2(...), 2, \PDO::SQLITE_DETERMINISTIC); - - //Create a new collation for natural sorting - $native_connection->sqliteCreateCollation('NATURAL_CMP', strnatcmp(...)); - - //Create a function for SI prefix value sorting - $native_connection->sqliteCreateFunction('SI_VALUE', SiValueSort::sqliteSiValue(...), 1, \PDO::SQLITE_DETERMINISTIC); - } + //Create a function for SI prefix value sorting + $native_connection->sqliteCreateFunction('SI_VALUE', SiValueSort::sqliteSiValue(...), 1, \PDO::SQLITE_DETERMINISTIC); } } @@ -132,4 +118,4 @@ class SQLiteRegexExtensionMiddlewareDriver extends AbstractDriverMiddleware return $index + 1; } -} +} \ No newline at end of file diff --git a/src/Entity/ProjectSystem/Project.php b/src/Entity/ProjectSystem/Project.php index f4a3e9de..a103d694 100644 --- a/src/Entity/ProjectSystem/Project.php +++ b/src/Entity/ProjectSystem/Project.php @@ -117,7 +117,7 @@ class Project extends AbstractStructuralDBElement /** * @var string|null The current status of the project */ - #[Assert\Choice(choices: ['draft', 'planning', 'in_production', 'finished', 'archived'])] + #[Assert\Choice(['draft', 'planning', 'in_production', 'finished', 'archived'])] #[Groups(['extended', 'full', 'project:read', 'project:write', 'import'])] #[ORM\Column(type: Types::STRING, length: 64, nullable: true)] protected ?string $status = null; diff --git a/src/Form/Type/AttachmentTypeType.php b/src/Form/Type/AttachmentTypeType.php index 95b5a254..099ed282 100644 --- a/src/Form/Type/AttachmentTypeType.php +++ b/src/Form/Type/AttachmentTypeType.php @@ -38,7 +38,7 @@ class AttachmentTypeType extends AbstractType return StructuralEntityType::class; } - public function configureOptions(OptionsResolver $resolver): void + public function configureOptions(OptionsResolver $resolver) { $resolver->define('attachment_filter_class')->allowedTypes('null', 'string')->default(null); diff --git a/src/Helpers/Projects/ProjectBuildRequest.php b/src/Helpers/Projects/ProjectBuildRequest.php index d2dfe139..430d37b5 100644 --- a/src/Helpers/Projects/ProjectBuildRequest.php +++ b/src/Helpers/Projects/ProjectBuildRequest.php @@ -84,10 +84,8 @@ final class ProjectBuildRequest $remaining_amount = $this->getNeededAmountForBOMEntry($bom_entry); foreach($this->getPartLotsForBOMEntry($bom_entry) as $lot) { //If the lot has instock use it for the build - $id = $lot->getID() ?? throw new \RuntimeException("Part lot needs to have an ID!"); - - $this->withdraw_amounts[$id] = min($remaining_amount, $lot->getAmount()); - $remaining_amount -= max(0, $this->withdraw_amounts[$id]); + $this->withdraw_amounts[$lot->getID()] = min($remaining_amount, $lot->getAmount()); + $remaining_amount -= max(0, $this->withdraw_amounts[$lot->getID()]); } } } @@ -178,10 +176,6 @@ final class ProjectBuildRequest { $lot_id = $lot instanceof PartLot ? $lot->getID() : $lot; - if ($lot_id === null) { - throw new \InvalidArgumentException('The given lot must have an ID!'); - } - if (! array_key_exists($lot_id, $this->withdraw_amounts)) { throw new \InvalidArgumentException('The given lot is not in the withdraw amounts array!'); } @@ -198,12 +192,10 @@ final class ProjectBuildRequest { if ($lot instanceof PartLot) { $lot_id = $lot->getID(); - } else { + } elseif (is_int($lot)) { $lot_id = $lot; - } - - if ($lot_id === null) { - throw new \InvalidArgumentException('The given lot must have an ID!'); + } else { + throw new \InvalidArgumentException('The given lot must be an instance of PartLot or an ID of a PartLot!'); } $this->withdraw_amounts[$lot_id] = $amount; @@ -304,7 +296,7 @@ final class ProjectBuildRequest * @param bool $dont_check_quantity * @return $this */ - public function setDontCheckQuantity(bool $dont_check_quantity): self + public function setDontCheckQuantity(bool $dont_check_quantity): ProjectBuildRequest { $this->dont_check_quantity = $dont_check_quantity; return $this; diff --git a/src/Repository/DBElementRepository.php b/src/Repository/DBElementRepository.php index 6e13aff7..f737d91d 100644 --- a/src/Repository/DBElementRepository.php +++ b/src/Repository/DBElementRepository.php @@ -158,6 +158,7 @@ class DBElementRepository extends EntityRepository { $reflection = new ReflectionClass($element::class); $property = $reflection->getProperty($field); + $property->setAccessible(true); $property->setValue($element, $new_value); } } diff --git a/src/Services/ImportExportSystem/PartKeeprImporter/PKImportHelperTrait.php b/src/Services/ImportExportSystem/PartKeeprImporter/PKImportHelperTrait.php index cbfb4ee0..08b1c301 100644 --- a/src/Services/ImportExportSystem/PartKeeprImporter/PKImportHelperTrait.php +++ b/src/Services/ImportExportSystem/PartKeeprImporter/PKImportHelperTrait.php @@ -233,6 +233,7 @@ trait PKImportHelperTrait $reflectionClass = new \ReflectionClass($entity); $property = $reflectionClass->getProperty('addedDate'); + $property->setAccessible(true); $property->setValue($entity, $date); } diff --git a/templates/log_system/details/_extra_collection_element_deleted.html.twig b/templates/log_system/details/_extra_collection_element_deleted.html.twig index 1c2ce2f3..221fae95 100644 --- a/templates/log_system/details/_extra_collection_element_deleted.html.twig +++ b/templates/log_system/details/_extra_collection_element_deleted.html.twig @@ -4,7 +4,7 @@
{% trans %}log.collection_deleted.deleted{% endtrans %}: - {{ type_label(entry.deletedElementClass) }} #{{ entry.deletedElementID }} + {{ entity_type_label(entry.deletedElementClass) }} #{{ entry.deletedElementID }} {% if entry.oldName is not empty %} ({{ entry.oldName }}) {% endif %} @@ -12,4 +12,4 @@
{% trans %}log.collection_deleted.on_collection{% endtrans %}: {{ log_helper.translate_field(entry.collectionName) }} -
+ \ No newline at end of file diff --git a/templates/parts/info/_picture.html.twig b/templates/parts/info/_picture.html.twig index db6c59ca..e6aa74b3 100644 --- a/templates/parts/info/_picture.html.twig +++ b/templates/parts/info/_picture.html.twig @@ -19,7 +19,7 @@