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

DeleteThemeFilesHandler::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 0

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 0
nc 1
nop 2
dl 0
loc 2
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