Passed
Push — trunk ( ccf801...a9c55d )
by Christian
09:47 queued 12s
created

ThemeExceptionHandler::getPriority()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
1
<?php declare(strict_types=1);
2
3
namespace Shopware\Storefront\Theme\DataAbstractionLayer;
4
5
use Shopware\Core\Framework\DataAbstractionLayer\Dbal\ExceptionHandlerInterface;
6
use Shopware\Core\Framework\Log\Package;
7
use Shopware\Storefront\Theme\Exception\ThemeException;
8
9
/**
10
 * @internal
11
 */
12
#[Package('storefront')]
13
class ThemeExceptionHandler implements ExceptionHandlerInterface
14
{
15
    public function getPriority(): int
16
    {
17
        return ExceptionHandlerInterface::PRIORITY_DEFAULT;
18
    }
19
20
    public function matchException(\Exception $e): ?\Exception
21
    {
22
        if (preg_match(
23
            '/SQLSTATE\[23000]: Integrity constraint violation: 1451.*CONSTRAINT `fk.theme_media.media_id` FOREIGN KEY \(`media_id`\) REFERENCES `media` \(`id`\)/',
24
            $e->getMessage(),
25
        )) {
26
            return ThemeException::themeMediaStillInUse();
27
        }
28
29
        return null;
30
    }
31
}
32