mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-20 17:15:51 +02:00
Fixed coding style.
This commit is contained in:
parent
24939f2342
commit
fd61c8d9e2
129 changed files with 962 additions and 1091 deletions
|
@ -69,7 +69,7 @@
|
|||
"symfony/maker-bundle": "^1.13",
|
||||
"symfony/profiler-pack": "*",
|
||||
"symfony/test-pack": "^1.0",
|
||||
"symplify/easy-coding-standard": "^7.1",
|
||||
"symplify/easy-coding-standard": "7.2.3",
|
||||
"vimeo/psalm": "^3.5"
|
||||
},
|
||||
"config": {
|
||||
|
@ -91,14 +91,6 @@
|
|||
"App\\Tests\\": "tests/"
|
||||
}
|
||||
},
|
||||
"replace": {
|
||||
"paragonie/random_compat": "2.*",
|
||||
"symfony/polyfill-ctype": "*",
|
||||
"symfony/polyfill-iconv": "*",
|
||||
"symfony/polyfill-php71": "*",
|
||||
"symfony/polyfill-php70": "*",
|
||||
"symfony/polyfill-php56": "*"
|
||||
},
|
||||
"scripts": {
|
||||
"auto-scripts": {
|
||||
"cache:clear": "symfony-cmd",
|
||||
|
|
146
composer.lock
generated
146
composer.lock
generated
|
@ -4,7 +4,7 @@
|
|||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "6ebc8e9705e901be6f00f9f6418cf900",
|
||||
"content-hash": "fd11975fb4135f47bdb119fec531a868",
|
||||
"packages": [
|
||||
{
|
||||
"name": "beberlei/assert",
|
||||
|
@ -2573,6 +2573,51 @@
|
|||
],
|
||||
"time": "2019-11-06T19:20:29+00:00"
|
||||
},
|
||||
{
|
||||
"name": "paragonie/random_compat",
|
||||
"version": "v9.99.99",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/paragonie/random_compat.git",
|
||||
"reference": "84b4dfb120c6f9b4ff7b3685f9b8f1aa365a0c95"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/paragonie/random_compat/zipball/84b4dfb120c6f9b4ff7b3685f9b8f1aa365a0c95",
|
||||
"reference": "84b4dfb120c6f9b4ff7b3685f9b8f1aa365a0c95",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": "^7"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "4.*|5.*",
|
||||
"vimeo/psalm": "^1"
|
||||
},
|
||||
"suggest": {
|
||||
"ext-libsodium": "Provides a modern crypto API that can be used to generate random bytes."
|
||||
},
|
||||
"type": "library",
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Paragon Initiative Enterprises",
|
||||
"email": "security@paragonie.com",
|
||||
"homepage": "https://paragonie.com"
|
||||
}
|
||||
],
|
||||
"description": "PHP 5.x polyfill for random_bytes() and random_int() from PHP 7",
|
||||
"keywords": [
|
||||
"csprng",
|
||||
"polyfill",
|
||||
"pseudorandom",
|
||||
"random"
|
||||
],
|
||||
"time": "2018-07-02T15:55:56+00:00"
|
||||
},
|
||||
{
|
||||
"name": "php-http/discovery",
|
||||
"version": "1.7.4",
|
||||
|
@ -6143,6 +6188,64 @@
|
|||
"description": "A pack for the Doctrine ORM",
|
||||
"time": "2020-02-10T18:03:48+00:00"
|
||||
},
|
||||
{
|
||||
"name": "symfony/polyfill-ctype",
|
||||
"version": "v1.14.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/polyfill-ctype.git",
|
||||
"reference": "fbdeaec0df06cf3d51c93de80c7eb76e271f5a38"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/fbdeaec0df06cf3d51c93de80c7eb76e271f5a38",
|
||||
"reference": "fbdeaec0df06cf3d51c93de80c7eb76e271f5a38",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3.3"
|
||||
},
|
||||
"suggest": {
|
||||
"ext-ctype": "For best performance"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.14-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Symfony\\Polyfill\\Ctype\\": ""
|
||||
},
|
||||
"files": [
|
||||
"bootstrap.php"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Gert de Pagter",
|
||||
"email": "BackEndTea@gmail.com"
|
||||
},
|
||||
{
|
||||
"name": "Symfony Community",
|
||||
"homepage": "https://symfony.com/contributors"
|
||||
}
|
||||
],
|
||||
"description": "Symfony polyfill for ctype functions",
|
||||
"homepage": "https://symfony.com",
|
||||
"keywords": [
|
||||
"compatibility",
|
||||
"ctype",
|
||||
"polyfill",
|
||||
"portable"
|
||||
],
|
||||
"time": "2020-01-13T11:15:53+00:00"
|
||||
},
|
||||
{
|
||||
"name": "symfony/polyfill-intl-icu",
|
||||
"version": "v1.14.0",
|
||||
|
@ -11379,16 +11482,16 @@
|
|||
},
|
||||
{
|
||||
"name": "symplify/easy-coding-standard",
|
||||
"version": "v7.2.0",
|
||||
"version": "v7.2.3",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/Symplify/EasyCodingStandard.git",
|
||||
"reference": "efa1b57dd454af4d250d8ecd5aacca19a174a3ed"
|
||||
"url": "https://github.com/symplify/easy-coding-standard.git",
|
||||
"reference": "9dfbfc09994310ca43cec24ca86044aae7a5fe47"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/Symplify/EasyCodingStandard/zipball/efa1b57dd454af4d250d8ecd5aacca19a174a3ed",
|
||||
"reference": "efa1b57dd454af4d250d8ecd5aacca19a174a3ed",
|
||||
"url": "https://api.github.com/repos/symplify/easy-coding-standard/zipball/9dfbfc09994310ca43cec24ca86044aae7a5fe47",
|
||||
"reference": "9dfbfc09994310ca43cec24ca86044aae7a5fe47",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -11409,16 +11512,19 @@
|
|||
"symfony/finder": "^4.4|^5.0",
|
||||
"symfony/http-kernel": "^4.4|^5.0",
|
||||
"symfony/yaml": "^4.4|^5.0",
|
||||
"symplify/auto-bind-parameter": "^7.2",
|
||||
"symplify/autowire-array-parameter": "^7.2",
|
||||
"symplify/coding-standard": "^7.2",
|
||||
"symplify/package-builder": "^7.2",
|
||||
"symplify/set-config-resolver": "^7.2",
|
||||
"symplify/smart-file-system": "^7.2"
|
||||
"symplify/auto-bind-parameter": "^7.2.3",
|
||||
"symplify/autowire-array-parameter": "^7.2.3",
|
||||
"symplify/coding-standard": "^7.2.3",
|
||||
"symplify/package-builder": "^7.2.3",
|
||||
"symplify/set-config-resolver": "^7.2.3",
|
||||
"symplify/smart-file-system": "^7.2.3"
|
||||
},
|
||||
"replace": {
|
||||
"symfony/polyfill-php70": "*"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^8.4",
|
||||
"symplify/easy-coding-standard-tester": "^7.2"
|
||||
"phpunit/phpunit": "^8.5|^9.0",
|
||||
"symplify/easy-coding-standard-tester": "^7.2.3"
|
||||
},
|
||||
"bin": [
|
||||
"bin/ecs"
|
||||
|
@ -11426,16 +11532,16 @@
|
|||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "7.2-dev"
|
||||
"dev-master": "7.3-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Symplify\\EasyCodingStandard\\": "src",
|
||||
"Symplify\\EasyCodingStandard\\ChangedFilesDetector\\": "packages/ChangedFilesDetector/src",
|
||||
"Symplify\\EasyCodingStandard\\Configuration\\": "packages/Configuration/src",
|
||||
"Symplify\\EasyCodingStandard\\FixerRunner\\": "packages/FixerRunner/src",
|
||||
"Symplify\\EasyCodingStandard\\SniffRunner\\": "packages/SniffRunner/src"
|
||||
"Symplify\\EasyCodingStandard\\ChangedFilesDetector\\": "packages/changed-files-detector/src",
|
||||
"Symplify\\EasyCodingStandard\\Configuration\\": "packages/configuration/src",
|
||||
"Symplify\\EasyCodingStandard\\FixerRunner\\": "packages/fixer-runner/src",
|
||||
"Symplify\\EasyCodingStandard\\SniffRunner\\": "packages/sniff-runner/src"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
|
@ -11443,7 +11549,7 @@
|
|||
"MIT"
|
||||
],
|
||||
"description": "Use Coding Standard with 0-knowledge of PHP-CS-Fixer and PHP_CodeSniffer.",
|
||||
"time": "2020-01-05T09:25:47+00:00"
|
||||
"time": "2020-02-27T16:45:59+00:00"
|
||||
},
|
||||
{
|
||||
"name": "symplify/package-builder",
|
||||
|
|
4
ecs.yaml
4
ecs.yaml
|
@ -9,6 +9,10 @@ parameters:
|
|||
# - "symplify"
|
||||
- "symfony"
|
||||
|
||||
paths:
|
||||
- 'src'
|
||||
- 'tests'
|
||||
|
||||
skip:
|
||||
Symplify\CodingStandard\Fixer\Naming\PropertyNameMatchingTypeFixer: ~
|
||||
Symplify\CodingStandard\Fixer\LineLength\LineLengthFixer: ~
|
|
@ -125,6 +125,7 @@ class SetPasswordCommand extends Command
|
|||
$this->entityManager->flush();
|
||||
|
||||
$io->success('Password was set successful! You can now log in using the new password.');
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -139,6 +139,7 @@ class UpdateExchangeRatesCommand extends Command
|
|||
$this->em->flush();
|
||||
|
||||
$io->success(sprintf('%d (of %d) currency exchange rates were updated.', $success_counter, count($candidates)));
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -68,9 +68,6 @@ class AttachmentTypeController extends BaseAdminController
|
|||
/**
|
||||
* @Route("/{id}", name="attachment_type_delete", methods={"DELETE"})
|
||||
*
|
||||
* @param Request $request
|
||||
* @param AttachmentType $entity
|
||||
* @param StructuralElementRecursionHelper $recursionHelper
|
||||
* @return RedirectResponse
|
||||
*/
|
||||
public function delete(Request $request, AttachmentType $entity, StructuralElementRecursionHelper $recursionHelper): RedirectResponse
|
||||
|
@ -82,9 +79,6 @@ class AttachmentTypeController extends BaseAdminController
|
|||
* @Route("/{id}/edit/{timestamp}", requirements={"id"="\d+"}, name="attachment_type_edit")
|
||||
* @Route("/{id}", requirements={"id"="\d+"})
|
||||
*
|
||||
* @param AttachmentType $entity
|
||||
* @param Request $request
|
||||
* @param EntityManagerInterface $em
|
||||
* @return Response
|
||||
*/
|
||||
public function edit(AttachmentType $entity, Request $request, EntityManagerInterface $em, ?string $timestamp = null): Response
|
||||
|
@ -96,9 +90,6 @@ class AttachmentTypeController extends BaseAdminController
|
|||
* @Route("/new", name="attachment_type_new")
|
||||
* @Route("/")
|
||||
*
|
||||
* @param Request $request
|
||||
* @param EntityManagerInterface $em
|
||||
* @param EntityImporter $importer
|
||||
* @return Response
|
||||
*/
|
||||
public function new(Request $request, EntityManagerInterface $em, EntityImporter $importer): Response
|
||||
|
@ -109,9 +100,6 @@ class AttachmentTypeController extends BaseAdminController
|
|||
/**
|
||||
* @Route("/export", name="attachment_type_export_all")
|
||||
*
|
||||
* @param EntityManagerInterface $em
|
||||
* @param EntityExporter $exporter
|
||||
* @param Request $request
|
||||
* @return Response
|
||||
*/
|
||||
public function exportAll(EntityManagerInterface $em, EntityExporter $exporter, Request $request): Response
|
||||
|
@ -122,9 +110,6 @@ class AttachmentTypeController extends BaseAdminController
|
|||
/**
|
||||
* @Route("/{id}/export", name="attachment_type_export")
|
||||
*
|
||||
* @param AttachmentType $entity
|
||||
* @param EntityExporter $exporter
|
||||
* @param Request $request
|
||||
* @return Response
|
||||
*/
|
||||
public function exportEntity(AttachmentType $entity, EntityExporter $exporter, Request $request): Response
|
||||
|
|
|
@ -111,14 +111,12 @@ abstract class BaseAdminController extends AbstractController
|
|||
$this->dataTableFactory = $dataTableFactory;
|
||||
}
|
||||
|
||||
|
||||
protected function _edit(AbstractNamedDBElement $entity, Request $request, EntityManagerInterface $em, ?string $timestamp = null) : Response
|
||||
protected function _edit(AbstractNamedDBElement $entity, Request $request, EntityManagerInterface $em, ?string $timestamp = null): Response
|
||||
{
|
||||
$this->denyAccessUnlessGranted('read', $entity);
|
||||
|
||||
|
||||
$timeTravel_timestamp = null;
|
||||
if ($timestamp !== null) {
|
||||
if (null !== $timestamp) {
|
||||
$this->denyAccessUnlessGranted('@tools.timetravel');
|
||||
$this->denyAccessUnlessGranted('show_history', $entity);
|
||||
//If the timestamp only contains numbers interpret it as unix timestamp
|
||||
|
@ -131,12 +129,12 @@ abstract class BaseAdminController extends AbstractController
|
|||
$this->timeTravel->revertEntityToTimestamp($entity, $timeTravel_timestamp);
|
||||
}
|
||||
|
||||
if ($this->isGranted('show_history', $entity) ) {
|
||||
if ($this->isGranted('show_history', $entity)) {
|
||||
$table = $this->dataTableFactory->createFromType(
|
||||
LogDataTable::class,
|
||||
[
|
||||
'filter_elements' => $this->historyHelper->getAssociatedElements($entity),
|
||||
'mode' => 'element_history'
|
||||
'mode' => 'element_history',
|
||||
],
|
||||
['pageLength' => 10]
|
||||
)
|
||||
|
@ -151,7 +149,7 @@ abstract class BaseAdminController extends AbstractController
|
|||
|
||||
$form = $this->createForm($this->form_class, $entity, [
|
||||
'attachment_class' => $this->attachment_class,
|
||||
'disabled' => $timeTravel_timestamp !== null ? true : null
|
||||
'disabled' => null !== $timeTravel_timestamp ? true : null,
|
||||
]);
|
||||
|
||||
$form->handleRequest($request);
|
||||
|
@ -202,7 +200,7 @@ abstract class BaseAdminController extends AbstractController
|
|||
'attachment_helper' => $this->attachmentHelper,
|
||||
'route_base' => $this->route_base,
|
||||
'datatable' => $table,
|
||||
'timeTravel' => $timeTravel_timestamp
|
||||
'timeTravel' => $timeTravel_timestamp,
|
||||
]);
|
||||
}
|
||||
|
||||
|
@ -274,9 +272,7 @@ abstract class BaseAdminController extends AbstractController
|
|||
'csv_separator' => $data['csv_separator'],
|
||||
];
|
||||
|
||||
$this->commentHelper->setMessage('Import ' . $file->getClientOriginalName());
|
||||
|
||||
|
||||
$this->commentHelper->setMessage('Import '.$file->getClientOriginalName());
|
||||
|
||||
$errors = $importer->fileToDBEntities($file, $this->entity_class, $options);
|
||||
|
||||
|
@ -319,7 +315,7 @@ abstract class BaseAdminController extends AbstractController
|
|||
]);
|
||||
}
|
||||
|
||||
protected function _delete(Request $request, AbstractNamedDBElement $entity, StructuralElementRecursionHelper $recursionHelper) : RedirectResponse
|
||||
protected function _delete(Request $request, AbstractNamedDBElement $entity, StructuralElementRecursionHelper $recursionHelper): RedirectResponse
|
||||
{
|
||||
$this->denyAccessUnlessGranted('delete', $entity);
|
||||
|
||||
|
|
|
@ -68,9 +68,6 @@ class CategoryController extends BaseAdminController
|
|||
/**
|
||||
* @Route("/{id}", name="category_delete", methods={"DELETE"})
|
||||
*
|
||||
* @param Request $request
|
||||
* @param Category $entity
|
||||
* @param StructuralElementRecursionHelper $recursionHelper
|
||||
* @return RedirectResponse
|
||||
*/
|
||||
public function delete(Request $request, Category $entity, StructuralElementRecursionHelper $recursionHelper): RedirectResponse
|
||||
|
@ -82,9 +79,6 @@ class CategoryController extends BaseAdminController
|
|||
* @Route("/{id}/edit/{timestamp}", requirements={"id"="\d+"}, name="category_edit")
|
||||
* @Route("/{id}", requirements={"id"="\d+"})
|
||||
*
|
||||
* @param Category $entity
|
||||
* @param Request $request
|
||||
* @param EntityManagerInterface $em
|
||||
* @return Response
|
||||
*/
|
||||
public function edit(Category $entity, Request $request, EntityManagerInterface $em, ?string $timestamp = null): Response
|
||||
|
@ -96,9 +90,6 @@ class CategoryController extends BaseAdminController
|
|||
* @Route("/new", name="category_new")
|
||||
* @Route("/")
|
||||
*
|
||||
* @param Request $request
|
||||
* @param EntityManagerInterface $em
|
||||
* @param EntityImporter $importer
|
||||
* @return Response
|
||||
*/
|
||||
public function new(Request $request, EntityManagerInterface $em, EntityImporter $importer): Response
|
||||
|
@ -109,9 +100,6 @@ class CategoryController extends BaseAdminController
|
|||
/**
|
||||
* @Route("/export", name="category_export_all")
|
||||
*
|
||||
* @param EntityManagerInterface $em
|
||||
* @param EntityExporter $exporter
|
||||
* @param Request $request
|
||||
* @return Response
|
||||
*/
|
||||
public function exportAll(EntityManagerInterface $em, EntityExporter $exporter, Request $request): Response
|
||||
|
@ -122,9 +110,6 @@ class CategoryController extends BaseAdminController
|
|||
/**
|
||||
* @Route("/{id}/export", name="category_export")
|
||||
*
|
||||
* @param Category $entity
|
||||
* @param EntityExporter $exporter
|
||||
* @param Request $request
|
||||
* @return Response
|
||||
*/
|
||||
public function exportEntity(Category $entity, EntityExporter $exporter, Request $request): Response
|
||||
|
|
|
@ -70,9 +70,6 @@ class CurrencyController extends BaseAdminController
|
|||
/**
|
||||
* @Route("/{id}", name="currency_delete", methods={"DELETE"})
|
||||
*
|
||||
* @param Request $request
|
||||
* @param Currency $entity
|
||||
* @param StructuralElementRecursionHelper $recursionHelper
|
||||
* @return RedirectResponse
|
||||
*/
|
||||
public function delete(Request $request, Currency $entity, StructuralElementRecursionHelper $recursionHelper): RedirectResponse
|
||||
|
@ -84,9 +81,6 @@ class CurrencyController extends BaseAdminController
|
|||
* @Route("/{id}/edit/{timestamp}", requirements={"id"="\d+"}, name="currency_edit")
|
||||
* @Route("/{id}", requirements={"id"="\d+"})
|
||||
*
|
||||
* @param Currency $entity
|
||||
* @param Request $request
|
||||
* @param EntityManagerInterface $em
|
||||
* @return Response
|
||||
*/
|
||||
public function edit(Currency $entity, Request $request, EntityManagerInterface $em, ?string $timestamp = null): Response
|
||||
|
@ -98,9 +92,6 @@ class CurrencyController extends BaseAdminController
|
|||
* @Route("/new", name="currency_new")
|
||||
* @Route("/")
|
||||
*
|
||||
* @param Request $request
|
||||
* @param EntityManagerInterface $em
|
||||
* @param EntityImporter $importer
|
||||
* @return Response
|
||||
*/
|
||||
public function new(Request $request, EntityManagerInterface $em, EntityImporter $importer): Response
|
||||
|
@ -111,9 +102,6 @@ class CurrencyController extends BaseAdminController
|
|||
/**
|
||||
* @Route("/export", name="currency_export_all")
|
||||
*
|
||||
* @param EntityManagerInterface $em
|
||||
* @param EntityExporter $exporter
|
||||
* @param Request $request
|
||||
* @return Response
|
||||
*/
|
||||
public function exportAll(EntityManagerInterface $em, EntityExporter $exporter, Request $request): Response
|
||||
|
@ -124,9 +112,6 @@ class CurrencyController extends BaseAdminController
|
|||
/**
|
||||
* @Route("/{id}/export", name="currency_export")
|
||||
*
|
||||
* @param Currency $entity
|
||||
* @param EntityExporter $exporter
|
||||
* @param Request $request
|
||||
* @return Response
|
||||
*/
|
||||
public function exportEntity(Currency $entity, EntityExporter $exporter, Request $request): Response
|
||||
|
|
|
@ -68,9 +68,6 @@ class DeviceController extends BaseAdminController
|
|||
/**
|
||||
* @Route("/{id}", name="device_delete", methods={"DELETE"})
|
||||
*
|
||||
* @param Request $request
|
||||
* @param Device $entity
|
||||
* @param StructuralElementRecursionHelper $recursionHelper
|
||||
* @return RedirectResponse
|
||||
*/
|
||||
public function delete(Request $request, Device $entity, StructuralElementRecursionHelper $recursionHelper): RedirectResponse
|
||||
|
@ -82,9 +79,6 @@ class DeviceController extends BaseAdminController
|
|||
* @Route("/{id}/edit/{timestamp}", requirements={"id"="\d+"}, name="device_edit")
|
||||
* @Route("/{id}", requirements={"id"="\d+"})
|
||||
*
|
||||
* @param Device $entity
|
||||
* @param Request $request
|
||||
* @param EntityManagerInterface $em
|
||||
* @return Response
|
||||
*/
|
||||
public function edit(Device $entity, Request $request, EntityManagerInterface $em, ?string $timestamp = null): Response
|
||||
|
@ -96,9 +90,6 @@ class DeviceController extends BaseAdminController
|
|||
* @Route("/new", name="device_new")
|
||||
* @Route("/")
|
||||
*
|
||||
* @param Request $request
|
||||
* @param EntityManagerInterface $em
|
||||
* @param EntityImporter $importer
|
||||
* @return Response
|
||||
*/
|
||||
public function new(Request $request, EntityManagerInterface $em, EntityImporter $importer): Response
|
||||
|
@ -109,9 +100,6 @@ class DeviceController extends BaseAdminController
|
|||
/**
|
||||
* @Route("/export", name="device_export_all")
|
||||
*
|
||||
* @param EntityManagerInterface $em
|
||||
* @param EntityExporter $exporter
|
||||
* @param Request $request
|
||||
* @return Response
|
||||
*/
|
||||
public function exportAll(EntityManagerInterface $em, EntityExporter $exporter, Request $request): Response
|
||||
|
@ -122,9 +110,6 @@ class DeviceController extends BaseAdminController
|
|||
/**
|
||||
* @Route("/{id}/export", name="device_export")
|
||||
*
|
||||
* @param Device $entity
|
||||
* @param EntityExporter $exporter
|
||||
* @param Request $request
|
||||
* @return Response
|
||||
*/
|
||||
public function exportEntity(Device $entity, EntityExporter $exporter, Request $request): Response
|
||||
|
|
|
@ -67,9 +67,7 @@ class FootprintController extends BaseAdminController
|
|||
|
||||
/**
|
||||
* @Route("/{id}", name="footprint_delete", methods={"DELETE"})
|
||||
* @param Request $request
|
||||
* @param Footprint $entity
|
||||
* @param StructuralElementRecursionHelper $recursionHelper
|
||||
*
|
||||
* @return \Symfony\Component\HttpFoundation\RedirectResponse
|
||||
*/
|
||||
public function delete(Request $request, Footprint $entity, StructuralElementRecursionHelper $recursionHelper)
|
||||
|
@ -80,9 +78,7 @@ class FootprintController extends BaseAdminController
|
|||
/**
|
||||
* @Route("/{id}/edit/{timestamp}", requirements={"id"="\d+"}, name="footprint_edit")
|
||||
* @Route("/{id}", requirements={"id"="\d+"})
|
||||
* @param Footprint $entity
|
||||
* @param Request $request
|
||||
* @param EntityManagerInterface $em
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function edit(Footprint $entity, Request $request, EntityManagerInterface $em, ?string $timestamp = null)
|
||||
|
@ -94,9 +90,6 @@ class FootprintController extends BaseAdminController
|
|||
* @Route("/new", name="footprint_new")
|
||||
* @Route("/")
|
||||
*
|
||||
* @param Request $request
|
||||
* @param EntityManagerInterface $em
|
||||
* @param EntityImporter $importer
|
||||
* @return Response
|
||||
*/
|
||||
public function new(Request $request, EntityManagerInterface $em, EntityImporter $importer): Response
|
||||
|
@ -107,9 +100,6 @@ class FootprintController extends BaseAdminController
|
|||
/**
|
||||
* @Route("/export", name="footprint_export_all")
|
||||
*
|
||||
* @param EntityManagerInterface $em
|
||||
* @param EntityExporter $exporter
|
||||
* @param Request $request
|
||||
* @return Response
|
||||
*/
|
||||
public function exportAll(EntityManagerInterface $em, EntityExporter $exporter, Request $request): Response
|
||||
|
@ -120,9 +110,6 @@ class FootprintController extends BaseAdminController
|
|||
/**
|
||||
* @Route("/{id}/export", name="footprint_export")
|
||||
*
|
||||
* @param AttachmentType $entity
|
||||
* @param EntityExporter $exporter
|
||||
* @param Request $request
|
||||
* @return Response
|
||||
*/
|
||||
public function exportEntity(AttachmentType $entity, EntityExporter $exporter, Request $request): Response
|
||||
|
|
|
@ -66,9 +66,7 @@ class ManufacturerController extends BaseAdminController
|
|||
|
||||
/**
|
||||
* @Route("/{id}", name="manufacturer_delete", methods={"DELETE"})
|
||||
* @param Request $request
|
||||
* @param Manufacturer $entity
|
||||
* @param StructuralElementRecursionHelper $recursionHelper
|
||||
*
|
||||
* @return \Symfony\Component\HttpFoundation\RedirectResponse
|
||||
*/
|
||||
public function delete(Request $request, Manufacturer $entity, StructuralElementRecursionHelper $recursionHelper)
|
||||
|
@ -79,9 +77,7 @@ class ManufacturerController extends BaseAdminController
|
|||
/**
|
||||
* @Route("/{id}/edit/{timestamp}", requirements={"id"="\d+"}, name="manufacturer_edit")
|
||||
* @Route("/{id}", requirements={"id"="\d+"})
|
||||
* @param Manufacturer $entity
|
||||
* @param Request $request
|
||||
* @param EntityManagerInterface $em
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function edit(Manufacturer $entity, Request $request, EntityManagerInterface $em, ?string $timestamp = null)
|
||||
|
@ -93,9 +89,6 @@ class ManufacturerController extends BaseAdminController
|
|||
* @Route("/new", name="manufacturer_new")
|
||||
* @Route("/")
|
||||
*
|
||||
* @param Request $request
|
||||
* @param EntityManagerInterface $em
|
||||
* @param EntityImporter $importer
|
||||
* @return Response
|
||||
*/
|
||||
public function new(Request $request, EntityManagerInterface $em, EntityImporter $importer): Response
|
||||
|
@ -106,9 +99,6 @@ class ManufacturerController extends BaseAdminController
|
|||
/**
|
||||
* @Route("/export", name="manufacturer_export_all")
|
||||
*
|
||||
* @param EntityManagerInterface $em
|
||||
* @param EntityExporter $exporter
|
||||
* @param Request $request
|
||||
* @return Response
|
||||
*/
|
||||
public function exportAll(EntityManagerInterface $em, EntityExporter $exporter, Request $request): Response
|
||||
|
@ -119,10 +109,6 @@ class ManufacturerController extends BaseAdminController
|
|||
/**
|
||||
* @Route("/{id}/export", name="manufacturer_export")
|
||||
*
|
||||
* @param Manufacturer $entity
|
||||
*
|
||||
* @param EntityExporter $exporter
|
||||
* @param Request $request
|
||||
* @return Response
|
||||
*/
|
||||
public function exportEntity(Manufacturer $entity, EntityExporter $exporter, Request $request): Response
|
||||
|
|
|
@ -67,9 +67,7 @@ class MeasurementUnitController extends BaseAdminController
|
|||
|
||||
/**
|
||||
* @Route("/{id}", name="measurement_unit_delete", methods={"DELETE"})
|
||||
* @param Request $request
|
||||
* @param MeasurementUnit $entity
|
||||
* @param StructuralElementRecursionHelper $recursionHelper
|
||||
*
|
||||
* @return \Symfony\Component\HttpFoundation\RedirectResponse
|
||||
*/
|
||||
public function delete(Request $request, MeasurementUnit $entity, StructuralElementRecursionHelper $recursionHelper)
|
||||
|
@ -80,9 +78,7 @@ class MeasurementUnitController extends BaseAdminController
|
|||
/**
|
||||
* @Route("/{id}/edit/{timestamp}", requirements={"id"="\d+"}, name="measurement_unit_edit")
|
||||
* @Route("/{id}", requirements={"id"="\d+"})
|
||||
* @param MeasurementUnit $entity
|
||||
* @param Request $request
|
||||
* @param EntityManagerInterface $em
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function edit(MeasurementUnit $entity, Request $request, EntityManagerInterface $em, ?string $timestamp = null)
|
||||
|
@ -94,9 +90,6 @@ class MeasurementUnitController extends BaseAdminController
|
|||
* @Route("/new", name="measurement_unit_new")
|
||||
* @Route("/")
|
||||
*
|
||||
* @param Request $request
|
||||
* @param EntityManagerInterface $em
|
||||
* @param EntityImporter $importer
|
||||
* @return Response
|
||||
*/
|
||||
public function new(Request $request, EntityManagerInterface $em, EntityImporter $importer): Response
|
||||
|
@ -107,9 +100,6 @@ class MeasurementUnitController extends BaseAdminController
|
|||
/**
|
||||
* @Route("/export", name="measurement_unit_export_all")
|
||||
*
|
||||
* @param EntityManagerInterface $em
|
||||
* @param EntityExporter $exporter
|
||||
* @param Request $request
|
||||
* @return Response
|
||||
*/
|
||||
public function exportAll(EntityManagerInterface $em, EntityExporter $exporter, Request $request): Response
|
||||
|
@ -120,9 +110,6 @@ class MeasurementUnitController extends BaseAdminController
|
|||
/**
|
||||
* @Route("/{id}/export", name="measurement_unit_export")
|
||||
*
|
||||
* @param AttachmentType $entity
|
||||
* @param EntityExporter $exporter
|
||||
* @param Request $request
|
||||
* @return Response
|
||||
*/
|
||||
public function exportEntity(AttachmentType $entity, EntityExporter $exporter, Request $request): Response
|
||||
|
|
|
@ -65,9 +65,7 @@ class StorelocationController extends BaseAdminController
|
|||
|
||||
/**
|
||||
* @Route("/{id}", name="store_location_delete", methods={"DELETE"})
|
||||
* @param Request $request
|
||||
* @param Storelocation $entity
|
||||
* @param StructuralElementRecursionHelper $recursionHelper
|
||||
*
|
||||
* @return \Symfony\Component\HttpFoundation\RedirectResponse
|
||||
*/
|
||||
public function delete(Request $request, Storelocation $entity, StructuralElementRecursionHelper $recursionHelper)
|
||||
|
@ -78,9 +76,7 @@ class StorelocationController extends BaseAdminController
|
|||
/**
|
||||
* @Route("/{id}/edit/{timestamp}", requirements={"id"="\d+"}, name="store_location_edit")
|
||||
* @Route("/{id}", requirements={"id"="\d+"})
|
||||
* @param Storelocation $entity
|
||||
* @param Request $request
|
||||
* @param EntityManagerInterface $em
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function edit(Storelocation $entity, Request $request, EntityManagerInterface $em, ?string $timestamp = null)
|
||||
|
@ -92,9 +88,6 @@ class StorelocationController extends BaseAdminController
|
|||
* @Route("/new", name="store_location_new")
|
||||
* @Route("/")
|
||||
*
|
||||
* @param Request $request
|
||||
* @param EntityManagerInterface $em
|
||||
* @param EntityImporter $importer
|
||||
* @return Response
|
||||
*/
|
||||
public function new(Request $request, EntityManagerInterface $em, EntityImporter $importer): Response
|
||||
|
@ -105,9 +98,6 @@ class StorelocationController extends BaseAdminController
|
|||
/**
|
||||
* @Route("/export", name="store_location_export_all")
|
||||
*
|
||||
* @param EntityManagerInterface $em
|
||||
* @param EntityExporter $exporter
|
||||
* @param Request $request
|
||||
* @return Response
|
||||
*/
|
||||
public function exportAll(EntityManagerInterface $em, EntityExporter $exporter, Request $request): Response
|
||||
|
@ -118,10 +108,6 @@ class StorelocationController extends BaseAdminController
|
|||
/**
|
||||
* @Route("/{id}/export", name="store_location_export")
|
||||
*
|
||||
* @param Storelocation $entity
|
||||
*
|
||||
* @param EntityExporter $exporter
|
||||
* @param Request $request
|
||||
* @return Response
|
||||
*/
|
||||
public function exportEntity(Storelocation $entity, EntityExporter $exporter, Request $request): Response
|
||||
|
|
|
@ -66,9 +66,7 @@ class SupplierController extends BaseAdminController
|
|||
|
||||
/**
|
||||
* @Route("/{id}", name="supplier_delete", methods={"DELETE"})
|
||||
* @param Request $request
|
||||
* @param Supplier $entity
|
||||
* @param StructuralElementRecursionHelper $recursionHelper
|
||||
*
|
||||
* @return \Symfony\Component\HttpFoundation\RedirectResponse
|
||||
*/
|
||||
public function delete(Request $request, Supplier $entity, StructuralElementRecursionHelper $recursionHelper)
|
||||
|
@ -79,9 +77,7 @@ class SupplierController extends BaseAdminController
|
|||
/**
|
||||
* @Route("/{id}/edit/{timestamp}", requirements={"id"="\d+"}, name="supplier_edit")
|
||||
* @Route("/{id}", requirements={"id"="\d+"})
|
||||
* @param Supplier $entity
|
||||
* @param Request $request
|
||||
* @param EntityManagerInterface $em
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function edit(Supplier $entity, Request $request, EntityManagerInterface $em, ?string $timestamp = null)
|
||||
|
@ -93,9 +89,6 @@ class SupplierController extends BaseAdminController
|
|||
* @Route("/new", name="supplier_new")
|
||||
* @Route("/")
|
||||
*
|
||||
* @param Request $request
|
||||
* @param EntityManagerInterface $em
|
||||
* @param EntityImporter $importer
|
||||
* @return Response
|
||||
*/
|
||||
public function new(Request $request, EntityManagerInterface $em, EntityImporter $importer): Response
|
||||
|
@ -106,9 +99,6 @@ class SupplierController extends BaseAdminController
|
|||
/**
|
||||
* @Route("/export", name="supplier_export_all")
|
||||
*
|
||||
* @param EntityManagerInterface $em
|
||||
* @param EntityExporter $exporter
|
||||
* @param Request $request
|
||||
* @return Response
|
||||
*/
|
||||
public function exportAll(EntityManagerInterface $em, EntityExporter $exporter, Request $request): Response
|
||||
|
@ -119,9 +109,6 @@ class SupplierController extends BaseAdminController
|
|||
/**
|
||||
* @Route("/{id}/export", name="supplier_export")
|
||||
*
|
||||
* @param Supplier $entity
|
||||
* @param EntityExporter $exporter
|
||||
* @param Request $request
|
||||
* @return Response
|
||||
*/
|
||||
public function exportEntity(Supplier $entity, EntityExporter $exporter, Request $request): Response
|
||||
|
|
|
@ -46,7 +46,6 @@ use App\DataTables\AttachmentDataTable;
|
|||
use App\Entity\Attachments\Attachment;
|
||||
use App\Entity\Attachments\PartAttachment;
|
||||
use App\Services\Attachments\AttachmentManager;
|
||||
use Exception;
|
||||
use Omines\DataTablesBundle\DataTableFactory;
|
||||
use RuntimeException;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
|
@ -64,8 +63,6 @@ class AttachmentFileController extends AbstractController
|
|||
*
|
||||
* @Route("/attachment/{id}/download", name="attachment_download")
|
||||
*
|
||||
* @param Attachment $attachment
|
||||
* @param AttachmentManager $helper
|
||||
* @return BinaryFileResponse
|
||||
*/
|
||||
public function download(Attachment $attachment, AttachmentManager $helper): BinaryFileResponse
|
||||
|
@ -94,10 +91,7 @@ class AttachmentFileController extends AbstractController
|
|||
*
|
||||
* @Route("/attachment/{id}/view", name="attachment_view")
|
||||
*
|
||||
* @param Attachment $attachment
|
||||
* @param AttachmentManager $helper
|
||||
* @return BinaryFileResponse
|
||||
*
|
||||
*/
|
||||
public function view(Attachment $attachment, AttachmentManager $helper): BinaryFileResponse
|
||||
{
|
||||
|
@ -123,8 +117,6 @@ class AttachmentFileController extends AbstractController
|
|||
/**
|
||||
* @Route("/attachment/list", name="attachment_list")
|
||||
*
|
||||
* @param DataTableFactory $dataTable
|
||||
* @param Request $request
|
||||
* @return JsonResponse|Response
|
||||
*/
|
||||
public function attachmentsTable(DataTableFactory $dataTable, Request $request)
|
||||
|
|
|
@ -70,9 +70,6 @@ class GroupController extends BaseAdminController
|
|||
* @Route("/{id}/edit/{timestamp}", requirements={"id"="\d+"}, name="group_edit")
|
||||
* @Route("/{id}/", requirements={"id"="\d+"})
|
||||
*
|
||||
* @param Group $entity
|
||||
* @param Request $request
|
||||
* @param EntityManagerInterface $em
|
||||
* @return Response
|
||||
*/
|
||||
public function edit(Group $entity, Request $request, EntityManagerInterface $em, ?string $timestamp = null): Response
|
||||
|
@ -84,9 +81,6 @@ class GroupController extends BaseAdminController
|
|||
* @Route("/new", name="group_new")
|
||||
* @Route("/")
|
||||
*
|
||||
* @param Request $request
|
||||
* @param EntityManagerInterface $em
|
||||
* @param EntityImporter $importer
|
||||
* @return Response
|
||||
*/
|
||||
public function new(Request $request, EntityManagerInterface $em, EntityImporter $importer): Response
|
||||
|
@ -97,9 +91,6 @@ class GroupController extends BaseAdminController
|
|||
/**
|
||||
* @Route("/{id}", name="group_delete", methods={"DELETE"})
|
||||
*
|
||||
* @param Request $request
|
||||
* @param Group $entity
|
||||
* @param StructuralElementRecursionHelper $recursionHelper
|
||||
* @return RedirectResponse
|
||||
*/
|
||||
public function delete(Request $request, Group $entity, StructuralElementRecursionHelper $recursionHelper): RedirectResponse
|
||||
|
@ -110,9 +101,6 @@ class GroupController extends BaseAdminController
|
|||
/**
|
||||
* @Route("/export", name="group_export_all")
|
||||
*
|
||||
* @param EntityManagerInterface $em
|
||||
* @param EntityExporter $exporter
|
||||
* @param Request $request
|
||||
* @return Response
|
||||
*/
|
||||
public function exportAll(EntityManagerInterface $em, EntityExporter $exporter, Request $request): Response
|
||||
|
@ -123,9 +111,6 @@ class GroupController extends BaseAdminController
|
|||
/**
|
||||
* @Route("/{id}/export", name="group_export")
|
||||
*
|
||||
* @param Group $entity
|
||||
* @param EntityExporter $exporter
|
||||
* @param Request $request
|
||||
* @return Response
|
||||
*/
|
||||
public function exportEntity(Group $entity, EntityExporter $exporter, Request $request): Response
|
||||
|
|
|
@ -44,11 +44,11 @@ namespace App\Controller;
|
|||
|
||||
use App\DataTables\LogDataTable;
|
||||
use App\Services\GitVersionInfo;
|
||||
use const DIRECTORY_SEPARATOR;
|
||||
use Omines\DataTablesBundle\DataTableFactory;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use const DIRECTORY_SEPARATOR;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpKernel\KernelInterface;
|
||||
use Symfony\Component\Routing\Annotation\Route;
|
||||
use Symfony\Contracts\Cache\CacheInterface;
|
||||
|
@ -81,16 +81,16 @@ class HomepageController extends AbstractController
|
|||
|
||||
/**
|
||||
* @Route("/", name="homepage")
|
||||
* @param GitVersionInfo $versionInfo
|
||||
*
|
||||
* @return \Symfony\Component\HttpFoundation\Response
|
||||
*/
|
||||
public function homepage(Request $request, GitVersionInfo $versionInfo): Response
|
||||
{
|
||||
if ($this->isGranted("@tools.lastActivity")) {
|
||||
if ($this->isGranted('@tools.lastActivity')) {
|
||||
$table = $this->dataTable->createFromType(
|
||||
LogDataTable::class,
|
||||
[
|
||||
'mode' => 'last_activity'
|
||||
'mode' => 'last_activity',
|
||||
],
|
||||
['pageLength' => 10]
|
||||
)
|
||||
|
@ -107,7 +107,7 @@ class HomepageController extends AbstractController
|
|||
'banner' => $this->getBanner(),
|
||||
'git_branch' => $versionInfo->getGitBranchName(),
|
||||
'git_commit' => $versionInfo->getGitCommitHash(),
|
||||
'datatable' => $table
|
||||
'datatable' => $table,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -56,7 +56,6 @@ use Omines\DataTablesBundle\DataTableFactory;
|
|||
use phpDocumentor\Reflection\Element;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
use Symfony\Component\HttpFoundation\RedirectResponse;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Routing\Annotation\Route;
|
||||
|
@ -70,7 +69,6 @@ class LogController extends AbstractController
|
|||
protected $timeTravel;
|
||||
protected $dbRepository;
|
||||
|
||||
|
||||
public function __construct(EntityManagerInterface $entityManager, TimeTravel $timeTravel)
|
||||
{
|
||||
$this->entityManager = $entityManager;
|
||||
|
@ -81,8 +79,6 @@ class LogController extends AbstractController
|
|||
/**
|
||||
* @Route("/", name="log_view")
|
||||
*
|
||||
* @param Request $request
|
||||
* @param DataTableFactory $dataTable
|
||||
* @return JsonResponse|Response
|
||||
*/
|
||||
public function showLogs(Request $request, DataTableFactory $dataTable)
|
||||
|
@ -103,7 +99,6 @@ class LogController extends AbstractController
|
|||
|
||||
/**
|
||||
* @Route("/undo", name="log_undo", methods={"POST"})
|
||||
* @param Request $request
|
||||
*/
|
||||
public function undoRevertLog(Request $request, EventUndoHelper $eventUndoHelper)
|
||||
{
|
||||
|
@ -111,13 +106,13 @@ class LogController extends AbstractController
|
|||
$id = $request->request->get('undo');
|
||||
|
||||
//If no undo value was set check if a revert was set
|
||||
if ($id === null) {
|
||||
if (null === $id) {
|
||||
$id = $request->get('revert');
|
||||
$mode = EventUndoHelper::MODE_REVERT;
|
||||
}
|
||||
|
||||
$log_element = $this->entityManager->find(AbstractLogEntry::class, $id);
|
||||
if ($log_element === null) {
|
||||
if (null === $log_element) {
|
||||
throw new \InvalidArgumentException('No log entry with the given ID is existing!');
|
||||
}
|
||||
|
||||
|
@ -126,15 +121,16 @@ class LogController extends AbstractController
|
|||
$eventUndoHelper->setMode($mode);
|
||||
$eventUndoHelper->setUndoneEvent($log_element);
|
||||
|
||||
if ($mode === EventUndoHelper::MODE_UNDO) {
|
||||
if (EventUndoHelper::MODE_UNDO === $mode) {
|
||||
$this->undoLog($log_element);
|
||||
} elseif ($mode === EventUndoHelper::MODE_REVERT) {
|
||||
} elseif (EventUndoHelper::MODE_REVERT === $mode) {
|
||||
$this->revertLog($log_element);
|
||||
}
|
||||
|
||||
$eventUndoHelper->clearUndoneEvent();
|
||||
|
||||
$redirect = $request->request->get('redirect_back');
|
||||
|
||||
return $this->redirect($redirect);
|
||||
}
|
||||
|
||||
|
@ -143,15 +139,16 @@ class LogController extends AbstractController
|
|||
$timestamp = $logEntry->getTimestamp();
|
||||
$element = $this->entityManager->find($logEntry->getTargetClass(), $logEntry->getTargetID());
|
||||
//If the element is not available in DB try to undelete it
|
||||
if ($element === null) {
|
||||
if (null === $element) {
|
||||
$element = $this->timeTravel->undeleteEntity($logEntry->getTargetClass(), $logEntry->getTargetID());
|
||||
$this->entityManager->persist($element);
|
||||
$this->entityManager->flush();
|
||||
$this->dbRepository->changeID($element, $logEntry->getTargetID());
|
||||
}
|
||||
|
||||
if (!$element instanceof AbstractDBElement) {
|
||||
if (! $element instanceof AbstractDBElement) {
|
||||
$this->addFlash('error', 'log.undo.target_not_found');
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -172,7 +169,7 @@ class LogController extends AbstractController
|
|||
}
|
||||
|
||||
//Check if the element we want to undelete already exits
|
||||
if ($this->entityManager->find($element_class, $element_id) == null) {
|
||||
if (null === $this->entityManager->find($element_class, $element_id)) {
|
||||
$undeleted_element = $this->timeTravel->undeleteEntity($element_class, $element_id);
|
||||
$this->entityManager->persist($undeleted_element);
|
||||
$this->entityManager->flush();
|
||||
|
@ -183,7 +180,7 @@ class LogController extends AbstractController
|
|||
}
|
||||
} elseif ($log_element instanceof ElementCreatedLogEntry) {
|
||||
$element = $this->entityManager->find($log_element->getTargetClass(), $log_element->getTargetID());
|
||||
if ($element !== null) {
|
||||
if (null !== $element) {
|
||||
$this->entityManager->remove($element);
|
||||
$this->entityManager->flush();
|
||||
$this->addFlash('success', 'log.undo.element_delete_success');
|
||||
|
|
|
@ -87,8 +87,8 @@ class PartController extends AbstractController
|
|||
* @Route("/{id}/info/{timestamp}", name="part_info")
|
||||
* @Route("/{id}", requirements={"id"="\d+"})
|
||||
*
|
||||
* @param Part $part
|
||||
* @return Response
|
||||
*
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function show(Part $part, Request $request, TimeTravel $timeTravel, HistoryHelper $historyHelper,
|
||||
|
@ -97,7 +97,7 @@ class PartController extends AbstractController
|
|||
$this->denyAccessUnlessGranted('read', $part);
|
||||
|
||||
$timeTravel_timestamp = null;
|
||||
if ($timestamp !== null) {
|
||||
if (null !== $timestamp) {
|
||||
$this->denyAccessUnlessGranted('@tools.timetravel');
|
||||
$this->denyAccessUnlessGranted('show_history', $part);
|
||||
//If the timestamp only contains numbers interpret it as unix timestamp
|
||||
|
@ -110,10 +110,10 @@ class PartController extends AbstractController
|
|||
$timeTravel->revertEntityToTimestamp($part, $timeTravel_timestamp);
|
||||
}
|
||||
|
||||
if ($this->isGranted('show_history', $part) ) {
|
||||
if ($this->isGranted('show_history', $part)) {
|
||||
$table = $dataTable->createFromType(LogDataTable::class, [
|
||||
'filter_elements' => $historyHelper->getAssociatedElements($part),
|
||||
'mode' => 'element_history'
|
||||
'mode' => 'element_history',
|
||||
], ['pageLength' => 10])
|
||||
->handleRequest($request);
|
||||
|
||||
|
@ -132,7 +132,7 @@ class PartController extends AbstractController
|
|||
'attachment_helper' => $this->attachmentManager,
|
||||
'pricedetail_helper' => $this->pricedetailHelper,
|
||||
'pictures' => $this->partPreviewGenerator->getPreviewAttachments($part),
|
||||
'timeTravel' => $timeTravel_timestamp
|
||||
'timeTravel' => $timeTravel_timestamp,
|
||||
]
|
||||
);
|
||||
}
|
||||
|
@ -140,11 +140,6 @@ class PartController extends AbstractController
|
|||
/**
|
||||
* @Route("/{id}/edit", name="part_edit")
|
||||
*
|
||||
* @param Part $part
|
||||
* @param Request $request
|
||||
* @param EntityManagerInterface $em
|
||||
* @param TranslatorInterface $translator
|
||||
* @param AttachmentSubmitHandler $attachmentSubmitHandler
|
||||
* @return Response
|
||||
*/
|
||||
public function edit(Part $part, Request $request, EntityManagerInterface $em, TranslatorInterface $translator,
|
||||
|
@ -197,8 +192,6 @@ class PartController extends AbstractController
|
|||
/**
|
||||
* @Route("/{id}/delete", name="part_delete", methods={"DELETE"})
|
||||
*
|
||||
* @param Request $request
|
||||
* @param Part $part
|
||||
* @return RedirectResponse
|
||||
*/
|
||||
public function delete(Request $request, Part $part): RedirectResponse
|
||||
|
@ -226,17 +219,12 @@ class PartController extends AbstractController
|
|||
* @Route("/new", name="part_new")
|
||||
* @Route("/{id}/clone", name="part_clone")
|
||||
*
|
||||
* @param Request $request
|
||||
* @param EntityManagerInterface $em
|
||||
* @param TranslatorInterface $translator
|
||||
* @param AttachmentManager $attachmentHelper
|
||||
* @param AttachmentSubmitHandler $attachmentSubmitHandler
|
||||
* @return Response
|
||||
*/
|
||||
public function new(Request $request, EntityManagerInterface $em, TranslatorInterface $translator,
|
||||
AttachmentManager $attachmentHelper, AttachmentSubmitHandler $attachmentSubmitHandler, ?Part $part = null): Response
|
||||
{
|
||||
if($part === null) {
|
||||
if (null === $part) {
|
||||
$new_part = new Part();
|
||||
} else {
|
||||
$new_part = clone $part;
|
||||
|
@ -247,7 +235,7 @@ class PartController extends AbstractController
|
|||
$cid = $request->get('cid', 1);
|
||||
|
||||
$category = $em->find(Category::class, $cid);
|
||||
if (null !== $category && $new_part->getCategory() === null) {
|
||||
if (null !== $category && null === $new_part->getCategory()) {
|
||||
$new_part->setCategory($category);
|
||||
}
|
||||
|
||||
|
|
|
@ -60,9 +60,6 @@ class PartListsController extends AbstractController
|
|||
/**
|
||||
* @Route("/category/{id}/parts", name="part_list_category")
|
||||
*
|
||||
* @param Category $category
|
||||
* @param Request $request
|
||||
* @param DataTableFactory $dataTable
|
||||
* @return JsonResponse|Response
|
||||
*/
|
||||
public function showCategory(Category $category, Request $request, DataTableFactory $dataTable)
|
||||
|
@ -83,9 +80,6 @@ class PartListsController extends AbstractController
|
|||
/**
|
||||
* @Route("/footprint/{id}/parts", name="part_list_footprint")
|
||||
*
|
||||
* @param Footprint $footprint
|
||||
* @param Request $request
|
||||
* @param DataTableFactory $dataTable
|
||||
* @return JsonResponse|Response
|
||||
*/
|
||||
public function showFootprint(Footprint $footprint, Request $request, DataTableFactory $dataTable)
|
||||
|
@ -106,9 +100,6 @@ class PartListsController extends AbstractController
|
|||
/**
|
||||
* @Route("/manufacturer/{id}/parts", name="part_list_manufacturer")
|
||||
*
|
||||
* @param Manufacturer $manufacturer
|
||||
* @param Request $request
|
||||
* @param DataTableFactory $dataTable
|
||||
* @return JsonResponse|Response
|
||||
*/
|
||||
public function showManufacturer(Manufacturer $manufacturer, Request $request, DataTableFactory $dataTable)
|
||||
|
@ -129,9 +120,6 @@ class PartListsController extends AbstractController
|
|||
/**
|
||||
* @Route("/store_location/{id}/parts", name="part_list_store_location")
|
||||
*
|
||||
* @param Storelocation $storelocation
|
||||
* @param Request $request
|
||||
* @param DataTableFactory $dataTable
|
||||
* @return JsonResponse|Response
|
||||
*/
|
||||
public function showStorelocation(Storelocation $storelocation, Request $request, DataTableFactory $dataTable)
|
||||
|
@ -152,9 +140,6 @@ class PartListsController extends AbstractController
|
|||
/**
|
||||
* @Route("/supplier/{id}/parts", name="part_list_supplier")
|
||||
*
|
||||
* @param Supplier $supplier
|
||||
* @param Request $request
|
||||
* @param DataTableFactory $dataTable
|
||||
* @return JsonResponse|Response
|
||||
*/
|
||||
public function showSupplier(Supplier $supplier, Request $request, DataTableFactory $dataTable)
|
||||
|
@ -175,9 +160,6 @@ class PartListsController extends AbstractController
|
|||
/**
|
||||
* @Route("/parts/by_tag/{tag}", name="part_list_tags")
|
||||
*
|
||||
* @param string $tag
|
||||
* @param Request $request
|
||||
* @param DataTableFactory $dataTable
|
||||
* @return JsonResponse|Response
|
||||
*/
|
||||
public function showTag(string $tag, Request $request, DataTableFactory $dataTable)
|
||||
|
@ -197,8 +179,7 @@ class PartListsController extends AbstractController
|
|||
|
||||
/**
|
||||
* @Route("/parts/search", name="parts_search")
|
||||
* @param Request $request
|
||||
* @param DataTableFactory $dataTable
|
||||
*
|
||||
* @return JsonResponse|Response
|
||||
*/
|
||||
public function showSearch(Request $request, DataTableFactory $dataTable)
|
||||
|
@ -218,9 +199,8 @@ class PartListsController extends AbstractController
|
|||
'regex' => $request->query->getBoolean('regex'),
|
||||
];
|
||||
|
||||
|
||||
$table = $dataTable->createFromType(PartsDataTable::class, [
|
||||
'search' => $search, 'search_options' => $search_options
|
||||
'search' => $search, 'search_options' => $search_options,
|
||||
])
|
||||
->handleRequest($request);
|
||||
|
||||
|
@ -237,8 +217,6 @@ class PartListsController extends AbstractController
|
|||
/**
|
||||
* @Route("/parts", name="parts_show_all")
|
||||
*
|
||||
* @param Request $request
|
||||
* @param DataTableFactory $dataTable
|
||||
* @return JsonResponse|Response
|
||||
*/
|
||||
public function showAll(Request $request, DataTableFactory $dataTable)
|
||||
|
|
|
@ -70,7 +70,6 @@ class RedirectController extends AbstractController
|
|||
* This function is called whenever a route was not matching the localized routes.
|
||||
* The purpose is to redirect the user to the localized version of the page.
|
||||
*
|
||||
* @param Request $request
|
||||
* @return RedirectResponse
|
||||
*/
|
||||
public function addLocalePart(Request $request): RedirectResponse
|
||||
|
|
|
@ -71,7 +71,7 @@ class SecurityController extends AbstractController
|
|||
|
||||
/**
|
||||
* @Route("/login", name="login", methods={"GET", "POST"})
|
||||
* @param AuthenticationUtils $authenticationUtils
|
||||
*
|
||||
* @return \Symfony\Component\HttpFoundation\Response
|
||||
*/
|
||||
public function login(AuthenticationUtils $authenticationUtils): \Symfony\Component\HttpFoundation\Response
|
||||
|
@ -90,8 +90,7 @@ class SecurityController extends AbstractController
|
|||
|
||||
/**
|
||||
* @Route("/pw_reset/request", name="pw_reset_request")
|
||||
* @param PasswordResetManager $passwordReset
|
||||
* @param Request $request
|
||||
*
|
||||
* @return \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response
|
||||
*/
|
||||
public function requestPwReset(PasswordResetManager $passwordReset, Request $request)
|
||||
|
@ -135,10 +134,7 @@ class SecurityController extends AbstractController
|
|||
|
||||
/**
|
||||
* @Route("/pw_reset/new_pw/{user}/{token}", name="pw_reset_new_pw")
|
||||
* @param PasswordResetManager $passwordReset
|
||||
* @param Request $request
|
||||
* @param string|null $user
|
||||
* @param string|null $token
|
||||
*
|
||||
* @return \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response
|
||||
*/
|
||||
public function pwResetNewPw(PasswordResetManager $passwordReset, Request $request, ?string $user = null, ?string $token = null)
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
|
@ -20,7 +23,6 @@
|
|||
|
||||
namespace App\Controller;
|
||||
|
||||
|
||||
use App\Services\StatisticsHelper;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
@ -30,6 +32,7 @@ class StatisticsController extends AbstractController
|
|||
{
|
||||
/**
|
||||
* @Route("/statistics", name="statistics_view")
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function showStatistics(StatisticsHelper $helper): Response
|
||||
|
@ -40,4 +43,4 @@ class StatisticsController extends AbstractController
|
|||
'helper' => $helper,
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -70,7 +70,7 @@ class TreeController extends AbstractController
|
|||
|
||||
/**
|
||||
* @Route("/tools", name="tree_tools")
|
||||
* @param ToolsTreeBuilder $builder
|
||||
*
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function tools(ToolsTreeBuilder $builder): JsonResponse
|
||||
|
@ -83,7 +83,7 @@ class TreeController extends AbstractController
|
|||
/**
|
||||
* @Route("/category/{id}", name="tree_category")
|
||||
* @Route("/categories")
|
||||
* @param Category|null $category
|
||||
*
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function categoryTree(?Category $category = null): JsonResponse
|
||||
|
@ -96,7 +96,7 @@ class TreeController extends AbstractController
|
|||
/**
|
||||
* @Route("/footprint/{id}", name="tree_footprint")
|
||||
* @Route("/footprints")
|
||||
* @param Footprint|null $footprint
|
||||
*
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function footprintTree(?Footprint $footprint = null): JsonResponse
|
||||
|
@ -109,7 +109,7 @@ class TreeController extends AbstractController
|
|||
/**
|
||||
* @Route("/location/{id}", name="tree_location")
|
||||
* @Route("/locations")
|
||||
* @param Storelocation|null $location
|
||||
*
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function locationTree(?Storelocation $location = null): JsonResponse
|
||||
|
@ -122,7 +122,7 @@ class TreeController extends AbstractController
|
|||
/**
|
||||
* @Route("/manufacturer/{id}", name="tree_manufacturer")
|
||||
* @Route("/manufacturers")
|
||||
* @param Manufacturer|null $manufacturer
|
||||
*
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function manufacturerTree(?Manufacturer $manufacturer = null): JsonResponse
|
||||
|
@ -135,7 +135,7 @@ class TreeController extends AbstractController
|
|||
/**
|
||||
* @Route("/supplier/{id}", name="tree_supplier")
|
||||
* @Route("/suppliers")
|
||||
* @param Supplier|null $supplier
|
||||
*
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function supplierTree(?Supplier $supplier = null): JsonResponse
|
||||
|
@ -148,7 +148,7 @@ class TreeController extends AbstractController
|
|||
/**
|
||||
* @Route("/device/{id}", name="tree_device")
|
||||
* @Route("/devices")
|
||||
* @param Device|null $device
|
||||
*
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function deviceTree(?Device $device = null): JsonResponse
|
||||
|
|
|
@ -61,9 +61,7 @@ class TypeaheadController extends AbstractController
|
|||
{
|
||||
/**
|
||||
* @Route("/builtInResources/search/{query}", name="typeahead_builtInRessources", requirements={"query"= ".+"})
|
||||
* @param Request $request
|
||||
* @param string $query
|
||||
* @param BuiltinAttachmentsFinder $finder
|
||||
*
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function builtInResources(Request $request, string $query, BuiltinAttachmentsFinder $finder)
|
||||
|
@ -84,8 +82,7 @@ class TypeaheadController extends AbstractController
|
|||
|
||||
/**
|
||||
* @Route("/tags/search/{query}", name="typeahead_tags", requirements={"query"= ".+"})
|
||||
* @param string $query
|
||||
* @param TagFinder $finder
|
||||
*
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function tags(string $query, TagFinder $finder)
|
||||
|
|
|
@ -71,10 +71,9 @@ class UserController extends AdminPages\BaseAdminController
|
|||
/**
|
||||
* @Route("/{id}/edit/{timestamp}", requirements={"id"="\d+"}, name="user_edit")
|
||||
* @Route("/{id}/", requirements={"id"="\d+"})
|
||||
* @param User $entity
|
||||
* @param Request $request
|
||||
* @param EntityManagerInterface $em
|
||||
*
|
||||
* @return Response
|
||||
*
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function edit(User $entity, Request $request, EntityManagerInterface $em, ?string $timestamp = null)
|
||||
|
@ -109,9 +108,6 @@ class UserController extends AdminPages\BaseAdminController
|
|||
* @Route("/new", name="user_new")
|
||||
* @Route("/")
|
||||
*
|
||||
* @param Request $request
|
||||
* @param EntityManagerInterface $em
|
||||
* @param EntityImporter $importer
|
||||
* @return Response
|
||||
*/
|
||||
public function new(Request $request, EntityManagerInterface $em, EntityImporter $importer): Response
|
||||
|
@ -121,9 +117,7 @@ class UserController extends AdminPages\BaseAdminController
|
|||
|
||||
/**
|
||||
* @Route("/{id}", name="user_delete", methods={"DELETE"}, requirements={"id"="\d+"})
|
||||
* @param Request $request
|
||||
* @param User $entity
|
||||
* @param StructuralElementRecursionHelper $recursionHelper
|
||||
*
|
||||
* @return \Symfony\Component\HttpFoundation\RedirectResponse
|
||||
*/
|
||||
public function delete(Request $request, User $entity, StructuralElementRecursionHelper $recursionHelper)
|
||||
|
@ -138,9 +132,6 @@ class UserController extends AdminPages\BaseAdminController
|
|||
/**
|
||||
* @Route("/export", name="user_export_all")
|
||||
*
|
||||
* @param EntityManagerInterface $em
|
||||
* @param EntityExporter $exporter
|
||||
* @param Request $request
|
||||
* @return Response
|
||||
*/
|
||||
public function exportAll(EntityManagerInterface $em, EntityExporter $exporter, Request $request): Response
|
||||
|
@ -151,10 +142,6 @@ class UserController extends AdminPages\BaseAdminController
|
|||
/**
|
||||
* @Route("/{id}/export", name="user_export")
|
||||
*
|
||||
* @param User $entity
|
||||
*
|
||||
* @param EntityExporter $exporter
|
||||
* @param Request $request
|
||||
* @return Response
|
||||
*/
|
||||
public function exportEntity(User $entity, EntityExporter $exporter, Request $request): Response
|
||||
|
@ -165,8 +152,7 @@ class UserController extends AdminPages\BaseAdminController
|
|||
/**
|
||||
* @Route("/info", name="user_info_self")
|
||||
* @Route("/{id}/info", name="user_info")
|
||||
* @param User|null $user
|
||||
* @param Packages $packages
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function userInfo(?User $user, Packages $packages): Response
|
||||
|
@ -174,7 +160,7 @@ class UserController extends AdminPages\BaseAdminController
|
|||
//If no user id was passed, then we show info about the current user
|
||||
if (null === $user) {
|
||||
$tmp = $this->getUser();
|
||||
if(!$tmp instanceof User) {
|
||||
if (! $tmp instanceof User) {
|
||||
throw new InvalidArgumentException('Userinfo only works for database users!');
|
||||
}
|
||||
$user = $tmp;
|
||||
|
|
|
@ -102,9 +102,6 @@ class UserSettingsController extends AbstractController
|
|||
/**
|
||||
* @Route("/u2f_delete", name="u2f_delete", methods={"DELETE"})
|
||||
*
|
||||
* @param Request $request
|
||||
* @param EntityManagerInterface $entityManager
|
||||
* @param BackupCodeManager $backupCodeManager
|
||||
* @return RedirectResponse
|
||||
*/
|
||||
public function removeU2FToken(Request $request, EntityManagerInterface $entityManager, BackupCodeManager $backupCodeManager): RedirectResponse
|
||||
|
@ -155,8 +152,7 @@ class UserSettingsController extends AbstractController
|
|||
|
||||
/**
|
||||
* @Route("/invalidate_trustedDevices", name="tfa_trustedDevices_invalidate", methods={"DELETE"})
|
||||
* @param Request $request
|
||||
* @param EntityManagerInterface $entityManager
|
||||
*
|
||||
* @return RuntimeException|RedirectResponse
|
||||
*/
|
||||
public function resetTrustedDevices(Request $request, EntityManagerInterface $entityManager)
|
||||
|
@ -187,11 +183,7 @@ class UserSettingsController extends AbstractController
|
|||
|
||||
/**
|
||||
* @Route("/settings", name="user_settings")
|
||||
* @param Request $request
|
||||
* @param EntityManagerInterface $em
|
||||
* @param UserPasswordEncoderInterface $passwordEncoder
|
||||
* @param GoogleAuthenticator $googleAuthenticator
|
||||
* @param BackupCodeManager $backupCodeManager
|
||||
*
|
||||
* @return RedirectResponse|\Symfony\Component\HttpFoundation\Response
|
||||
*/
|
||||
public function userSettings(Request $request, EntityManagerInterface $em, UserPasswordEncoderInterface $passwordEncoder, GoogleAuthenticator $googleAuthenticator, BackupCodeManager $backupCodeManager)
|
||||
|
@ -266,9 +258,9 @@ class UserSettingsController extends AbstractController
|
|||
],
|
||||
],
|
||||
'constraints' => [new Length([
|
||||
'min' => 6,
|
||||
'max' => 128,
|
||||
])],
|
||||
'min' => 6,
|
||||
'max' => 128,
|
||||
])],
|
||||
])
|
||||
->add('submit', SubmitType::class, ['label' => 'save'])
|
||||
->getForm();
|
||||
|
@ -297,7 +289,7 @@ class UserSettingsController extends AbstractController
|
|||
}
|
||||
$google_form->handleRequest($request);
|
||||
|
||||
if ( ! $this->demo_mode && $google_form->isSubmitted() && $google_form->isValid()) {
|
||||
if (! $this->demo_mode && $google_form->isSubmitted() && $google_form->isValid()) {
|
||||
if (! $google_enabled) {
|
||||
//Save 2FA settings (save secrets)
|
||||
$user->setGoogleAuthenticatorSecret($google_form->get('googleAuthenticatorSecret')->getData());
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
|
@ -20,7 +23,6 @@
|
|||
|
||||
namespace App\DataFixtures;
|
||||
|
||||
|
||||
use App\Entity\Attachments\AttachmentType;
|
||||
use App\Entity\Attachments\PartAttachment;
|
||||
use App\Entity\Parts\Category;
|
||||
|
@ -38,7 +40,6 @@ use Doctrine\Persistence\ObjectManager;
|
|||
|
||||
class PartFixtures extends Fixture
|
||||
{
|
||||
|
||||
protected $em;
|
||||
|
||||
public function __construct(EntityManagerInterface $entityManager)
|
||||
|
@ -46,10 +47,7 @@ class PartFixtures extends Fixture
|
|||
$this->em = $entityManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function load(ObjectManager $manager)
|
||||
public function load(ObjectManager $manager): void
|
||||
{
|
||||
$table_name = $this->em->getClassMetadata(Part::class)->getTableName();
|
||||
$this->em->getConnection()->exec("ALTER TABLE `${table_name}` AUTO_INCREMENT = 1;");
|
||||
|
@ -119,4 +117,4 @@ class PartFixtures extends Fixture
|
|||
$manager->persist($part);
|
||||
$manager->flush();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -47,7 +47,6 @@ use Doctrine\ORM\QueryBuilder;
|
|||
use Doctrine\ORM\Tools\Pagination\Paginator;
|
||||
use Omines\DataTablesBundle\Adapter\AdapterQuery;
|
||||
use Omines\DataTablesBundle\Adapter\Doctrine\Event\ORMAdapterQueryEvent;
|
||||
use Omines\DataTablesBundle\Adapter\Doctrine\ORMAdapterEvents;
|
||||
use Omines\DataTablesBundle\Column\AbstractColumn;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
|
||||
|
|
|
@ -90,7 +90,7 @@ class EntityColumn extends AbstractColumn
|
|||
/** @var AbstractDBElement|null $entity */
|
||||
$entity = $this->accessor->getValue($context, $options['property']);
|
||||
|
||||
if ($entity !== null) {
|
||||
if (null !== $entity) {
|
||||
if (null !== $entity->getID()) {
|
||||
return sprintf(
|
||||
'<a href="%s">%s</a>',
|
||||
|
@ -101,6 +101,7 @@ class EntityColumn extends AbstractColumn
|
|||
|
||||
return sprintf('<i>%s</i>', $value);
|
||||
}
|
||||
|
||||
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).
|
||||
*
|
||||
|
@ -20,16 +23,11 @@
|
|||
|
||||
namespace App\DataTables\Column;
|
||||
|
||||
|
||||
use Omines\DataTablesBundle\Column\AbstractColumn;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
|
||||
class IconLinkColumn extends AbstractColumn
|
||||
{
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function normalize($value)
|
||||
{
|
||||
return $value;
|
||||
|
@ -39,11 +37,11 @@ class IconLinkColumn extends AbstractColumn
|
|||
{
|
||||
parent::configureOptions($resolver);
|
||||
$resolver->setDefaults([
|
||||
'icon' => 'fas fa-fw fa-edit',
|
||||
'title' => null,
|
||||
'href' => null,
|
||||
'disabled' => false,
|
||||
]);
|
||||
'icon' => 'fas fa-fw fa-edit',
|
||||
'title' => null,
|
||||
'href' => null,
|
||||
'disabled' => false,
|
||||
]);
|
||||
|
||||
$resolver->setAllowedTypes('title', ['null', 'string', 'callable']);
|
||||
$resolver->setAllowedTypes('icon', ['null', 'string', 'callable']);
|
||||
|
@ -60,7 +58,7 @@ class IconLinkColumn extends AbstractColumn
|
|||
$title = $this->getTitle($value, $context);
|
||||
$disabled = $this->getDisabled($value, $context);
|
||||
|
||||
if ($href !== null) {
|
||||
if (null !== $href) {
|
||||
return sprintf(
|
||||
'<a class="btn btn-primary btn-sm %s" href="%s" title="%s"><i class="%s"></i></a>',
|
||||
$disabled ? 'disabled' : '',
|
||||
|
@ -70,7 +68,7 @@ class IconLinkColumn extends AbstractColumn
|
|||
);
|
||||
}
|
||||
|
||||
return "";
|
||||
return '';
|
||||
}
|
||||
|
||||
protected function getDisabled($value, $context): bool
|
||||
|
@ -82,6 +80,7 @@ class IconLinkColumn extends AbstractColumn
|
|||
if (is_callable($provider)) {
|
||||
return call_user_func($provider, $value, $context);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -123,4 +122,4 @@ class IconLinkColumn extends AbstractColumn
|
|||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -80,6 +80,7 @@ class LogEntryTargetColumn extends AbstractColumn
|
|||
public function configureOptions(OptionsResolver $resolver)
|
||||
{
|
||||
parent::configureOptions($resolver);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
|
|
@ -112,6 +112,7 @@ class PartAttachmentsColumn extends AbstractColumn
|
|||
public function configureOptions(OptionsResolver $resolver)
|
||||
{
|
||||
parent::configureOptions($resolver);
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
|
@ -20,8 +23,6 @@
|
|||
|
||||
namespace App\DataTables\Column;
|
||||
|
||||
|
||||
use App\Entity\LogSystem\AbstractLogEntry;
|
||||
use App\Entity\LogSystem\CollectionElementDeleted;
|
||||
use App\Entity\LogSystem\ElementCreatedLogEntry;
|
||||
use App\Entity\LogSystem\ElementDeletedLogEntry;
|
||||
|
@ -41,9 +42,6 @@ class RevertLogColumn extends AbstractColumn
|
|||
$this->security = $security;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function normalize($value)
|
||||
{
|
||||
return $value;
|
||||
|
@ -68,7 +66,7 @@ class RevertLogColumn extends AbstractColumn
|
|||
return '';
|
||||
}
|
||||
|
||||
$disabled = !$this->security->isGranted('revert_element', $context->getTargetClass());
|
||||
$disabled = ! $this->security->isGranted('revert_element', $context->getTargetClass());
|
||||
|
||||
$tmp = '<div class="btn-group btn-group-sm">';
|
||||
$tmp .= sprintf(
|
||||
|
@ -90,4 +88,4 @@ class RevertLogColumn extends AbstractColumn
|
|||
|
||||
return $tmp;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -70,7 +70,6 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
|
|||
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
|
||||
use Symfony\Component\Security\Core\Security;
|
||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
use Symfony\Flex\Options;
|
||||
|
||||
class LogDataTable implements DataTableTypeInterface
|
||||
{
|
||||
|
@ -92,12 +91,12 @@ class LogDataTable implements DataTableTypeInterface
|
|||
$this->security = $security;
|
||||
}
|
||||
|
||||
public function configureOptions(OptionsResolver $optionsResolver)
|
||||
public function configureOptions(OptionsResolver $optionsResolver): void
|
||||
{
|
||||
$optionsResolver->setDefaults([
|
||||
'mode' => 'system_log',
|
||||
'filter_elements' => [],
|
||||
]);
|
||||
'mode' => 'system_log',
|
||||
'filter_elements' => [],
|
||||
]);
|
||||
|
||||
$optionsResolver->setAllowedValues('mode', ['system_log', 'element_history', 'last_activity']);
|
||||
}
|
||||
|
@ -108,7 +107,6 @@ class LogDataTable implements DataTableTypeInterface
|
|||
$this->configureOptions($resolver);
|
||||
$options = $resolver->resolve($options);
|
||||
|
||||
|
||||
$dataTable->add('symbol', TextColumn::class, [
|
||||
'label' => '',
|
||||
'render' => function ($value, AbstractLogEntry $context) {
|
||||
|
@ -179,7 +177,7 @@ class LogDataTable implements DataTableTypeInterface
|
|||
|
||||
$dataTable->add('level', TextColumn::class, [
|
||||
'label' => $this->translator->trans('log.level'),
|
||||
'visible' => $options['mode'] === 'system_log',
|
||||
'visible' => 'system_log' === $options['mode'],
|
||||
'propertyPath' => 'levelString',
|
||||
'render' => function (string $value, AbstractLogEntry $context) {
|
||||
return $value;
|
||||
|
@ -220,7 +218,7 @@ class LogDataTable implements DataTableTypeInterface
|
|||
'label' => $this->translator->trans('log.extra'),
|
||||
]);
|
||||
|
||||
$dataTable->add('timeTravel', IconLinkColumn::class,[
|
||||
$dataTable->add('timeTravel', IconLinkColumn::class, [
|
||||
'label' => '',
|
||||
'icon' => 'fas fa-fw fa-eye',
|
||||
'href' => function ($value, AbstractLogEntry $context) {
|
||||
|
@ -231,26 +229,25 @@ class LogDataTable implements DataTableTypeInterface
|
|||
) {
|
||||
try {
|
||||
$target = $this->logRepo->getTargetElement($context);
|
||||
if($target !== null) {
|
||||
$str = $this->entityURLGenerator->timeTravelURL($target, $context->getTimestamp());
|
||||
return $str;
|
||||
if (null !== $target) {
|
||||
return $this->entityURLGenerator->timeTravelURL($target, $context->getTimestamp());
|
||||
}
|
||||
} catch (EntityNotSupportedException $exception) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
},
|
||||
'disabled' => function ($value, AbstractLogEntry $context) {
|
||||
return
|
||||
!$this->security->isGranted('@tools.timetravel')
|
||||
|| !$this->security->isGranted('show_history', $context->getTargetClass());
|
||||
}
|
||||
|
||||
! $this->security->isGranted('@tools.timetravel')
|
||||
|| ! $this->security->isGranted('show_history', $context->getTargetClass());
|
||||
},
|
||||
]);
|
||||
|
||||
$dataTable->add('actionRevert', RevertLogColumn::class, [
|
||||
'label' => ''
|
||||
'label' => '',
|
||||
]);
|
||||
|
||||
$dataTable->addOrderBy('timestamp', DataTable::SORT_DESCENDING);
|
||||
|
@ -270,12 +267,12 @@ class LogDataTable implements DataTableTypeInterface
|
|||
->from(AbstractLogEntry::class, 'log')
|
||||
->leftJoin('log.user', 'user');
|
||||
|
||||
if ($options['mode'] === 'last_activity') {
|
||||
$builder->where('log INSTANCE OF ' . ElementCreatedLogEntry::class)
|
||||
->orWhere('log INSTANCE OF ' . ElementDeletedLogEntry::class)
|
||||
->orWhere('log INSTANCE OF ' . ElementEditedLogEntry::class)
|
||||
->orWhere('log INSTANCE OF ' . CollectionElementDeleted::class)
|
||||
->andWhere('log.target_type NOT IN (:disallowed)');;
|
||||
if ('last_activity' === $options['mode']) {
|
||||
$builder->where('log INSTANCE OF '.ElementCreatedLogEntry::class)
|
||||
->orWhere('log INSTANCE OF '.ElementDeletedLogEntry::class)
|
||||
->orWhere('log INSTANCE OF '.ElementEditedLogEntry::class)
|
||||
->orWhere('log INSTANCE OF '.CollectionElementDeleted::class)
|
||||
->andWhere('log.target_type NOT IN (:disallowed)');
|
||||
|
||||
$builder->setParameter('disallowed', [
|
||||
AbstractLogEntry::targetTypeClassToID(User::class),
|
||||
|
@ -283,13 +280,13 @@ class LogDataTable implements DataTableTypeInterface
|
|||
]);
|
||||
}
|
||||
|
||||
if (!empty($options['filter_elements'])) {
|
||||
if (! empty($options['filter_elements'])) {
|
||||
foreach ($options['filter_elements'] as $element) {
|
||||
/** @var AbstractDBElement $element */
|
||||
|
||||
$target_type = AbstractLogEntry::targetTypeClassToID(get_class($element));
|
||||
$target_id = $element->getID();
|
||||
$builder->orWhere("log.target_type = $target_type AND log.target_id = $target_id");
|
||||
$builder->orWhere("log.target_type = ${target_type} AND log.target_id = ${target_id}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -93,17 +93,17 @@ final class PartsDataTable implements DataTableTypeInterface
|
|||
$this->attachmentURLGenerator = $attachmentURLGenerator;
|
||||
}
|
||||
|
||||
public function configureOptions(OptionsResolver $optionsResolver)
|
||||
public function configureOptions(OptionsResolver $optionsResolver): void
|
||||
{
|
||||
$optionsResolver->setDefaults([
|
||||
'category' => null,
|
||||
'footprint' => null,
|
||||
'manufacturer' => null,
|
||||
'storelocation' => null,
|
||||
'supplier' => null,
|
||||
'tag' => null,
|
||||
'search' => null,
|
||||
]);
|
||||
'category' => null,
|
||||
'footprint' => null,
|
||||
'manufacturer' => null,
|
||||
'storelocation' => null,
|
||||
'supplier' => null,
|
||||
'tag' => null,
|
||||
'search' => null,
|
||||
]);
|
||||
|
||||
$optionsResolver->setAllowedTypes('category', ['null', Category::class]);
|
||||
$optionsResolver->setAllowedTypes('footprint', ['null', Footprint::class]);
|
||||
|
@ -113,20 +113,20 @@ final class PartsDataTable implements DataTableTypeInterface
|
|||
$optionsResolver->setAllowedTypes('search', ['null', 'string']);
|
||||
|
||||
//Configure search options
|
||||
$optionsResolver->setDefault('search_options', function (OptionsResolver $resolver) {
|
||||
$optionsResolver->setDefault('search_options', function (OptionsResolver $resolver): void {
|
||||
$resolver->setDefaults([
|
||||
'name' => true,
|
||||
'category' => true,
|
||||
'description' => true,
|
||||
'store_location' => true,
|
||||
'comment' => true,
|
||||
'ordernr' => true,
|
||||
'supplier' => false,
|
||||
'manufacturer' => false,
|
||||
'footprint' => false,
|
||||
'tags' => false,
|
||||
'regex' => false,
|
||||
]);
|
||||
'name' => true,
|
||||
'category' => true,
|
||||
'description' => true,
|
||||
'store_location' => true,
|
||||
'comment' => true,
|
||||
'ordernr' => true,
|
||||
'supplier' => false,
|
||||
'manufacturer' => false,
|
||||
'footprint' => false,
|
||||
'tags' => false,
|
||||
'regex' => false,
|
||||
]);
|
||||
$resolver->setAllowedTypes('name', 'bool');
|
||||
$resolver->setAllowedTypes('category', 'bool');
|
||||
$resolver->setAllowedTypes('description', 'bool');
|
||||
|
@ -375,8 +375,8 @@ final class PartsDataTable implements DataTableTypeInterface
|
|||
$builder->andWhere('part.tags LIKE :tag')->setParameter('tag', '%'.$options['tag'].'%');
|
||||
}
|
||||
|
||||
if (!empty($options['search'])) {
|
||||
if (!$options['search_options']['regex']) {
|
||||
if (! empty($options['search'])) {
|
||||
if (! $options['search_options']['regex']) {
|
||||
//Dont show results, if no things are selected
|
||||
$builder->andWhere('0=1');
|
||||
$defined = false;
|
||||
|
@ -463,7 +463,6 @@ final class PartsDataTable implements DataTableTypeInterface
|
|||
if ($defined) {
|
||||
$builder->setParameter('search', $options['search']);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -365,7 +365,6 @@ abstract class Attachment extends AbstractNamedDBElement
|
|||
/**
|
||||
* Sets the element that is associated with this attachment.
|
||||
*
|
||||
* @param AttachmentContainingDBElement $element
|
||||
* @return $this
|
||||
*/
|
||||
public function setElement(AttachmentContainingDBElement $element): self
|
||||
|
@ -394,7 +393,6 @@ abstract class Attachment extends AbstractNamedDBElement
|
|||
}
|
||||
|
||||
/**
|
||||
* @param AttachmentType $attachement_type
|
||||
* @return $this
|
||||
*/
|
||||
public function setAttachmentType(AttachmentType $attachement_type): self
|
||||
|
@ -408,7 +406,6 @@ abstract class Attachment extends AbstractNamedDBElement
|
|||
* Sets the url associated with this attachment.
|
||||
* If the url is empty nothing is changed, to not override the file path.
|
||||
*
|
||||
* @param string|null $url
|
||||
* @return Attachment
|
||||
*/
|
||||
public function setURL(?string $url): self
|
||||
|
|
|
@ -22,8 +22,8 @@ declare(strict_types=1);
|
|||
|
||||
namespace App\Entity\Attachments;
|
||||
|
||||
use App\Entity\Base\MasterAttachmentTrait;
|
||||
use App\Entity\Base\AbstractNamedDBElement;
|
||||
use App\Entity\Base\MasterAttachmentTrait;
|
||||
use App\Entity\Contracts\HasAttachmentsInterface;
|
||||
use App\Entity\Contracts\HasMasterAttachmentInterface;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
|
@ -39,8 +39,8 @@ abstract class AttachmentContainingDBElement extends AbstractNamedDBElement impl
|
|||
|
||||
/**
|
||||
* @var Attachment[]|Collection
|
||||
* //TODO
|
||||
* //@ORM\OneToMany(targetEntity="Attachment", mappedBy="element")
|
||||
* //TODO
|
||||
* //@ORM\OneToMany(targetEntity="Attachment", mappedBy="element")
|
||||
*
|
||||
* Mapping is done in sub classes like part
|
||||
*/
|
||||
|
@ -51,6 +51,25 @@ abstract class AttachmentContainingDBElement extends AbstractNamedDBElement impl
|
|||
$this->attachments = new ArrayCollection();
|
||||
}
|
||||
|
||||
public function __clone()
|
||||
{
|
||||
if ($this->id) {
|
||||
$attachments = $this->attachments;
|
||||
$this->attachments = new ArrayCollection();
|
||||
//Set master attachment is needed
|
||||
foreach ($attachments as $attachment) {
|
||||
$clone = clone $attachment;
|
||||
if ($attachment === $this->master_picture_attachment) {
|
||||
$this->setMasterPictureAttachment($clone);
|
||||
}
|
||||
$this->addAttachment($clone);
|
||||
}
|
||||
}
|
||||
|
||||
//Parent has to be last call, as it resets the ID
|
||||
parent::__clone();
|
||||
}
|
||||
|
||||
/********************************************************************************
|
||||
*
|
||||
* Getters
|
||||
|
@ -86,7 +105,6 @@ abstract class AttachmentContainingDBElement extends AbstractNamedDBElement impl
|
|||
/**
|
||||
* Removes the given attachment from this element.
|
||||
*
|
||||
* @param Attachment $attachment
|
||||
* @return $this
|
||||
*/
|
||||
public function removeAttachment(Attachment $attachment): self
|
||||
|
@ -95,23 +113,4 @@ abstract class AttachmentContainingDBElement extends AbstractNamedDBElement impl
|
|||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function __clone()
|
||||
{
|
||||
if ($this->id) {
|
||||
$attachments = $this->attachments;
|
||||
$this->attachments = new ArrayCollection();
|
||||
//Set master attachment is needed
|
||||
foreach ($attachments as $attachment) {
|
||||
$clone = clone $attachment;
|
||||
if ($attachment === $this->master_picture_attachment) {
|
||||
$this->setMasterPictureAttachment($clone);
|
||||
}
|
||||
$this->addAttachment($clone);
|
||||
}
|
||||
}
|
||||
|
||||
//Parent has to be last call, as it resets the ID
|
||||
parent::__clone();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,7 +24,6 @@ namespace App\Entity\Attachments;
|
|||
|
||||
use App\Entity\Base\AbstractStructuralDBElement;
|
||||
use App\Entity\Parameters\AttachmentTypeParameter;
|
||||
use App\Entity\Parameters\DeviceParameter;
|
||||
use App\Validator\Constraints\ValidFileFilter;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
|
|
|
@ -173,7 +173,7 @@ abstract class AbstractCompany extends AbstractPartsContainingDBElement
|
|||
/**
|
||||
* Set the addres.
|
||||
*
|
||||
* @param string $new_address the new address (with "\n" as line break)
|
||||
* @param string $new_address the new address (with "\n" as line break)
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
|
@ -188,6 +188,7 @@ abstract class AbstractCompany extends AbstractPartsContainingDBElement
|
|||
* Set the phone number.
|
||||
*
|
||||
* @param string $new_phone_number the new phone number
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setPhoneNumber(string $new_phone_number): self
|
||||
|
@ -201,6 +202,7 @@ abstract class AbstractCompany extends AbstractPartsContainingDBElement
|
|||
* Set the fax number.
|
||||
*
|
||||
* @param string $new_fax_number the new fax number
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setFaxNumber(string $new_fax_number): self
|
||||
|
@ -214,6 +216,7 @@ abstract class AbstractCompany extends AbstractPartsContainingDBElement
|
|||
* Set the e-mail address.
|
||||
*
|
||||
* @param string $new_email_address the new e-mail address
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setEmailAddress(string $new_email_address): self
|
||||
|
@ -227,6 +230,7 @@ abstract class AbstractCompany extends AbstractPartsContainingDBElement
|
|||
* Set the website.
|
||||
*
|
||||
* @param string $new_website the new website
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setWebsite(string $new_website): self
|
||||
|
@ -240,6 +244,7 @@ abstract class AbstractCompany extends AbstractPartsContainingDBElement
|
|||
* Set the link to the website of an article.
|
||||
*
|
||||
* @param string $new_url the new URL with the placeholder %PARTNUMBER% for the part number
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setAutoProductUrl(string $new_url): self
|
||||
|
|
|
@ -57,6 +57,15 @@ abstract class AbstractNamedDBElement extends AbstractDBElement implements Named
|
|||
return $this->getName();
|
||||
}
|
||||
|
||||
public function __clone()
|
||||
{
|
||||
if ($this->id) {
|
||||
//We create a new object, so give it a new creation date
|
||||
$this->addedDate = null;
|
||||
}
|
||||
parent::__clone(); // TODO: Change the autogenerated stub
|
||||
}
|
||||
|
||||
/********************************************************************************
|
||||
*
|
||||
* Getters
|
||||
|
@ -89,15 +98,7 @@ abstract class AbstractNamedDBElement extends AbstractDBElement implements Named
|
|||
public function setName(string $new_name): self
|
||||
{
|
||||
$this->name = $new_name;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function __clone()
|
||||
{
|
||||
if ($this->id) {
|
||||
//We create a new object, so give it a new creation date
|
||||
$this->addedDate = null;
|
||||
}
|
||||
parent::__clone(); // TODO: Change the autogenerated stub
|
||||
}
|
||||
}
|
||||
|
|
|
@ -115,7 +115,7 @@ abstract class AbstractStructuralDBElement extends AttachmentContainingDBElement
|
|||
* Check if this element is a child of another element (recursive).
|
||||
*
|
||||
* @param AbstractStructuralDBElement $another_element the object to compare
|
||||
* IMPORTANT: both objects to compare must be from the same class (for example two "Device" objects)!
|
||||
* IMPORTANT: both objects to compare must be from the same class (for example two "Device" objects)!
|
||||
*
|
||||
* @return bool True, if this element is child of $another_element.
|
||||
*
|
||||
|
@ -316,13 +316,14 @@ abstract class AbstractStructuralDBElement extends AttachmentContainingDBElement
|
|||
}
|
||||
|
||||
/**
|
||||
* @param static[]|Collection $elements
|
||||
* @param static[]|Collection $elements
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setChildren($elements): self
|
||||
{
|
||||
if (!is_array($elements) && !$elements instanceof Collection) {
|
||||
throw new InvalidArgumentException('$elements must be an array or Collection!');
|
||||
if (! is_array($elements) && ! $elements instanceof Collection) {
|
||||
throw new InvalidArgumentException('$elements must be an array or Collection!');
|
||||
}
|
||||
|
||||
$this->children = $elements;
|
||||
|
@ -331,7 +332,6 @@ abstract class AbstractStructuralDBElement extends AttachmentContainingDBElement
|
|||
}
|
||||
|
||||
/**
|
||||
* @param bool $not_selectable
|
||||
* @return AbstractStructuralDBElement
|
||||
*/
|
||||
public function setNotSelectable(bool $not_selectable): self
|
||||
|
|
|
@ -72,7 +72,6 @@ trait MasterAttachmentTrait
|
|||
/**
|
||||
* Sets the new master picture for this part.
|
||||
*
|
||||
* @param Attachment|null $new_master_attachment
|
||||
* @return $this
|
||||
*/
|
||||
public function setMasterPictureAttachment(?Attachment $new_master_attachment): self
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
|
@ -20,10 +23,9 @@
|
|||
|
||||
namespace App\Entity\Contracts;
|
||||
|
||||
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
|
||||
interface HasAttachmentsInterface
|
||||
{
|
||||
public function getAttachments(): Collection;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
|
@ -20,7 +23,6 @@
|
|||
|
||||
namespace App\Entity\Contracts;
|
||||
|
||||
|
||||
use App\Entity\Attachments\Attachment;
|
||||
|
||||
interface HasMasterAttachmentInterface
|
||||
|
@ -32,4 +34,4 @@ interface HasMasterAttachmentInterface
|
|||
* @return Attachment|null the master picture Attachment of this part (if there is one)
|
||||
*/
|
||||
public function getMasterPictureAttachment(): ?Attachment;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
|
@ -20,11 +23,11 @@
|
|||
|
||||
namespace App\Entity\Contracts;
|
||||
|
||||
|
||||
interface LogWithCommentInterface
|
||||
{
|
||||
/**
|
||||
* Checks if this log entry has a user provided comment.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function hasComment(): bool;
|
||||
|
@ -32,14 +35,15 @@ interface LogWithCommentInterface
|
|||
/**
|
||||
* Gets the user provided comment associated with this log entry.
|
||||
* Returns null if not comment was set.
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getComment(): ?string;
|
||||
|
||||
/**
|
||||
* Sets the user provided comment associated with this log entry.
|
||||
* @param string|null $new_comment
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setComment(?string $new_comment): self;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
|
@ -20,27 +23,27 @@
|
|||
|
||||
namespace App\Entity\Contracts;
|
||||
|
||||
|
||||
use App\Entity\LogSystem\AbstractLogEntry;
|
||||
|
||||
interface LogWithEventUndoInterface
|
||||
{
|
||||
/**
|
||||
* Checks if this element undoes another event.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isUndoEvent(): bool;
|
||||
|
||||
/**
|
||||
* Returns the ID of the undone event or null if no event is undone.
|
||||
*
|
||||
* @return int|null
|
||||
*/
|
||||
public function getUndoEventID(): ?int;
|
||||
|
||||
/**
|
||||
* Sets the event that is undone, and the undo mode.
|
||||
* @param AbstractLogEntry $event
|
||||
* @param string $mode
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setUndoneEvent(AbstractLogEntry $event, string $mode = 'undo'): self;
|
||||
|
@ -49,7 +52,8 @@ interface LogWithEventUndoInterface
|
|||
* Returns the mode how the event was undone:
|
||||
* "undo" = Only a single event was applied to element
|
||||
* "revert" = Element was reverted to the state it was to the timestamp of the log.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getUndoMode(): string;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
|
@ -20,7 +23,6 @@
|
|||
|
||||
namespace App\Entity\Contracts;
|
||||
|
||||
|
||||
interface NamedElementInterface
|
||||
{
|
||||
/**
|
||||
|
@ -29,4 +31,4 @@ interface NamedElementInterface
|
|||
* @return string the name of this element
|
||||
*/
|
||||
public function getName(): string;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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,7 +24,6 @@
|
|||
|
||||
namespace App\Entity\Contracts;
|
||||
|
||||
|
||||
use DateTime;
|
||||
|
||||
interface TimeStampableInterface
|
||||
|
@ -41,4 +43,4 @@ interface TimeStampableInterface
|
|||
* @return DateTime|null the creation time of the part
|
||||
*/
|
||||
public function getAddedDate(): ?DateTime;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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,11 +24,11 @@
|
|||
|
||||
namespace App\Entity\Contracts;
|
||||
|
||||
|
||||
interface TimeTravelInterface
|
||||
{
|
||||
/**
|
||||
* Checks if this entry has informations which data has changed.
|
||||
*
|
||||
* @return bool True if this entry has informations about the changed data.
|
||||
*/
|
||||
public function hasOldDataInformations(): bool;
|
||||
|
@ -35,7 +38,8 @@ interface TimeTravelInterface
|
|||
|
||||
/**
|
||||
* Returns the the timestamp associated with this change.
|
||||
*
|
||||
* @return \DateTime
|
||||
*/
|
||||
public function getTimestamp(): \DateTime;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -147,7 +147,7 @@ abstract class AbstractLogEntry extends AbstractDBElement
|
|||
self::TARGET_TYPE_ORDERDETAIL => Orderdetail::class,
|
||||
self::TARGET_TYPE_PRICEDETAIL => Pricedetail::class,
|
||||
self::TARGET_TYPE_MEASUREMENTUNIT => MeasurementUnit::class,
|
||||
self::TARGET_TYPE_PARAMETER => AbstractParameter::class
|
||||
self::TARGET_TYPE_PARAMETER => AbstractParameter::class,
|
||||
];
|
||||
|
||||
/** @var User The user which has caused this log entry
|
||||
|
@ -206,7 +206,6 @@ abstract class AbstractLogEntry extends AbstractDBElement
|
|||
/**
|
||||
* Sets the user that caused the event.
|
||||
*
|
||||
* @param User $user
|
||||
* @return $this
|
||||
*/
|
||||
public function setUser(User $user): self
|
||||
|
@ -229,7 +228,6 @@ abstract class AbstractLogEntry extends AbstractDBElement
|
|||
/**
|
||||
* Sets the timestamp when the event happened.
|
||||
*
|
||||
* @param DateTime $timestamp
|
||||
* @return $this
|
||||
*/
|
||||
public function setTimestamp(DateTime $timestamp): self
|
||||
|
@ -258,7 +256,6 @@ abstract class AbstractLogEntry extends AbstractDBElement
|
|||
/**
|
||||
* Sets the new level of this log entry.
|
||||
*
|
||||
* @param int $level
|
||||
* @return $this
|
||||
*/
|
||||
public function setLevel(int $level): self
|
||||
|
@ -284,7 +281,6 @@ abstract class AbstractLogEntry extends AbstractDBElement
|
|||
/**
|
||||
* Sets the priority level of this log entry as PSR3 compatible string.
|
||||
*
|
||||
* @param string $level
|
||||
* @return $this
|
||||
*/
|
||||
public function setLevelString(string $level): self
|
||||
|
@ -373,12 +369,13 @@ abstract class AbstractLogEntry extends AbstractDBElement
|
|||
|
||||
/**
|
||||
* Sets the target ID of the element associated with this element.
|
||||
* @param int $target_id
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setTargetElementID(int $target_id): self
|
||||
{
|
||||
$this->target_id = $target_id;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
|
@ -20,7 +23,6 @@
|
|||
|
||||
namespace App\Entity\LogSystem;
|
||||
|
||||
|
||||
use App\Entity\Base\AbstractDBElement;
|
||||
use App\Entity\Contracts\LogWithEventUndoInterface;
|
||||
use App\Entity\Contracts\NamedElementInterface;
|
||||
|
@ -52,6 +54,7 @@ class CollectionElementDeleted extends AbstractLogEntry implements LogWithEventU
|
|||
|
||||
/**
|
||||
* Get the name of the collection (on target element) that was changed.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getCollectionName(): string
|
||||
|
@ -62,6 +65,7 @@ class CollectionElementDeleted extends AbstractLogEntry implements LogWithEventU
|
|||
/**
|
||||
* Gets the name of the element that was deleted.
|
||||
* Return null, if the element did not have a name.
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getOldName(): ?string
|
||||
|
@ -71,6 +75,7 @@ class CollectionElementDeleted extends AbstractLogEntry implements LogWithEventU
|
|||
|
||||
/**
|
||||
* Returns the class of the deleted element.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getDeletedElementClass(): string
|
||||
|
@ -80,6 +85,7 @@ class CollectionElementDeleted extends AbstractLogEntry implements LogWithEventU
|
|||
|
||||
/**
|
||||
* Returns the ID of the deleted element.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getDeletedElementID(): int
|
||||
|
@ -87,32 +93,23 @@ class CollectionElementDeleted extends AbstractLogEntry implements LogWithEventU
|
|||
return $this->extra['i'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function isUndoEvent(): bool
|
||||
{
|
||||
return isset($this->extra['u']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getUndoEventID(): ?int
|
||||
{
|
||||
return $this->extra['u'] ?? null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function setUndoneEvent(AbstractLogEntry $event, string $mode = 'undo'): LogWithEventUndoInterface
|
||||
{
|
||||
$this->extra['u'] = $event->getID();
|
||||
|
||||
if ($mode === 'undo') {
|
||||
if ('undo' === $mode) {
|
||||
$this->extra['um'] = 1;
|
||||
} elseif ($mode === 'revert') {
|
||||
} elseif ('revert' === $mode) {
|
||||
$this->extra['um'] = 2;
|
||||
} else {
|
||||
throw new \InvalidArgumentException('Passed invalid $mode!');
|
||||
|
@ -121,16 +118,13 @@ class CollectionElementDeleted extends AbstractLogEntry implements LogWithEventU
|
|||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getUndoMode(): string
|
||||
{
|
||||
$mode_int = $this->extra['um'] ?? 1;
|
||||
if ($mode_int === 1) {
|
||||
if (1 === $mode_int) {
|
||||
return 'undo';
|
||||
} else {
|
||||
return 'revert';
|
||||
}
|
||||
|
||||
return 'revert';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -55,6 +55,7 @@ class ConfigChangedLogEntry extends AbstractLogEntry
|
|||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
throw new LogEntryObsoleteException();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -88,57 +88,40 @@ class ElementCreatedLogEntry extends AbstractLogEntry implements LogWithCommentI
|
|||
return null !== $this->getCreationInstockValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function hasComment(): bool
|
||||
{
|
||||
return isset($this->extra['m']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getComment(): ?string
|
||||
{
|
||||
return $this->extra['m'] ?? null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function setComment(?string $new_comment): LogWithCommentInterface
|
||||
{
|
||||
$this->extra['m'] = $new_comment;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function isUndoEvent(): bool
|
||||
{
|
||||
return isset($this->extra['u']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getUndoEventID(): ?int
|
||||
{
|
||||
return $this->extra['u'] ?? null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function setUndoneEvent(AbstractLogEntry $event, string $mode = 'undo'): LogWithEventUndoInterface
|
||||
{
|
||||
$this->extra['u'] = $event->getID();
|
||||
|
||||
if ($mode === 'undo') {
|
||||
if ('undo' === $mode) {
|
||||
$this->extra['um'] = 1;
|
||||
} elseif ($mode === 'revert') {
|
||||
} elseif ('revert' === $mode) {
|
||||
$this->extra['um'] = 2;
|
||||
} else {
|
||||
throw new \InvalidArgumentException('Passed invalid $mode!');
|
||||
|
@ -147,16 +130,13 @@ class ElementCreatedLogEntry extends AbstractLogEntry implements LogWithCommentI
|
|||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getUndoMode(): string
|
||||
{
|
||||
$mode_int = $this->extra['um'] ?? 1;
|
||||
if ($mode_int === 1) {
|
||||
if (1 === $mode_int) {
|
||||
return 'undo';
|
||||
} else {
|
||||
return 'revert';
|
||||
}
|
||||
|
||||
return 'revert';
|
||||
}
|
||||
}
|
||||
|
|
|
@ -71,7 +71,6 @@ class ElementDeletedLogEntry extends AbstractLogEntry implements TimeTravelInter
|
|||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
* @return $this
|
||||
*/
|
||||
public function setTargetElement(?AbstractDBElement $element): AbstractLogEntry
|
||||
|
@ -80,12 +79,14 @@ class ElementDeletedLogEntry extends AbstractLogEntry implements TimeTravelInter
|
|||
if ($element instanceof NamedElementInterface) {
|
||||
$this->setOldName($element->getName());
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setOldName(string $old_name): self
|
||||
{
|
||||
$this->extra['n'] = $old_name;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@ -96,82 +97,60 @@ class ElementDeletedLogEntry extends AbstractLogEntry implements TimeTravelInter
|
|||
|
||||
/**
|
||||
* Sets the old data for this entry.
|
||||
* @param array $old_data
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setOldData(array $old_data): self
|
||||
{
|
||||
$this->extra['o'] = $old_data;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function hasOldDataInformations(): bool
|
||||
{
|
||||
return !empty($this->extra['o']);
|
||||
return ! empty($this->extra['o']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getOldData(): array
|
||||
{
|
||||
return $this->extra['o'] ?? [];
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function hasComment(): bool
|
||||
{
|
||||
return isset($this->extra['m']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getComment(): ?string
|
||||
{
|
||||
return $this->extra['m'] ?? null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function setComment(?string $new_comment): LogWithCommentInterface
|
||||
{
|
||||
$this->extra['m'] = $new_comment;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function isUndoEvent(): bool
|
||||
{
|
||||
return isset($this->extra['u']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getUndoEventID(): ?int
|
||||
{
|
||||
return $this->extra['u'] ?? null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function setUndoneEvent(AbstractLogEntry $event, string $mode = 'undo'): LogWithEventUndoInterface
|
||||
{
|
||||
$this->extra['u'] = $event->getID();
|
||||
|
||||
if ($mode === 'undo') {
|
||||
if ('undo' === $mode) {
|
||||
$this->extra['um'] = 1;
|
||||
} elseif ($mode === 'revert') {
|
||||
} elseif ('revert' === $mode) {
|
||||
$this->extra['um'] = 2;
|
||||
} else {
|
||||
throw new \InvalidArgumentException('Passed invalid $mode!');
|
||||
|
@ -180,15 +159,13 @@ class ElementDeletedLogEntry extends AbstractLogEntry implements TimeTravelInter
|
|||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getUndoMode(): string
|
||||
{
|
||||
$mode_int = $this->extra['um'] ?? 1;
|
||||
if ($mode_int === 1) {
|
||||
if (1 === $mode_int) {
|
||||
return 'undo';
|
||||
}
|
||||
|
||||
return 'revert';
|
||||
}
|
||||
}
|
||||
|
|
|
@ -65,6 +65,7 @@ class ElementEditedLogEntry extends AbstractLogEntry implements TimeTravelInterf
|
|||
|
||||
/**
|
||||
* Checks if this log contains infos about which fields has changed.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function hasChangedFieldsInfo(): bool
|
||||
|
@ -74,6 +75,7 @@ class ElementEditedLogEntry extends AbstractLogEntry implements TimeTravelInterf
|
|||
|
||||
/**
|
||||
* Return the names of all fields that were changed during the change.
|
||||
*
|
||||
* @return string[]
|
||||
*/
|
||||
public function getChangedFields(): array
|
||||
|
@ -91,93 +93,74 @@ class ElementEditedLogEntry extends AbstractLogEntry implements TimeTravelInterf
|
|||
|
||||
/**
|
||||
* Set the fields that were changed during this element change.
|
||||
* @param string[] $changed_fields The names of the fields that were changed during the elements
|
||||
*
|
||||
* @param string[] $changed_fields The names of the fields that were changed during the elements
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setChangedFields(array $changed_fields): self
|
||||
{
|
||||
$this->extra['f'] = $changed_fields;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the old data for this entry.
|
||||
* @param array $old_data
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setOldData(array $old_data): self
|
||||
{
|
||||
$this->extra['d'] = $old_data;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function hasOldDataInformations(): bool
|
||||
{
|
||||
return !empty($this->extra['d']);
|
||||
return ! empty($this->extra['d']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getOldData(): array
|
||||
{
|
||||
return $this->extra['d'] ?? [];
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function hasComment(): bool
|
||||
{
|
||||
return isset($this->extra['m']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getComment(): ?string
|
||||
{
|
||||
return $this->extra['m'] ?? null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function setComment(?string $new_comment): LogWithCommentInterface
|
||||
{
|
||||
$this->extra['m'] = $new_comment;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function isUndoEvent(): bool
|
||||
{
|
||||
return isset($this->extra['u']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getUndoEventID(): ?int
|
||||
{
|
||||
return $this->extra['u'] ?? null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function setUndoneEvent(AbstractLogEntry $event, string $mode = 'undo'): LogWithEventUndoInterface
|
||||
{
|
||||
$this->extra['u'] = $event->getID();
|
||||
|
||||
if ($mode === 'undo') {
|
||||
if ('undo' === $mode) {
|
||||
$this->extra['um'] = 1;
|
||||
} elseif ($mode === 'revert') {
|
||||
} elseif ('revert' === $mode) {
|
||||
$this->extra['um'] = 2;
|
||||
} else {
|
||||
throw new \InvalidArgumentException('Passed invalid $mode!');
|
||||
|
@ -186,16 +169,13 @@ class ElementEditedLogEntry extends AbstractLogEntry implements TimeTravelInterf
|
|||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getUndoMode(): string
|
||||
{
|
||||
$mode_int = $this->extra['um'] ?? 1;
|
||||
if ($mode_int === 1) {
|
||||
if (1 === $mode_int) {
|
||||
return 'undo';
|
||||
} else {
|
||||
return 'revert';
|
||||
}
|
||||
|
||||
return 'revert';
|
||||
}
|
||||
}
|
||||
|
|
|
@ -55,6 +55,7 @@ class ExceptionLogEntry extends AbstractLogEntry
|
|||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
throw new LogEntryObsoleteException();
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
|
@ -22,7 +25,6 @@ namespace App\Entity\Parameters;
|
|||
|
||||
use App\Entity\Base\AbstractDBElement;
|
||||
use App\Entity\Base\AbstractNamedDBElement;
|
||||
use App\Repository\DBElementRepository;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use InvalidArgumentException;
|
||||
use LogicException;
|
||||
|
@ -59,7 +61,7 @@ abstract class AbstractParameter extends AbstractNamedDBElement
|
|||
* @Assert\Length(max=20)
|
||||
* @ORM\Column(type="string", nullable=false)
|
||||
*/
|
||||
protected $symbol = "";
|
||||
protected $symbol = '';
|
||||
|
||||
/**
|
||||
* @var float|null The guaranteed minimum value of this property.
|
||||
|
@ -90,22 +92,23 @@ abstract class AbstractParameter extends AbstractNamedDBElement
|
|||
* @Assert\Length(max=5)
|
||||
* @ORM\Column(type="string", nullable=false)
|
||||
*/
|
||||
protected $unit = "";
|
||||
protected $unit = '';
|
||||
|
||||
/**
|
||||
* @var string A text value for the given property.
|
||||
* @ORM\Column(type="string", nullable=false)
|
||||
*/
|
||||
protected $value_text = "";
|
||||
protected $value_text = '';
|
||||
|
||||
/**
|
||||
* @var string The group this parameter belongs to.
|
||||
* @ORM\Column(type="string", nullable=false, name="param_group")
|
||||
*/
|
||||
protected $group = "";
|
||||
protected $group = '';
|
||||
|
||||
/**
|
||||
* Mapping is done in sub classes
|
||||
* Mapping is done in sub classes.
|
||||
*
|
||||
* @var AbstractDBElement|null The element to which this parameter belongs to.
|
||||
*/
|
||||
protected $element;
|
||||
|
@ -119,6 +122,7 @@ abstract class AbstractParameter extends AbstractNamedDBElement
|
|||
|
||||
/**
|
||||
* Returns the name of the specification (e.g. "Collector-Base Voltage").
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getName(): string
|
||||
|
@ -128,6 +132,7 @@ abstract class AbstractParameter extends AbstractNamedDBElement
|
|||
|
||||
/**
|
||||
* Returns the element this parameter belongs to.
|
||||
*
|
||||
* @return AbstractDBElement|null
|
||||
*/
|
||||
public function getElement(): ?AbstractDBElement
|
||||
|
@ -137,13 +142,14 @@ abstract class AbstractParameter extends AbstractNamedDBElement
|
|||
|
||||
/**
|
||||
* Return a formatted string version of the values of the string.
|
||||
* Based on the set values it can return something like this: 34 V (12 V ... 50 V) [Text]
|
||||
* Based on the set values it can return something like this: 34 V (12 V ... 50 V) [Text].
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getFormattedValue(): string
|
||||
{
|
||||
//If we just only have text value, return early
|
||||
if ($this->value_typical === null && $this->value_min === null && $this->value_max === null) {
|
||||
if (null === $this->value_typical && null === $this->value_min && null === $this->value_max) {
|
||||
return $this->value_text;
|
||||
}
|
||||
|
||||
|
@ -158,11 +164,11 @@ abstract class AbstractParameter extends AbstractNamedDBElement
|
|||
}
|
||||
|
||||
if ($this->value_max && $this->value_min) {
|
||||
$str .= $this->getValueMinWithUnit() . ' ... ' . $this->getValueMaxWithUnit();
|
||||
$str .= $this->getValueMinWithUnit().' ... '.$this->getValueMaxWithUnit();
|
||||
} elseif ($this->value_max) {
|
||||
$str .= 'max. ' . $this->getValueMaxWithUnit();
|
||||
$str .= 'max. '.$this->getValueMaxWithUnit();
|
||||
} elseif ($this->value_min) {
|
||||
$str .= 'min. ' . $this->getValueMinWithUnit();
|
||||
$str .= 'min. '.$this->getValueMinWithUnit();
|
||||
}
|
||||
|
||||
//Add closing bracket
|
||||
|
@ -171,7 +177,7 @@ abstract class AbstractParameter extends AbstractNamedDBElement
|
|||
}
|
||||
|
||||
if ($this->value_text) {
|
||||
$str .= ' [' . $this->value_text . ']';
|
||||
$str .= ' ['.$this->value_text.']';
|
||||
}
|
||||
|
||||
return $str;
|
||||
|
@ -179,7 +185,7 @@ abstract class AbstractParameter extends AbstractNamedDBElement
|
|||
|
||||
/**
|
||||
* Sets the element to which this parameter belongs to.
|
||||
* @param AbstractDBElement $element
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setElement(AbstractDBElement $element): self
|
||||
|
@ -189,22 +195,25 @@ abstract class AbstractParameter extends AbstractNamedDBElement
|
|||
}
|
||||
|
||||
$this->element = $element;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the name of the specification. This value is required.
|
||||
* @param string $name
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setName(string $name): AbstractNamedDBElement
|
||||
{
|
||||
$this->name = $name;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the mathematical symbol for this specification (e.g. "V_CB")
|
||||
* Returns the mathematical symbol for this specification (e.g. "V_CB").
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getSymbol(): string
|
||||
|
@ -213,18 +222,20 @@ abstract class AbstractParameter extends AbstractNamedDBElement
|
|||
}
|
||||
|
||||
/**
|
||||
* Sets the mathematical symbol for this specification (e.g. "V_CB")
|
||||
* @param string $symbol
|
||||
* Sets the mathematical symbol for this specification (e.g. "V_CB").
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setSymbol(string $symbol): self
|
||||
{
|
||||
$this->symbol = $symbol;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns The guaranteed minimum value of this property.
|
||||
*
|
||||
* @return float|null
|
||||
*/
|
||||
public function getValueMin(): ?float
|
||||
|
@ -234,17 +245,19 @@ abstract class AbstractParameter extends AbstractNamedDBElement
|
|||
|
||||
/**
|
||||
* Sets the minimum value of this property.
|
||||
* @param float|null $value_min
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setValueMin(?float $value_min): self
|
||||
{
|
||||
$this->value_min = $value_min;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the typical value of this property.
|
||||
*
|
||||
* @return float|null
|
||||
*/
|
||||
public function getValueTypical(): ?float
|
||||
|
@ -253,22 +266,8 @@ abstract class AbstractParameter extends AbstractNamedDBElement
|
|||
}
|
||||
|
||||
/**
|
||||
* Return a string representation and (if possible) with its unit.
|
||||
* @param float $value
|
||||
* @param string $format
|
||||
* @return string
|
||||
*/
|
||||
protected function formatWithUnit(float $value, string $format = "%g"): string
|
||||
{
|
||||
$str = \sprintf($format, $value);
|
||||
if (!empty($this->unit)) {
|
||||
return $str . ' ' . $this->unit;
|
||||
}
|
||||
return $str;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a formatted version with the minimum value with the unit of this parameter
|
||||
* Return a formatted version with the minimum value with the unit of this parameter.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getValueTypicalWithUnit(): string
|
||||
|
@ -277,7 +276,8 @@ abstract class AbstractParameter extends AbstractNamedDBElement
|
|||
}
|
||||
|
||||
/**
|
||||
* Return a formatted version with the maximum value with the unit of this parameter
|
||||
* Return a formatted version with the maximum value with the unit of this parameter.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getValueMaxWithUnit(): string
|
||||
|
@ -286,7 +286,8 @@ abstract class AbstractParameter extends AbstractNamedDBElement
|
|||
}
|
||||
|
||||
/**
|
||||
* Return a formatted version with the typical value with the unit of this parameter
|
||||
* Return a formatted version with the typical value with the unit of this parameter.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getValueMinWithUnit(): string
|
||||
|
@ -295,18 +296,22 @@ abstract class AbstractParameter extends AbstractNamedDBElement
|
|||
}
|
||||
|
||||
/**
|
||||
* Sets the typical value of this property
|
||||
* @param float $value_typical
|
||||
* Sets the typical value of this property.
|
||||
*
|
||||
* @param float $value_typical
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setValueTypical(?float $value_typical): self
|
||||
{
|
||||
$this->value_typical = $value_typical;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the guaranteed maximum value
|
||||
* Returns the guaranteed maximum value.
|
||||
*
|
||||
* @return float|null
|
||||
*/
|
||||
public function getValueMax(): ?float
|
||||
|
@ -315,18 +320,20 @@ abstract class AbstractParameter extends AbstractNamedDBElement
|
|||
}
|
||||
|
||||
/**
|
||||
* Sets the guaranteed maximum value
|
||||
* @param float|null $value_max
|
||||
* Sets the guaranteed maximum value.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setValueMax(?float $value_max): self
|
||||
{
|
||||
$this->value_max = $value_max;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the unit used by the value (e.g. "V")
|
||||
* Returns the unit used by the value (e.g. "V").
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getUnit(): string
|
||||
|
@ -336,17 +343,19 @@ abstract class AbstractParameter extends AbstractNamedDBElement
|
|||
|
||||
/**
|
||||
* Sets the unit used by the value.
|
||||
* @param string $unit
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setUnit(string $unit): self
|
||||
{
|
||||
$this->unit = $unit;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the text value.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getValueText(): string
|
||||
|
@ -356,12 +365,13 @@ abstract class AbstractParameter extends AbstractNamedDBElement
|
|||
|
||||
/**
|
||||
* Sets the text value.
|
||||
* @param string $value_text
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setValueText(string $value_text): self
|
||||
{
|
||||
$this->value_text = $value_text;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@ -369,4 +379,19 @@ abstract class AbstractParameter extends AbstractNamedDBElement
|
|||
{
|
||||
return 'PM'.sprintf('%09d', $this->getID());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a string representation and (if possible) with its unit.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function formatWithUnit(float $value, string $format = '%g'): string
|
||||
{
|
||||
$str = \sprintf($format, $value);
|
||||
if (! empty($this->unit)) {
|
||||
return $str.' '.$this->unit;
|
||||
}
|
||||
|
||||
return $str;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
|
@ -20,13 +23,11 @@
|
|||
|
||||
namespace App\Entity\Parameters;
|
||||
|
||||
|
||||
use App\Entity\Attachments\AttachmentType;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
/**
|
||||
* @ORM\Entity()
|
||||
* @package App\Entity\Parameters
|
||||
*/
|
||||
class AttachmentTypeParameter extends AbstractParameter
|
||||
{
|
||||
|
@ -37,4 +38,4 @@ class AttachmentTypeParameter extends AbstractParameter
|
|||
* @ORM\JoinColumn(name="element_id", referencedColumnName="id", nullable=false, onDelete="CASCADE").
|
||||
*/
|
||||
protected $element;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
|
@ -20,13 +23,11 @@
|
|||
|
||||
namespace App\Entity\Parameters;
|
||||
|
||||
|
||||
use App\Entity\Parts\Category;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
/**
|
||||
* @ORM\Entity()
|
||||
* @package App\Entity\Parameters
|
||||
*/
|
||||
class CategoryParameter extends AbstractParameter
|
||||
{
|
||||
|
@ -37,4 +38,4 @@ class CategoryParameter extends AbstractParameter
|
|||
* @ORM\JoinColumn(name="element_id", referencedColumnName="id", nullable=false, onDelete="CASCADE").
|
||||
*/
|
||||
protected $element;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
|
@ -38,4 +41,4 @@ class CurrencyParameter extends AbstractParameter
|
|||
* @ORM\JoinColumn(name="element_id", referencedColumnName="id", nullable=false, onDelete="CASCADE").
|
||||
*/
|
||||
protected $element;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
|
@ -20,13 +23,11 @@
|
|||
|
||||
namespace App\Entity\Parameters;
|
||||
|
||||
|
||||
use App\Entity\Devices\Device;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
/**
|
||||
* @ORM\Entity()
|
||||
* @package App\Entity\Parameters
|
||||
*/
|
||||
class DeviceParameter extends AbstractParameter
|
||||
{
|
||||
|
@ -38,4 +39,4 @@ class DeviceParameter extends AbstractParameter
|
|||
* @ORM\JoinColumn(name="element_id", referencedColumnName="id", nullable=false, onDelete="CASCADE").
|
||||
*/
|
||||
protected $element;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
|
@ -25,7 +28,6 @@ use Doctrine\ORM\Mapping as ORM;
|
|||
|
||||
/**
|
||||
* @ORM\Entity()
|
||||
* @package App\Entity\Parameters
|
||||
*/
|
||||
class FootprintParameter extends AbstractParameter
|
||||
{
|
||||
|
@ -37,4 +39,4 @@ class FootprintParameter extends AbstractParameter
|
|||
* @ORM\JoinColumn(name="element_id", referencedColumnName="id", nullable=false, onDelete="CASCADE").
|
||||
*/
|
||||
protected $element;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
|
@ -25,7 +28,6 @@ use Doctrine\ORM\Mapping as ORM;
|
|||
|
||||
/**
|
||||
* @ORM\Entity()
|
||||
* @package App\Entity\Parameters
|
||||
*/
|
||||
class GroupParameter extends AbstractParameter
|
||||
{
|
||||
|
@ -37,4 +39,4 @@ class GroupParameter extends AbstractParameter
|
|||
* @ORM\JoinColumn(name="element_id", referencedColumnName="id", nullable=false, onDelete="CASCADE").
|
||||
*/
|
||||
protected $element;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
|
@ -25,7 +28,6 @@ use Doctrine\ORM\Mapping as ORM;
|
|||
|
||||
/**
|
||||
* @ORM\Entity()
|
||||
* @package App\Entity\Parameters
|
||||
*/
|
||||
class ManufacturerParameter extends AbstractParameter
|
||||
{
|
||||
|
@ -37,4 +39,4 @@ class ManufacturerParameter extends AbstractParameter
|
|||
* @ORM\JoinColumn(name="element_id", referencedColumnName="id", nullable=false, onDelete="CASCADE").
|
||||
*/
|
||||
protected $element;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
|
@ -25,7 +28,6 @@ use Doctrine\ORM\Mapping as ORM;
|
|||
|
||||
/**
|
||||
* @ORM\Entity()
|
||||
* @package App\Entity\Parameters
|
||||
*/
|
||||
class MeasurementUnitParameter extends AbstractParameter
|
||||
{
|
||||
|
@ -37,4 +39,4 @@ class MeasurementUnitParameter extends AbstractParameter
|
|||
* @ORM\JoinColumn(name="element_id", referencedColumnName="id", nullable=false, onDelete="CASCADE").
|
||||
*/
|
||||
protected $element;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
|
@ -20,22 +23,22 @@
|
|||
|
||||
namespace App\Entity\Parameters;
|
||||
|
||||
|
||||
use App\Entity\Parameters\AbstractParameter;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Symfony\Component\Validator\Constraints as Assert;
|
||||
|
||||
trait ParametersTrait
|
||||
{
|
||||
/**
|
||||
* Mapping done in subclasses
|
||||
* Mapping done in subclasses.
|
||||
*
|
||||
* @var AbstractParameter[]|Collection
|
||||
* @Assert\Valid()
|
||||
*/
|
||||
protected $parameters;
|
||||
|
||||
/**
|
||||
* Return all associated specifications
|
||||
* Return all associated specifications.
|
||||
*
|
||||
* @return AbstractParameter[]|Collection
|
||||
*/
|
||||
public function getParameters(): Collection
|
||||
|
@ -45,19 +48,21 @@ trait ParametersTrait
|
|||
|
||||
/**
|
||||
* Add a new parameter information.
|
||||
* @param AbstractParameter $parameter
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function addParameter(AbstractParameter $parameter): self
|
||||
{
|
||||
$parameter->setElement($this);
|
||||
$this->parameters->add($parameter);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function removeParameter(AbstractParameter $parameter): self
|
||||
{
|
||||
$this->parameters->removeElement($parameter);
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
|
@ -25,7 +28,6 @@ use Doctrine\ORM\Mapping as ORM;
|
|||
|
||||
/**
|
||||
* @ORM\Entity()
|
||||
* @package App\Entity\Parameters
|
||||
*/
|
||||
class PartParameter extends AbstractParameter
|
||||
{
|
||||
|
@ -37,4 +39,4 @@ class PartParameter extends AbstractParameter
|
|||
* @ORM\JoinColumn(name="element_id", referencedColumnName="id", nullable=false, onDelete="CASCADE").
|
||||
*/
|
||||
protected $element;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
|
@ -25,7 +28,6 @@ use Doctrine\ORM\Mapping as ORM;
|
|||
|
||||
/**
|
||||
* @ORM\Entity()
|
||||
* @package App\Entity\Parameters
|
||||
*/
|
||||
class StorelocationParameter extends AbstractParameter
|
||||
{
|
||||
|
@ -37,4 +39,4 @@ class StorelocationParameter extends AbstractParameter
|
|||
* @ORM\JoinColumn(name="element_id", referencedColumnName="id", nullable=false, onDelete="CASCADE").
|
||||
*/
|
||||
protected $element;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
|
@ -25,7 +28,6 @@ use Doctrine\ORM\Mapping as ORM;
|
|||
|
||||
/**
|
||||
* @ORM\Entity()
|
||||
* @package App\Entity\Parameters
|
||||
*/
|
||||
class SupplierParameter extends AbstractParameter
|
||||
{
|
||||
|
@ -37,4 +39,4 @@ class SupplierParameter extends AbstractParameter
|
|||
* @ORM\JoinColumn(name="element_id", referencedColumnName="id", nullable=false, onDelete="CASCADE").
|
||||
*/
|
||||
protected $element;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,7 +25,6 @@ namespace App\Entity\Parts;
|
|||
use App\Entity\Attachments\CategoryAttachment;
|
||||
use App\Entity\Base\AbstractPartsContainingDBElement;
|
||||
use App\Entity\Parameters\CategoryParameter;
|
||||
use App\Entity\Parameters\DeviceParameter;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Component\Validator\Constraints as Assert;
|
||||
|
@ -131,7 +130,6 @@ class Category extends AbstractPartsContainingDBElement
|
|||
}
|
||||
|
||||
/**
|
||||
* @param string $partname_hint
|
||||
* @return Category
|
||||
*/
|
||||
public function setPartnameHint(string $partname_hint): self
|
||||
|
@ -147,7 +145,6 @@ class Category extends AbstractPartsContainingDBElement
|
|||
}
|
||||
|
||||
/**
|
||||
* @param string $partname_regex
|
||||
* @return Category
|
||||
*/
|
||||
public function setPartnameRegex(string $partname_regex): self
|
||||
|
@ -163,7 +160,6 @@ class Category extends AbstractPartsContainingDBElement
|
|||
}
|
||||
|
||||
/**
|
||||
* @param bool $disable_footprints
|
||||
* @return Category
|
||||
*/
|
||||
public function setDisableFootprints(bool $disable_footprints): self
|
||||
|
@ -179,7 +175,6 @@ class Category extends AbstractPartsContainingDBElement
|
|||
}
|
||||
|
||||
/**
|
||||
* @param bool $disable_manufacturers
|
||||
* @return Category
|
||||
*/
|
||||
public function setDisableManufacturers(bool $disable_manufacturers): self
|
||||
|
@ -195,7 +190,6 @@ class Category extends AbstractPartsContainingDBElement
|
|||
}
|
||||
|
||||
/**
|
||||
* @param bool $disable_autodatasheets
|
||||
* @return Category
|
||||
*/
|
||||
public function setDisableAutodatasheets(bool $disable_autodatasheets): self
|
||||
|
@ -211,7 +205,6 @@ class Category extends AbstractPartsContainingDBElement
|
|||
}
|
||||
|
||||
/**
|
||||
* @param bool $disable_properties
|
||||
* @return Category
|
||||
*/
|
||||
public function setDisableProperties(bool $disable_properties): self
|
||||
|
@ -227,7 +220,6 @@ class Category extends AbstractPartsContainingDBElement
|
|||
}
|
||||
|
||||
/**
|
||||
* @param string $default_description
|
||||
* @return Category
|
||||
*/
|
||||
public function setDefaultDescription(string $default_description): self
|
||||
|
@ -243,7 +235,6 @@ class Category extends AbstractPartsContainingDBElement
|
|||
}
|
||||
|
||||
/**
|
||||
* @param string $default_comment
|
||||
* @return Category
|
||||
*/
|
||||
public function setDefaultComment(string $default_comment): self
|
||||
|
|
|
@ -52,7 +52,6 @@ namespace App\Entity\Parts;
|
|||
|
||||
use App\Entity\Attachments\FootprintAttachment;
|
||||
use App\Entity\Base\AbstractPartsContainingDBElement;
|
||||
use App\Entity\Parameters\DeviceParameter;
|
||||
use App\Entity\Parameters\FootprintParameter;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
|
|
@ -52,7 +52,6 @@ namespace App\Entity\Parts;
|
|||
|
||||
use App\Entity\Attachments\ManufacturerAttachment;
|
||||
use App\Entity\Base\AbstractCompany;
|
||||
use App\Entity\Parameters\DeviceParameter;
|
||||
use App\Entity\Parameters\ManufacturerParameter;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
|
|
@ -44,7 +44,6 @@ namespace App\Entity\Parts;
|
|||
|
||||
use App\Entity\Attachments\MeasurementUnitAttachment;
|
||||
use App\Entity\Base\AbstractPartsContainingDBElement;
|
||||
use App\Entity\Parameters\DeviceParameter;
|
||||
use App\Entity\Parameters\MeasurementUnitParameter;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
@ -148,7 +147,6 @@ class MeasurementUnit extends AbstractPartsContainingDBElement
|
|||
}
|
||||
|
||||
/**
|
||||
* @param bool $isInteger
|
||||
* @return MeasurementUnit
|
||||
*/
|
||||
public function setIsInteger(bool $isInteger): self
|
||||
|
@ -164,7 +162,6 @@ class MeasurementUnit extends AbstractPartsContainingDBElement
|
|||
}
|
||||
|
||||
/**
|
||||
* @param bool $usesSIPrefixes
|
||||
* @return MeasurementUnit
|
||||
*/
|
||||
public function setUseSIPrefix(bool $usesSIPrefixes): self
|
||||
|
|
|
@ -52,9 +52,8 @@ namespace App\Entity\Parts;
|
|||
|
||||
use App\Entity\Attachments\Attachment;
|
||||
use App\Entity\Attachments\AttachmentContainingDBElement;
|
||||
use App\Entity\Parameters\ParametersTrait;
|
||||
use App\Entity\Devices\Device;
|
||||
use App\Entity\Parameters\DeviceParameter;
|
||||
use App\Entity\Parameters\ParametersTrait;
|
||||
use App\Entity\Parameters\PartParameter;
|
||||
use App\Entity\Parts\PartTraits\AdvancedPropertyTrait;
|
||||
use App\Entity\Parts\PartTraits\BasicPropertyTrait;
|
||||
|
@ -145,6 +144,26 @@ class Part extends AttachmentContainingDBElement
|
|||
$this->parameters = new ArrayCollection();
|
||||
}
|
||||
|
||||
public function __clone()
|
||||
{
|
||||
if ($this->id) {
|
||||
//Deep clone part lots
|
||||
$lots = $this->partLots;
|
||||
$this->partLots = new ArrayCollection();
|
||||
foreach ($lots as $lot) {
|
||||
$this->addPartLot(clone $lot);
|
||||
}
|
||||
|
||||
//Deep clone order details
|
||||
$orderdetails = $this->orderdetails;
|
||||
$this->orderdetails = new ArrayCollection();
|
||||
foreach ($orderdetails as $orderdetail) {
|
||||
$this->addOrderdetail(clone $orderdetail);
|
||||
}
|
||||
}
|
||||
parent::__clone();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the ID as an string, defined by the element class.
|
||||
* This should have a form like P000014, for a part with ID 14.
|
||||
|
@ -167,24 +186,4 @@ class Part extends AttachmentContainingDBElement
|
|||
{
|
||||
return $this->devices;
|
||||
}
|
||||
|
||||
public function __clone()
|
||||
{
|
||||
if ($this->id) {
|
||||
//Deep clone part lots
|
||||
$lots = $this->partLots;
|
||||
$this->partLots = new ArrayCollection();
|
||||
foreach ($lots as $lot) {
|
||||
$this->addPartLot(clone $lot);
|
||||
}
|
||||
|
||||
//Deep clone order details
|
||||
$orderdetails = $this->orderdetails;
|
||||
$this->orderdetails = new ArrayCollection();
|
||||
foreach ($orderdetails as $orderdetail) {
|
||||
$this->addOrderdetail(clone $orderdetail);
|
||||
}
|
||||
}
|
||||
parent::__clone();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -119,6 +119,14 @@ class PartLot extends AbstractDBElement implements TimeStampableInterface
|
|||
*/
|
||||
protected $part;
|
||||
|
||||
public function __clone()
|
||||
{
|
||||
if ($this->id) {
|
||||
$this->addedDate = null;
|
||||
}
|
||||
parent::__clone();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the ID as an string, defined by the element class.
|
||||
* This should have a form like P000014, for a part with ID 14.
|
||||
|
@ -161,7 +169,6 @@ class PartLot extends AbstractDBElement implements TimeStampableInterface
|
|||
/**
|
||||
* Sets the description of the part lot.
|
||||
*
|
||||
* @param string $description
|
||||
* @return PartLot
|
||||
*/
|
||||
public function setDescription(string $description): self
|
||||
|
@ -184,7 +191,6 @@ class PartLot extends AbstractDBElement implements TimeStampableInterface
|
|||
/**
|
||||
* Sets the comment for this part lot.
|
||||
*
|
||||
* @param string $comment
|
||||
* @return PartLot
|
||||
*/
|
||||
public function setComment(string $comment): self
|
||||
|
@ -231,7 +237,6 @@ class PartLot extends AbstractDBElement implements TimeStampableInterface
|
|||
/**
|
||||
* Sets the storage location, where this part lot is stored.
|
||||
*
|
||||
* @param Storelocation|null $storage_location
|
||||
* @return PartLot
|
||||
*/
|
||||
public function setStorageLocation(?Storelocation $storage_location): self
|
||||
|
@ -254,8 +259,6 @@ class PartLot extends AbstractDBElement implements TimeStampableInterface
|
|||
/**
|
||||
* Sets the part that is stored in this part lot.
|
||||
*
|
||||
* @param Part $part
|
||||
*
|
||||
* @return PartLot
|
||||
*/
|
||||
public function setPart(Part $part): self
|
||||
|
@ -278,7 +281,6 @@ class PartLot extends AbstractDBElement implements TimeStampableInterface
|
|||
/**
|
||||
* Set the unknown instock status of this part lot.
|
||||
*
|
||||
* @param bool $instock_unknown
|
||||
* @return PartLot
|
||||
*/
|
||||
public function setInstockUnknown(bool $instock_unknown): self
|
||||
|
@ -316,7 +318,6 @@ class PartLot extends AbstractDBElement implements TimeStampableInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* @param bool $needs_refill
|
||||
* @return PartLot
|
||||
*/
|
||||
public function setNeedsRefill(bool $needs_refill): self
|
||||
|
@ -325,12 +326,4 @@ class PartLot extends AbstractDBElement implements TimeStampableInterface
|
|||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function __clone()
|
||||
{
|
||||
if($this->id) {
|
||||
$this->addedDate = null;
|
||||
}
|
||||
parent::__clone();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -106,6 +106,7 @@ trait AdvancedPropertyTrait
|
|||
* Sets a comma separated list of tags, that are assigned to this part.
|
||||
*
|
||||
* @param string $tags The new tags
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setTags(string $tags): self
|
||||
|
@ -129,6 +130,7 @@ trait AdvancedPropertyTrait
|
|||
* Sett to null, if the mass is unknown.
|
||||
*
|
||||
* @param float|null $mass the new mass
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setMass(?float $mass): self
|
||||
|
|
|
@ -164,6 +164,7 @@ trait BasicPropertyTrait
|
|||
* Sets the description of this part.
|
||||
*
|
||||
* @param string $new_description the new description
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setDescription(?string $new_description): self
|
||||
|
@ -177,6 +178,7 @@ trait BasicPropertyTrait
|
|||
* Sets the comment property of this part.
|
||||
*
|
||||
* @param string $new_comment the new comment
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setComment(string $new_comment): self
|
||||
|
@ -191,6 +193,7 @@ trait BasicPropertyTrait
|
|||
* The category property is required for every part, so you can not pass null like the other properties (footprints).
|
||||
*
|
||||
* @param Category $category The new category of this part
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setCategory(Category $category): self
|
||||
|
@ -205,6 +208,7 @@ trait BasicPropertyTrait
|
|||
*
|
||||
* @param Footprint|null $new_footprint The new footprint of this part. Set to null, if this part should not have
|
||||
* a footprint.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setFootprint(?Footprint $new_footprint): self
|
||||
|
@ -219,6 +223,7 @@ trait BasicPropertyTrait
|
|||
*
|
||||
* @param bool $new_favorite_status The new favorite status, that should be applied on this part.
|
||||
* Set this to true, when the part should be a favorite.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setFavorite(bool $new_favorite_status): self
|
||||
|
|
|
@ -90,7 +90,7 @@ trait InstockTrait
|
|||
/**
|
||||
* Adds the given part lot, to the list of part lots.
|
||||
* The part lot is assigned to this part.
|
||||
* @param PartLot $lot
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function addPartLot(PartLot $lot): self
|
||||
|
@ -105,6 +105,7 @@ trait InstockTrait
|
|||
* Removes the given part lot from the list of part lots.
|
||||
*
|
||||
* @param PartLot $lot the part lot that should be deleted
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function removePartLot(PartLot $lot): self
|
||||
|
@ -126,7 +127,7 @@ trait InstockTrait
|
|||
/**
|
||||
* Sets the measurement unit in which the part's amount should be measured.
|
||||
* Set to null, if the part should be measured in quantities.
|
||||
* @param MeasurementUnit|null $partUnit
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setPartUnit(?MeasurementUnit $partUnit): self
|
||||
|
@ -172,7 +173,6 @@ trait InstockTrait
|
|||
* Part Lots that have unknown value or are expired, are not used for this value.
|
||||
*
|
||||
* @return float The amount of parts given in partUnit
|
||||
*
|
||||
*/
|
||||
public function getAmountSum(): float
|
||||
{
|
||||
|
@ -199,6 +199,7 @@ trait InstockTrait
|
|||
* See getPartUnit() for the associated unit.
|
||||
*
|
||||
* @param float $new_minamount the new count of parts which should be in stock at least
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setMinAmount(float $new_minamount): self
|
||||
|
|
|
@ -136,7 +136,6 @@ trait ManufacturerTrait
|
|||
* Sets the manufacturing status for this part
|
||||
* See getManufacturingStatus() for valid values.
|
||||
*
|
||||
* @param string $manufacturing_status
|
||||
* @return Part
|
||||
*/
|
||||
public function setManufacturingStatus(string $manufacturing_status): self
|
||||
|
@ -167,7 +166,6 @@ trait ManufacturerTrait
|
|||
/**
|
||||
* Sets the manufacturer product number (MPN) for this part.
|
||||
*
|
||||
* @param string $manufacturer_product_number
|
||||
* @return Part
|
||||
*/
|
||||
public function setManufacturerProductNumber(string $manufacturer_product_number): self
|
||||
|
@ -182,6 +180,7 @@ trait ManufacturerTrait
|
|||
* Set to "" if this part should use the automatically URL based on its manufacturer.
|
||||
*
|
||||
* @param string $new_url The new url
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setManufacturerProductURL(string $new_url): self
|
||||
|
@ -196,6 +195,7 @@ trait ManufacturerTrait
|
|||
*
|
||||
* @param Manufacturer|null $new_manufacturer The new Manufacturer of this part. Set to null, if this part should
|
||||
* not have a manufacturer.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setManufacturer(?Manufacturer $new_manufacturer): self
|
||||
|
|
|
@ -144,6 +144,7 @@ trait OrderTrait
|
|||
* The orderdetail is assigned to this part.
|
||||
*
|
||||
* @param Orderdetail $orderdetail the orderdetail that should be added
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function addOrderdetail(Orderdetail $orderdetail): self
|
||||
|
@ -156,7 +157,7 @@ trait OrderTrait
|
|||
|
||||
/**
|
||||
* Removes the given orderdetail from the list of orderdetails.
|
||||
* @param Orderdetail $orderdetail
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function removeOrderdetail(Orderdetail $orderdetail): self
|
||||
|
@ -177,6 +178,7 @@ trait OrderTrait
|
|||
* (if the part has exactly one orderdetails,
|
||||
* set this orderdetails as order orderdetails.
|
||||
* Otherwise, set "no order orderdetails")
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setManualOrder(bool $new_manual_order, int $new_order_quantity = 1, ?Orderdetail $new_order_orderdetail = null): self
|
||||
|
|
|
@ -52,7 +52,6 @@ namespace App\Entity\Parts;
|
|||
|
||||
use App\Entity\Attachments\StorelocationAttachment;
|
||||
use App\Entity\Base\AbstractPartsContainingDBElement;
|
||||
use App\Entity\Parameters\DeviceParameter;
|
||||
use App\Entity\Parameters\StorelocationParameter;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
@ -153,7 +152,6 @@ class Storelocation extends AbstractPartsContainingDBElement
|
|||
}
|
||||
|
||||
/**
|
||||
* @param bool $only_single_part
|
||||
* @return Storelocation
|
||||
*/
|
||||
public function setOnlySinglePart(bool $only_single_part): self
|
||||
|
@ -174,7 +172,6 @@ class Storelocation extends AbstractPartsContainingDBElement
|
|||
}
|
||||
|
||||
/**
|
||||
* @param bool $limit_to_existing_parts
|
||||
* @return Storelocation
|
||||
*/
|
||||
public function setLimitToExistingParts(bool $limit_to_existing_parts): self
|
||||
|
@ -193,7 +190,6 @@ class Storelocation extends AbstractPartsContainingDBElement
|
|||
}
|
||||
|
||||
/**
|
||||
* @param MeasurementUnit|null $storage_type
|
||||
* @return Storelocation
|
||||
*/
|
||||
public function setStorageType(?MeasurementUnit $storage_type): self
|
||||
|
|
|
@ -52,7 +52,6 @@ namespace App\Entity\Parts;
|
|||
|
||||
use App\Entity\Attachments\SupplierAttachment;
|
||||
use App\Entity\Base\AbstractCompany;
|
||||
use App\Entity\Parameters\DeviceParameter;
|
||||
use App\Entity\Parameters\SupplierParameter;
|
||||
use App\Entity\PriceInformations\Currency;
|
||||
use App\Validator\Constraints\Selectable;
|
||||
|
@ -134,7 +133,6 @@ class Supplier extends AbstractCompany
|
|||
/**
|
||||
* Sets the default currency.
|
||||
*
|
||||
* @param Currency|null $default_currency
|
||||
* @return Supplier
|
||||
*/
|
||||
public function setDefaultCurrency(?Currency $default_currency): self
|
||||
|
|
|
@ -45,7 +45,6 @@ namespace App\Entity\PriceInformations;
|
|||
use App\Entity\Attachments\CurrencyAttachment;
|
||||
use App\Entity\Base\AbstractStructuralDBElement;
|
||||
use App\Entity\Parameters\CurrencyParameter;
|
||||
use App\Entity\Parameters\SupplierParameter;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
|
||||
|
|
|
@ -117,6 +117,20 @@ class Orderdetail extends AbstractDBElement implements TimeStampableInterface
|
|||
$this->pricedetails = new ArrayCollection();
|
||||
}
|
||||
|
||||
public function __clone()
|
||||
{
|
||||
if ($this->id) {
|
||||
$this->addedDate = null;
|
||||
$pricedetails = $this->pricedetails;
|
||||
$this->pricedetails = new ArrayCollection();
|
||||
//Set master attachment is needed
|
||||
foreach ($pricedetails as $pricedetail) {
|
||||
$this->addPricedetail(clone $pricedetail);
|
||||
}
|
||||
}
|
||||
parent::__clone();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the ID as an string, defined by the element class.
|
||||
* This should have a form like P000014, for a part with ID 14.
|
||||
|
@ -228,7 +242,6 @@ class Orderdetail extends AbstractDBElement implements TimeStampableInterface
|
|||
/**
|
||||
* Removes an pricedetail from this orderdetail.
|
||||
*
|
||||
* @param Pricedetail $pricedetail
|
||||
* @return Orderdetail
|
||||
*/
|
||||
public function removePricedetail(Pricedetail $pricedetail): self
|
||||
|
@ -276,7 +289,6 @@ class Orderdetail extends AbstractDBElement implements TimeStampableInterface
|
|||
/**
|
||||
* Sets a new part with which this orderdetail is associated.
|
||||
*
|
||||
* @param Part $part
|
||||
* @return Orderdetail
|
||||
*/
|
||||
public function setPart(Part $part): self
|
||||
|
@ -289,7 +301,6 @@ class Orderdetail extends AbstractDBElement implements TimeStampableInterface
|
|||
/**
|
||||
* Sets the new supplier associated with this orderdetail.
|
||||
*
|
||||
* @param Supplier $new_supplier
|
||||
* @return Orderdetail
|
||||
*/
|
||||
public function setSupplier(Supplier $new_supplier): self
|
||||
|
@ -348,18 +359,4 @@ class Orderdetail extends AbstractDBElement implements TimeStampableInterface
|
|||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function __clone()
|
||||
{
|
||||
if ($this->id) {
|
||||
$this->addedDate = null;
|
||||
$pricedetails = $this->pricedetails;
|
||||
$this->pricedetails = new ArrayCollection();
|
||||
//Set master attachment is needed
|
||||
foreach ($pricedetails as $pricedetail) {
|
||||
$this->addPricedetail(clone $pricedetail);
|
||||
}
|
||||
}
|
||||
parent::__clone();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -121,6 +121,14 @@ class Pricedetail extends AbstractDBElement implements TimeStampableInterface
|
|||
bcscale(static::PRICE_PRECISION);
|
||||
}
|
||||
|
||||
public function __clone()
|
||||
{
|
||||
if ($this->id) {
|
||||
$this->addedDate = null;
|
||||
}
|
||||
parent::__clone();
|
||||
}
|
||||
|
||||
/********************************************************************************
|
||||
*
|
||||
* Getters
|
||||
|
@ -230,7 +238,6 @@ class Pricedetail extends AbstractDBElement implements TimeStampableInterface
|
|||
/**
|
||||
* Sets the orderdetail to which this pricedetail belongs to.
|
||||
*
|
||||
* @param Orderdetail $orderdetail
|
||||
* @return $this
|
||||
*/
|
||||
public function setOrderdetail(Orderdetail $orderdetail): self
|
||||
|
@ -244,7 +251,6 @@ class Pricedetail extends AbstractDBElement implements TimeStampableInterface
|
|||
* Sets the currency associated with the price informations.
|
||||
* Set to null, to use the global base currency.
|
||||
*
|
||||
* @param Currency|null $currency
|
||||
* @return Pricedetail
|
||||
*/
|
||||
public function setCurrency(?Currency $currency): self
|
||||
|
@ -262,6 +268,7 @@ class Pricedetail extends AbstractDBElement implements TimeStampableInterface
|
|||
* * This is the price for "price_related_quantity" parts!!
|
||||
* * Example: if "price_related_quantity" is '10',
|
||||
* you have to set here the price for 10 parts!
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setPrice(string $new_price): self
|
||||
|
@ -309,6 +316,7 @@ class Pricedetail extends AbstractDBElement implements TimeStampableInterface
|
|||
* So the orderdetails would have three Pricedetails for one supplier.)
|
||||
*
|
||||
* @param float $new_min_discount_quantity the minimum discount quantity
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setMinDiscountQuantity(float $new_min_discount_quantity): self
|
||||
|
@ -328,12 +336,4 @@ class Pricedetail extends AbstractDBElement implements TimeStampableInterface
|
|||
{
|
||||
return 'PD'.sprintf('%06d', $this->getID());
|
||||
}
|
||||
|
||||
public function __clone()
|
||||
{
|
||||
if ($this->id) {
|
||||
$this->addedDate = null;
|
||||
}
|
||||
parent::__clone();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -45,7 +45,6 @@ namespace App\Entity\UserSystem;
|
|||
use App\Entity\Attachments\GroupAttachment;
|
||||
use App\Entity\Base\AbstractStructuralDBElement;
|
||||
use App\Entity\Parameters\GroupParameter;
|
||||
use App\Entity\Parameters\SupplierParameter;
|
||||
use App\Security\Interfaces\HasPermissionsInterface;
|
||||
use App\Validator\Constraints\ValidPermission;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
|
|
|
@ -123,6 +123,7 @@ class U2FKey implements TwoFactorKeyInterface
|
|||
public function setKeyHandle($keyHandle): self
|
||||
{
|
||||
$this->keyHandle = $keyHandle;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@ -134,6 +135,7 @@ class U2FKey implements TwoFactorKeyInterface
|
|||
public function setPublicKey($publicKey): self
|
||||
{
|
||||
$this->publicKey = $publicKey;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@ -145,6 +147,7 @@ class U2FKey implements TwoFactorKeyInterface
|
|||
public function setCertificate($certificate): self
|
||||
{
|
||||
$this->certificate = $certificate;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@ -156,6 +159,7 @@ class U2FKey implements TwoFactorKeyInterface
|
|||
public function setCounter($counter): self
|
||||
{
|
||||
$this->counter = $counter;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@ -167,6 +171,7 @@ class U2FKey implements TwoFactorKeyInterface
|
|||
public function setName($name): self
|
||||
{
|
||||
$this->name = $name;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@ -193,7 +198,6 @@ class U2FKey implements TwoFactorKeyInterface
|
|||
/**
|
||||
* Sets the user this U2F key belongs to.
|
||||
*
|
||||
* @param User $new_user
|
||||
* @return $this
|
||||
*/
|
||||
public function setUser(User $new_user): self
|
||||
|
|
|
@ -52,8 +52,8 @@ namespace App\Entity\UserSystem;
|
|||
|
||||
use App\Entity\Attachments\AttachmentContainingDBElement;
|
||||
use App\Entity\Attachments\UserAttachment;
|
||||
use App\Entity\Base\MasterAttachmentTrait;
|
||||
use App\Entity\Base\AbstractNamedDBElement;
|
||||
use App\Entity\Base\MasterAttachmentTrait;
|
||||
use App\Entity\PriceInformations\Currency;
|
||||
use App\Security\Interfaces\HasPermissionsInterface;
|
||||
use App\Validator\Constraints\Selectable;
|
||||
|
@ -338,7 +338,6 @@ class User extends AttachmentContainingDBElement implements UserInterface, HasPe
|
|||
/**
|
||||
* Sets the password hash for this user.
|
||||
*
|
||||
* @param string $password
|
||||
* @return User
|
||||
*/
|
||||
public function setPassword(string $password): self
|
||||
|
@ -378,7 +377,6 @@ class User extends AttachmentContainingDBElement implements UserInterface, HasPe
|
|||
/**
|
||||
* Sets the currency the users prefers to see prices in.
|
||||
*
|
||||
* @param Currency|null $currency
|
||||
* @return User
|
||||
*/
|
||||
public function setCurrency(?Currency $currency): self
|
||||
|
@ -441,7 +439,6 @@ class User extends AttachmentContainingDBElement implements UserInterface, HasPe
|
|||
/**
|
||||
* Set the status, if the user needs a password change.
|
||||
*
|
||||
* @param bool $need_pw_change
|
||||
* @return User
|
||||
*/
|
||||
public function setNeedPwChange(bool $need_pw_change): self
|
||||
|
@ -464,7 +461,6 @@ class User extends AttachmentContainingDBElement implements UserInterface, HasPe
|
|||
/**
|
||||
* Sets the encrypted password reset token.
|
||||
*
|
||||
* @param string|null $pw_reset_token
|
||||
* @return User
|
||||
*/
|
||||
public function setPwResetToken(?string $pw_reset_token): self
|
||||
|
@ -487,7 +483,6 @@ class User extends AttachmentContainingDBElement implements UserInterface, HasPe
|
|||
/**
|
||||
* Sets the datetime when the password reset token expires.
|
||||
*
|
||||
* @param DateTime $pw_reset_expires
|
||||
* @return User
|
||||
*/
|
||||
public function setPwResetExpires(DateTime $pw_reset_expires): self
|
||||
|
@ -671,7 +666,6 @@ class User extends AttachmentContainingDBElement implements UserInterface, HasPe
|
|||
/**
|
||||
* Change the timezone of this user.
|
||||
*
|
||||
* @param string|null $timezone
|
||||
* @return $this
|
||||
*/
|
||||
public function setTimezone(?string $timezone): self
|
||||
|
@ -764,7 +758,6 @@ class User extends AttachmentContainingDBElement implements UserInterface, HasPe
|
|||
/**
|
||||
* Sets the secret used for Google Authenticator. Set to null to disable Google Authenticator.
|
||||
*
|
||||
* @param string|null $googleAuthenticatorSecret
|
||||
* @return $this
|
||||
*/
|
||||
public function setGoogleAuthenticatorSecret(?string $googleAuthenticatorSecret): self
|
||||
|
@ -881,7 +874,6 @@ class User extends AttachmentContainingDBElement implements UserInterface, HasPe
|
|||
|
||||
/**
|
||||
* Add a U2F key to this user.
|
||||
* @param TwoFactorKeyInterface $key
|
||||
*/
|
||||
public function addU2FKey(TwoFactorKeyInterface $key): void
|
||||
{
|
||||
|
@ -890,7 +882,6 @@ class User extends AttachmentContainingDBElement implements UserInterface, HasPe
|
|||
|
||||
/**
|
||||
* Remove a U2F key from this user.
|
||||
* @param TwoFactorKeyInterface $key
|
||||
*/
|
||||
public function removeU2FKey(TwoFactorKeyInterface $key): void
|
||||
{
|
||||
|
|
|
@ -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,10 +24,7 @@
|
|||
namespace App\EventSubscriber;
|
||||
|
||||
use App\Entity\Attachments\Attachment;
|
||||
use App\Entity\Attachments\AttachmentType;
|
||||
use App\Entity\Base\AbstractDBElement;
|
||||
use App\Entity\Base\AbstractPartsContainingDBElement;
|
||||
use App\Entity\Base\AbstractStructuralDBElement;
|
||||
use App\Entity\LogSystem\AbstractLogEntry;
|
||||
use App\Entity\LogSystem\CollectionElementDeleted;
|
||||
use App\Entity\LogSystem\ElementCreatedLogEntry;
|
||||
|
@ -87,7 +87,7 @@ class EventLoggerSubscriber implements EventSubscriber
|
|||
$this->save_removed_data = $save_removed_data;
|
||||
}
|
||||
|
||||
public function onFlush(OnFlushEventArgs $eventArgs)
|
||||
public function onFlush(OnFlushEventArgs $eventArgs): void
|
||||
{
|
||||
$em = $eventArgs->getEntityManager();
|
||||
$uow = $em->getUnitOfWork();
|
||||
|
@ -112,7 +112,7 @@ class EventLoggerSubscriber implements EventSubscriber
|
|||
$uow->computeChangeSets();
|
||||
}
|
||||
|
||||
public function postPersist(LifecycleEventArgs $args)
|
||||
public function postPersist(LifecycleEventArgs $args): void
|
||||
{
|
||||
//Create an log entry, we have to do this post persist, cause we have to know the ID
|
||||
|
||||
|
@ -129,10 +129,10 @@ class EventLoggerSubscriber implements EventSubscriber
|
|||
|
||||
$log->setUndoneEvent($undoEvent, $this->eventUndoHelper->getMode());
|
||||
|
||||
if($undoEvent instanceof ElementDeletedLogEntry && $undoEvent->getTargetClass() === $log->getTargetClass()) {
|
||||
if ($undoEvent instanceof ElementDeletedLogEntry && $undoEvent->getTargetClass() === $log->getTargetClass()) {
|
||||
$log->setTargetElementID($undoEvent->getTargetID());
|
||||
}
|
||||
if($undoEvent instanceof CollectionElementDeleted && $undoEvent->getDeletedElementClass() === $log->getTargetClass()) {
|
||||
if ($undoEvent instanceof CollectionElementDeleted && $undoEvent->getDeletedElementClass() === $log->getTargetClass()) {
|
||||
$log->setTargetElementID($undoEvent->getDeletedElementID());
|
||||
}
|
||||
}
|
||||
|
@ -140,7 +140,7 @@ class EventLoggerSubscriber implements EventSubscriber
|
|||
}
|
||||
}
|
||||
|
||||
public function postFlush(PostFlushEventArgs $args)
|
||||
public function postFlush(PostFlushEventArgs $args): void
|
||||
{
|
||||
$em = $args->getEntityManager();
|
||||
$uow = $em->getUnitOfWork();
|
||||
|
@ -154,6 +154,48 @@ class EventLoggerSubscriber implements EventSubscriber
|
|||
$this->eventUndoHelper->clearUndoneEvent();
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the given element class has restrictions to its fields.
|
||||
*
|
||||
* @return bool True if there are restrictions, and further checking is needed
|
||||
*/
|
||||
public function hasFieldRestrictions(AbstractDBElement $element): bool
|
||||
{
|
||||
foreach (static::FIELD_BLACKLIST as $class => $blacklist) {
|
||||
if (is_a($element, $class)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the field of the given element should be saved (if it is not blacklisted).
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function shouldFieldBeSaved(AbstractDBElement $element, string $field_name): bool
|
||||
{
|
||||
foreach (static::FIELD_BLACKLIST as $class => $blacklist) {
|
||||
if (is_a($element, $class) && in_array($field_name, $blacklist, true)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
//By default allow every field.
|
||||
return true;
|
||||
}
|
||||
|
||||
public function getSubscribedEvents()
|
||||
{
|
||||
return[
|
||||
Events::onFlush,
|
||||
Events::postPersist,
|
||||
Events::postFlush,
|
||||
];
|
||||
}
|
||||
|
||||
protected function logElementDeleted(AbstractDBElement $entity, EntityManagerInterface $em): void
|
||||
{
|
||||
$log = new ElementDeletedLogEntry($entity);
|
||||
|
@ -179,7 +221,7 @@ class EventLoggerSubscriber implements EventSubscriber
|
|||
if (is_a($entity, $class)) {
|
||||
//Check names
|
||||
foreach ($mappings as $field => $mapping) {
|
||||
if (in_array($field, $whitelist)) {
|
||||
if (in_array($field, $whitelist, true)) {
|
||||
$changed = $this->propertyAccessor->getValue($entity, $field);
|
||||
$log = new CollectionElementDeleted($changed, $mapping['inversedBy'], $entity);
|
||||
if ($this->eventUndoHelper->isUndo()) {
|
||||
|
@ -216,33 +258,16 @@ class EventLoggerSubscriber implements EventSubscriber
|
|||
$this->logger->log($log);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the given element class has restrictions to its fields
|
||||
* @param AbstractDBElement $element
|
||||
* @return bool True if there are restrictions, and further checking is needed
|
||||
*/
|
||||
public function hasFieldRestrictions(AbstractDBElement $element): bool
|
||||
{
|
||||
foreach (static::FIELD_BLACKLIST as $class => $blacklist) {
|
||||
if (is_a($element, $class)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter out every forbidden field and return the cleaned array.
|
||||
* @param AbstractDBElement $element
|
||||
* @param array $fields
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function filterFieldRestrictions(AbstractDBElement $element, array $fields): array
|
||||
{
|
||||
unset($fields['lastModified']);
|
||||
|
||||
if (!$this->hasFieldRestrictions($element)) {
|
||||
if (! $this->hasFieldRestrictions($element)) {
|
||||
return $fields;
|
||||
}
|
||||
|
||||
|
@ -256,29 +281,11 @@ class EventLoggerSubscriber implements EventSubscriber
|
|||
}, ARRAY_FILTER_USE_BOTH);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the field of the given element should be saved (if it is not blacklisted).
|
||||
* @param AbstractDBElement $element
|
||||
* @param string $field_name
|
||||
* @return bool
|
||||
*/
|
||||
public function shouldFieldBeSaved(AbstractDBElement $element, string $field_name): bool
|
||||
{
|
||||
foreach (static::FIELD_BLACKLIST as $class => $blacklist) {
|
||||
if (is_a($element, $class) && in_array($field_name, $blacklist)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
//By default allow every field.
|
||||
return true;
|
||||
}
|
||||
|
||||
protected function saveChangeSet(AbstractDBElement $entity, AbstractLogEntry $logEntry, EntityManagerInterface $em, $element_deleted = false): void
|
||||
{
|
||||
$uow = $em->getUnitOfWork();
|
||||
|
||||
if (!$logEntry instanceof ElementEditedLogEntry && !$logEntry instanceof ElementDeletedLogEntry) {
|
||||
if (! $logEntry instanceof ElementEditedLogEntry && ! $logEntry instanceof ElementDeletedLogEntry) {
|
||||
throw new \InvalidArgumentException('$logEntry must be ElementEditedLogEntry or ElementDeletedLogEntry!');
|
||||
}
|
||||
|
||||
|
@ -304,28 +311,16 @@ class EventLoggerSubscriber implements EventSubscriber
|
|||
|
||||
/**
|
||||
* Check if the given entity can be logged.
|
||||
* @param object $entity
|
||||
*
|
||||
* @return bool True, if the given entity can be logged.
|
||||
*/
|
||||
protected function validEntity(object $entity): bool
|
||||
{
|
||||
//Dont log logentries itself!
|
||||
if ($entity instanceof AbstractDBElement && !$entity instanceof AbstractLogEntry) {
|
||||
if ($entity instanceof AbstractDBElement && ! $entity instanceof AbstractLogEntry) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getSubscribedEvents()
|
||||
{
|
||||
return[
|
||||
Events::onFlush,
|
||||
Events::postPersist,
|
||||
Events::postFlush
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -82,8 +82,8 @@ final class U2FRegistrationSubscriber implements EventSubscriberInterface
|
|||
//Skip adding of U2F key on demo mode
|
||||
if (! $this->demo_mode) {
|
||||
$user = $event->getUser();
|
||||
if (!$user instanceof User) {
|
||||
throw new \InvalidArgumentException("Only User objects can be registered for U2F!");
|
||||
if (! $user instanceof User) {
|
||||
throw new \InvalidArgumentException('Only User objects can be registered for U2F!');
|
||||
}
|
||||
|
||||
$registration = $event->getRegistration();
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
|
@ -29,14 +32,14 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
|
|||
|
||||
class ParameterType extends AbstractType
|
||||
{
|
||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
public function buildForm(FormBuilderInterface $builder, array $options): void
|
||||
{
|
||||
$builder->add('name', TextType::class,[
|
||||
$builder->add('name', TextType::class, [
|
||||
'empty_data' => '',
|
||||
'attr' => [
|
||||
'placeholder' => 'parameters.name.placeholder',
|
||||
'class' => 'form-control-sm'
|
||||
]
|
||||
'class' => 'form-control-sm',
|
||||
],
|
||||
]);
|
||||
$builder->add('symbol', TextType::class, [
|
||||
'required' => false,
|
||||
|
@ -44,8 +47,8 @@ class ParameterType extends AbstractType
|
|||
'attr' => [
|
||||
'placeholder' => 'parameters.symbol.placeholder',
|
||||
'class' => 'form-control-sm',
|
||||
'style' => 'max-width: 15ch;'
|
||||
]
|
||||
'style' => 'max-width: 15ch;',
|
||||
],
|
||||
]);
|
||||
$builder->add('value_text', TextType::class, [
|
||||
'required' => false,
|
||||
|
@ -53,7 +56,7 @@ class ParameterType extends AbstractType
|
|||
'attr' => [
|
||||
'placeholder' => 'parameters.text.placeholder',
|
||||
'class' => 'form-control-sm',
|
||||
]
|
||||
],
|
||||
]);
|
||||
|
||||
$builder->add('value_max', NumberType::class, [
|
||||
|
@ -63,8 +66,8 @@ class ParameterType extends AbstractType
|
|||
'step' => 'any',
|
||||
'placeholder' => 'parameters.max.placeholder',
|
||||
'class' => 'form-control-sm',
|
||||
'style' => 'max-width: 15ch;'
|
||||
],
|
||||
'style' => 'max-width: 15ch;',
|
||||
],
|
||||
]);
|
||||
$builder->add('value_min', NumberType::class, [
|
||||
'required' => false,
|
||||
|
@ -73,7 +76,7 @@ class ParameterType extends AbstractType
|
|||
'step' => 'any',
|
||||
'placeholder' => 'parameters.min.placeholder',
|
||||
'class' => 'form-control-sm',
|
||||
'style' => 'max-width: 15ch;'
|
||||
'style' => 'max-width: 15ch;',
|
||||
],
|
||||
]);
|
||||
$builder->add('value_typical', NumberType::class, [
|
||||
|
@ -83,8 +86,8 @@ class ParameterType extends AbstractType
|
|||
'step' => 'any',
|
||||
'placeholder' => 'parameters.typical.placeholder',
|
||||
'class' => 'form-control-sm',
|
||||
'style' => 'max-width: 15ch;'
|
||||
]
|
||||
'style' => 'max-width: 15ch;',
|
||||
],
|
||||
]);
|
||||
$builder->add('unit', TextType::class, [
|
||||
'required' => false,
|
||||
|
@ -92,15 +95,15 @@ class ParameterType extends AbstractType
|
|||
'attr' => [
|
||||
'placeholder' => 'parameters.unit.placeholder',
|
||||
'class' => 'form-control-sm',
|
||||
'style' => 'max-width: 8ch;'
|
||||
]
|
||||
'style' => 'max-width: 8ch;',
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
public function configureOptions(OptionsResolver $resolver)
|
||||
public function configureOptions(OptionsResolver $resolver): void
|
||||
{
|
||||
$resolver->setDefaults([
|
||||
'data_class' => AbstractParameter::class
|
||||
]);
|
||||
'data_class' => AbstractParameter::class,
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -51,7 +51,6 @@ use App\Entity\Parts\Manufacturer;
|
|||
use App\Entity\Parts\MeasurementUnit;
|
||||
use App\Entity\Parts\Part;
|
||||
use App\Entity\PriceInformations\Orderdetail;
|
||||
use App\Entity\Parameters\Parameter;
|
||||
use App\Form\AttachmentFormType;
|
||||
use App\Form\ParameterType;
|
||||
use App\Form\Type\MasterPictureAttachmentType;
|
||||
|
@ -275,8 +274,8 @@ class PartBaseType extends AbstractType
|
|||
'by_reference' => false,
|
||||
'prototype_data' => new PartParameter(),
|
||||
'entry_options' => [
|
||||
'data_class' => PartParameter::class
|
||||
]
|
||||
'data_class' => PartParameter::class,
|
||||
],
|
||||
]);
|
||||
|
||||
$builder->add('log_comment', TextType::class, [
|
||||
|
@ -295,7 +294,7 @@ class PartBaseType extends AbstractType
|
|||
public function configureOptions(OptionsResolver $resolver): void
|
||||
{
|
||||
$resolver->setDefaults([
|
||||
'data_class' => Part::class,
|
||||
]);
|
||||
'data_class' => Part::class,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -87,7 +87,7 @@ class CurrencyEntityType extends StructuralEntityType
|
|||
{
|
||||
//Similar to StructuralEntityType, but we use the currency symbol instead if available
|
||||
|
||||
if (!$choice instanceof Currency) {
|
||||
if (! $choice instanceof Currency) {
|
||||
throw new \InvalidArgumentException('$choice must be an currency object!');
|
||||
}
|
||||
|
||||
|
|
|
@ -43,7 +43,6 @@ declare(strict_types=1);
|
|||
namespace App\Form\Type;
|
||||
|
||||
use App\Entity\Attachments\Attachment;
|
||||
use App\Entity\Attachments\AttachmentContainingDBElement;
|
||||
use App\Entity\Contracts\HasMasterAttachmentInterface;
|
||||
use Doctrine\ORM\EntityRepository;
|
||||
use ReflectionClass;
|
||||
|
|
|
@ -12,24 +12,24 @@ use Doctrine\Migrations\AbstractMigration;
|
|||
*/
|
||||
final class Version20200311204104 extends AbstractMigration
|
||||
{
|
||||
public function getDescription() : string
|
||||
public function getDescription(): string
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
public function up(Schema $schema) : void
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
// this up() migration is auto-generated, please modify it to your needs
|
||||
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.');
|
||||
$this->abortIf('mysql' !== $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'mysql\'.');
|
||||
|
||||
$this->addSql('CREATE TABLE parameters (id INT AUTO_INCREMENT NOT NULL, name VARCHAR(255) NOT NULL, symbol VARCHAR(255) NOT NULL, value_min DOUBLE PRECISION DEFAULT NULL, value_typical DOUBLE PRECISION DEFAULT NULL, value_max DOUBLE PRECISION DEFAULT NULL, unit VARCHAR(255) NOT NULL, value_text VARCHAR(255) NOT NULL, param_group VARCHAR(255) NOT NULL, last_modified DATETIME DEFAULT CURRENT_TIMESTAMP NOT NULL, datetime_added DATETIME DEFAULT CURRENT_TIMESTAMP NOT NULL, type SMALLINT NOT NULL, element_id INT NOT NULL, INDEX IDX_69348FE1F1F2A24 (element_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
|
||||
$this->addSql('ALTER TABLE log CHANGE level level TINYINT');
|
||||
}
|
||||
|
||||
public function down(Schema $schema) : void
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
// this down() migration is auto-generated, please modify it to your needs
|
||||
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.');
|
||||
$this->abortIf('mysql' !== $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'mysql\'.');
|
||||
|
||||
$this->addSql('DROP TABLE parameters');
|
||||
$this->addSql('ALTER TABLE log CHANGE level level TINYINT(1) DEFAULT NULL');
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
|
@ -20,13 +23,11 @@
|
|||
|
||||
namespace App\Repository;
|
||||
|
||||
|
||||
use Doctrine\ORM\EntityRepository;
|
||||
|
||||
class AttachmentRepository extends DBElementRepository
|
||||
{
|
||||
/**
|
||||
* Gets the count of all private/secure attachments.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getPrivateAttachmentsCount(): int
|
||||
|
@ -36,12 +37,15 @@ class AttachmentRepository extends DBElementRepository
|
|||
->where('attachment.path LIKE :like');
|
||||
$qb->setParameter('like', '\\%SECURE\\%%');
|
||||
$query = $qb->getQuery();
|
||||
|
||||
return (int) $query->getSingleScalarResult();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the count of all external attachments (attachments only containing an URL)
|
||||
* Gets the count of all external attachments (attachments only containing an URL).
|
||||
*
|
||||
* @return int
|
||||
*
|
||||
* @throws \Doctrine\ORM\NoResultException
|
||||
* @throws \Doctrine\ORM\NonUniqueResultException
|
||||
*/
|
||||
|
@ -54,12 +58,15 @@ class AttachmentRepository extends DBElementRepository
|
|||
$qb->setParameter('http', 'http://%');
|
||||
$qb->setParameter('https', 'https://%');
|
||||
$query = $qb->getQuery();
|
||||
|
||||
return (int) $query->getSingleScalarResult();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the count of all attachments where an user uploaded an file.
|
||||
*
|
||||
* @return int
|
||||
*
|
||||
* @throws \Doctrine\ORM\NoResultException
|
||||
* @throws \Doctrine\ORM\NonUniqueResultException
|
||||
*/
|
||||
|
@ -74,6 +81,7 @@ class AttachmentRepository extends DBElementRepository
|
|||
$qb->setParameter('base', '\\%BASE\\%%');
|
||||
$qb->setParameter('media', '\\%MEDIA\\%%');
|
||||
$query = $qb->getQuery();
|
||||
|
||||
return (int) $query->getSingleScalarResult();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
|
@ -20,7 +23,6 @@
|
|||
|
||||
namespace App\Repository;
|
||||
|
||||
|
||||
use App\Entity\Base\AbstractDBElement;
|
||||
use Doctrine\ORM\EntityRepository;
|
||||
|
||||
|
@ -29,8 +31,9 @@ class DBElementRepository extends EntityRepository
|
|||
/**
|
||||
* Changes the ID of the given element to a new value.
|
||||
* You should only use it to undelete former existing elements, everything else is most likely a bad idea!
|
||||
* @param AbstractDBElement $element The element whose ID should be changed
|
||||
* @param int $new_id The new ID
|
||||
*
|
||||
* @param AbstractDBElement $element The element whose ID should be changed
|
||||
* @param int $new_id The new ID
|
||||
*/
|
||||
public function changeID(AbstractDBElement $element, int $new_id): void
|
||||
{
|
||||
|
@ -46,11 +49,11 @@ class DBElementRepository extends EntityRepository
|
|||
$this->setField($element, 'id', $new_id);
|
||||
}
|
||||
|
||||
protected function setField(AbstractDBElement $element, string $field, $new_value)
|
||||
protected function setField(AbstractDBElement $element, string $field, $new_value): void
|
||||
{
|
||||
$reflection = new \ReflectionClass(get_class($element));
|
||||
$property = $reflection->getProperty($field);
|
||||
$property->setAccessible(true);
|
||||
$property->setValue($element, $new_value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -49,8 +49,6 @@ use App\Entity\LogSystem\ElementCreatedLogEntry;
|
|||
use App\Entity\LogSystem\ElementDeletedLogEntry;
|
||||
use App\Entity\LogSystem\ElementEditedLogEntry;
|
||||
use App\Entity\UserSystem\User;
|
||||
use Doctrine\ORM\EntityRepository;
|
||||
use Doctrine\ORM\QueryBuilder;
|
||||
|
||||
class LogEntryRepository extends DBElementRepository
|
||||
{
|
||||
|
@ -72,9 +70,9 @@ class LogEntryRepository extends DBElementRepository
|
|||
* Find log entries associated with the given element (the history of the element).
|
||||
*
|
||||
* @param AbstractDBElement $element The element for which the history should be generated
|
||||
* @param string $order By default newest entries are shown first. Change this to ASC to show oldest entries first.
|
||||
* @param null $limit
|
||||
* @param null $offset
|
||||
* @param string $order By default newest entries are shown first. Change this to ASC to show oldest entries first.
|
||||
* @param null $limit
|
||||
* @param null $offset
|
||||
*
|
||||
* @return AbstractLogEntry[]
|
||||
*/
|
||||
|
@ -84,9 +82,11 @@ class LogEntryRepository extends DBElementRepository
|
|||
}
|
||||
|
||||
/**
|
||||
* Try to get a log entry that contains the information to undete a given element
|
||||
* @param string $class The class of the element that should be undeleted
|
||||
* @param int $id The ID of the element that should be deleted
|
||||
* Try to get a log entry that contains the information to undete a given element.
|
||||
*
|
||||
* @param string $class The class of the element that should be undeleted
|
||||
* @param int $id The ID of the element that should be deleted
|
||||
*
|
||||
* @return ElementDeletedLogEntry
|
||||
*/
|
||||
public function getUndeleteDataForElement(string $class, int $id): ElementDeletedLogEntry
|
||||
|
@ -94,31 +94,34 @@ class LogEntryRepository extends DBElementRepository
|
|||
$qb = $this->createQueryBuilder('log');
|
||||
$qb->select('log')
|
||||
//->where('log INSTANCE OF App\Entity\LogSystem\ElementEditedLogEntry')
|
||||
->where('log INSTANCE OF ' . ElementDeletedLogEntry::class)
|
||||
->where('log INSTANCE OF '.ElementDeletedLogEntry::class)
|
||||
->andWhere('log.target_type = :target_type')
|
||||
->andWhere('log.target_id = :target_id')
|
||||
->orderBy('log.timestamp', 'DESC')
|
||||
->setMaxResults(1);
|
||||
|
||||
$qb->setParameters([
|
||||
'target_type' => AbstractLogEntry::targetTypeClassToID($class),
|
||||
'target_id' => $id,
|
||||
]);
|
||||
'target_type' => AbstractLogEntry::targetTypeClassToID($class),
|
||||
'target_id' => $id,
|
||||
]);
|
||||
|
||||
$query = $qb->getQuery();
|
||||
$query = $qb->getQuery();
|
||||
|
||||
$results = $query->execute();
|
||||
|
||||
if (empty($results)) {
|
||||
throw new \RuntimeException("No undelete data could be found for this element");
|
||||
throw new \RuntimeException('No undelete data could be found for this element');
|
||||
}
|
||||
|
||||
return $results[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets all log entries that are related to time travelling
|
||||
* @param AbstractDBElement $element The element for which the time travel data should be retrieved
|
||||
* @param \DateTime $until Back to which timestamp should the data be get (including the timestamp)
|
||||
* Gets all log entries that are related to time travelling.
|
||||
*
|
||||
* @param AbstractDBElement $element The element for which the time travel data should be retrieved
|
||||
* @param \DateTime $until Back to which timestamp should the data be get (including the timestamp)
|
||||
*
|
||||
* @return AbstractLogEntry[]
|
||||
*/
|
||||
public function getTimetravelDataForElement(AbstractDBElement $element, \DateTime $until): array
|
||||
|
@ -126,48 +129,49 @@ class LogEntryRepository extends DBElementRepository
|
|||
$qb = $this->createQueryBuilder('log');
|
||||
$qb->select('log')
|
||||
//->where('log INSTANCE OF App\Entity\LogSystem\ElementEditedLogEntry')
|
||||
->where('log INSTANCE OF ' . ElementEditedLogEntry::class)
|
||||
->orWhere('log INSTANCE OF ' . CollectionElementDeleted::class)
|
||||
->where('log INSTANCE OF '.ElementEditedLogEntry::class)
|
||||
->orWhere('log INSTANCE OF '.CollectionElementDeleted::class)
|
||||
->andWhere('log.target_type = :target_type')
|
||||
->andWhere('log.target_id = :target_id')
|
||||
->andWhere('log.timestamp >= :until')
|
||||
->orderBy('log.timestamp', 'DESC');
|
||||
|
||||
$qb->setParameters([
|
||||
'target_type' => AbstractLogEntry::targetTypeClassToID(get_class($element)),
|
||||
'target_id' => $element->getID(),
|
||||
'until' => $until
|
||||
]);
|
||||
'target_type' => AbstractLogEntry::targetTypeClassToID(get_class($element)),
|
||||
'target_id' => $element->getID(),
|
||||
'until' => $until,
|
||||
]);
|
||||
|
||||
$query = $qb->getQuery();
|
||||
|
||||
return $query->execute();
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the given element has existed at the given timestamp
|
||||
* @param AbstractDBElement $element
|
||||
* @param \DateTime $timestamp
|
||||
* Check if the given element has existed at the given timestamp.
|
||||
*
|
||||
* @return bool True if the element existed at the given timestamp
|
||||
*/
|
||||
public function getElementExistedAtTimestamp(AbstractDBElement $element, \DateTime $timestamp): bool
|
||||
{
|
||||
$qb = $this->createQueryBuilder('log');
|
||||
$qb->select('count(log)')
|
||||
->where('log INSTANCE OF ' . ElementCreatedLogEntry::class)
|
||||
->where('log INSTANCE OF '.ElementCreatedLogEntry::class)
|
||||
->andWhere('log.target_type = :target_type')
|
||||
->andWhere('log.target_id = :target_id')
|
||||
->andWhere('log.timestamp >= :until')
|
||||
->orderBy('log.timestamp', 'DESC');
|
||||
|
||||
$qb->setParameters([
|
||||
'target_type' => AbstractLogEntry::targetTypeClassToID(get_class($element)),
|
||||
'target_id' => $element->getID(),
|
||||
'until' => $timestamp
|
||||
]);
|
||||
'target_type' => AbstractLogEntry::targetTypeClassToID(get_class($element)),
|
||||
'target_id' => $element->getID(),
|
||||
'until' => $timestamp,
|
||||
]);
|
||||
|
||||
$query = $qb->getQuery();
|
||||
$count = $query->getSingleScalarResult();
|
||||
return !($count > 0);
|
||||
|
||||
return ! ($count > 0);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -187,9 +191,9 @@ class LogEntryRepository extends DBElementRepository
|
|||
/**
|
||||
* Gets the target element associated with the logentry.
|
||||
*
|
||||
* @param AbstractLogEntry $logEntry
|
||||
* @return AbstractDBElement|null Returns the associated DBElement or null if the log either has no target or the element
|
||||
* was deleted from DB.
|
||||
* was deleted from DB.
|
||||
*
|
||||
* @throws \Doctrine\ORM\ORMException
|
||||
* @throws \Doctrine\ORM\OptimisticLockException
|
||||
* @throws \Doctrine\ORM\TransactionRequiredException
|
||||
|
@ -206,34 +210,9 @@ class LogEntryRepository extends DBElementRepository
|
|||
return $this->getEntityManager()->find($class, $id);
|
||||
}
|
||||
|
||||
protected function getLastUser(AbstractDBElement $element, string $class)
|
||||
{
|
||||
$qb = $this->createQueryBuilder('log');
|
||||
$qb->select('log')
|
||||
//->where('log INSTANCE OF App\Entity\LogSystem\ElementEditedLogEntry')
|
||||
->where('log INSTANCE OF ' . $class)
|
||||
->andWhere('log.target_type = :target_type')
|
||||
->andWhere('log.target_id = :target_id')
|
||||
->orderBy('log.timestamp', 'DESC');
|
||||
|
||||
$qb->setParameters([
|
||||
'target_type' => AbstractLogEntry::targetTypeClassToID(get_class($element)),
|
||||
'target_id' => $element->getID()
|
||||
]);
|
||||
|
||||
$query = $qb->getQuery();
|
||||
$query->setMaxResults(1);
|
||||
/** @var AbstractLogEntry[] $results */
|
||||
$results = $query->execute();
|
||||
if (isset($results[0])) {
|
||||
return $results[0]->getUser();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the last user that has edited the given element.
|
||||
* @param AbstractDBElement $element
|
||||
*
|
||||
* @return User|null A user object, or null if no user could be determined.
|
||||
*/
|
||||
public function getLastEditingUser(AbstractDBElement $element): ?User
|
||||
|
@ -243,11 +222,37 @@ class LogEntryRepository extends DBElementRepository
|
|||
|
||||
/**
|
||||
* Returns the user that has created the given element.
|
||||
* @param AbstractDBElement $element
|
||||
*
|
||||
* @return User|null A user object, or null if no user could be determined.
|
||||
*/
|
||||
public function getCreatingUser(AbstractDBElement $element): ?User
|
||||
{
|
||||
return $this->getLastUser($element, ElementCreatedLogEntry::class);
|
||||
}
|
||||
|
||||
protected function getLastUser(AbstractDBElement $element, string $class)
|
||||
{
|
||||
$qb = $this->createQueryBuilder('log');
|
||||
$qb->select('log')
|
||||
//->where('log INSTANCE OF App\Entity\LogSystem\ElementEditedLogEntry')
|
||||
->where('log INSTANCE OF '.$class)
|
||||
->andWhere('log.target_type = :target_type')
|
||||
->andWhere('log.target_id = :target_id')
|
||||
->orderBy('log.timestamp', 'DESC');
|
||||
|
||||
$qb->setParameters([
|
||||
'target_type' => AbstractLogEntry::targetTypeClassToID(get_class($element)),
|
||||
'target_id' => $element->getID(),
|
||||
]);
|
||||
|
||||
$query = $qb->getQuery();
|
||||
$query->setMaxResults(1);
|
||||
/** @var AbstractLogEntry[] $results */
|
||||
$results = $query->execute();
|
||||
if (isset($results[0])) {
|
||||
return $results[0]->getUser();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue