Passed
Push — trunk ( f797a9...e92141 )
by Christian
22:24 queued 10:00
created

DeleteThemeFilesHandler::__invoke()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 4
nc 2
nop 1
dl 0
loc 9
rs 10
c 1
b 0
f 0
1
<?php declare(strict_types=1);
2
3
namespace Shopware\Storefront\Theme\Message;
4
5
use League\Flysystem\FilesystemOperator;
6
use Shopware\Storefront\Theme\AbstractThemePathBuilder;
7
use Symfony\Component\Messenger\Attribute\AsMessageHandler;
8
9
/**
10
 * @package storefront
11
 *
12
 * @internal
13
 */
14
#[AsMessageHandler]
15
final class DeleteThemeFilesHandler
16
{
17
    public function __construct(private readonly FilesystemOperator $filesystem, private readonly AbstractThemePathBuilder $pathBuilder)
18
    {
19
    }
20
21
    public function __invoke(DeleteThemeFilesMessage $message): void
22
    {
23
        $currentPath = $this->pathBuilder->assemblePath($message->getSalesChannelId(), $message->getThemeId());
24
25
        if ($currentPath === $message->getThemePath()) {
26
            return;
27
        }
28
29
        $this->filesystem->deleteDirectory($message->getThemePath());
30
    }
31
}
32