mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-27 20:28:54 +02:00
Applied rector with PHP8.1 migration rules
This commit is contained in:
parent
dc6a67c2f0
commit
7ee01d9a05
303 changed files with 1228 additions and 3465 deletions
|
@ -43,16 +43,10 @@ use const DIRECTORY_SEPARATOR;
|
|||
#[\Symfony\Component\Console\Attribute\AsCommand('partdb:attachments:clean-unused|app:clean-attachments', 'Lists (and deletes if wanted) attachments files that are not used anymore (abandoned files).')]
|
||||
class CleanAttachmentsCommand extends Command
|
||||
{
|
||||
protected AttachmentManager $attachment_helper;
|
||||
protected AttachmentReverseSearch $reverseSearch;
|
||||
protected MimeTypes $mimeTypeGuesser;
|
||||
protected AttachmentPathResolver $pathResolver;
|
||||
|
||||
public function __construct(AttachmentManager $attachmentHelper, AttachmentReverseSearch $reverseSearch, AttachmentPathResolver $pathResolver)
|
||||
public function __construct(protected AttachmentManager $attachment_helper, protected AttachmentReverseSearch $reverseSearch, protected AttachmentPathResolver $pathResolver)
|
||||
{
|
||||
$this->attachment_helper = $attachmentHelper;
|
||||
$this->pathResolver = $pathResolver;
|
||||
$this->reverseSearch = $reverseSearch;
|
||||
$this->mimeTypeGuesser = new MimeTypes();
|
||||
parent::__construct();
|
||||
}
|
||||
|
@ -88,7 +82,7 @@ class CleanAttachmentsCommand extends Command
|
|||
|
||||
foreach ($finder as $file) {
|
||||
//If not attachment object uses this file, print it
|
||||
if (0 === count($this->reverseSearch->findAttachmentsByFile($file))) {
|
||||
if ([] === $this->reverseSearch->findAttachmentsByFile($file)) {
|
||||
$file_list[] = $file;
|
||||
$table->addRow([
|
||||
$fs->makePathRelative($file->getPathname(), $mediaPath),
|
||||
|
@ -98,7 +92,7 @@ class CleanAttachmentsCommand extends Command
|
|||
}
|
||||
}
|
||||
|
||||
if (count($file_list) > 0) {
|
||||
if ($file_list !== []) {
|
||||
$table->render();
|
||||
|
||||
$continue = $io->confirm(sprintf('Found %d abandoned files. Do you want to delete them? This can not be undone!', count($file_list)), false);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue