Passed
Push — trunk ( 8d610b...05c644 )
by Christian
10:57 queued 12s
created

MediaUploadedEvent   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 13
dl 0
loc 49
rs 10
c 0
b 0
f 0
wmc 8

8 Methods

Rating   Name   Duplication   Size   Complexity  
A getContext() 0 3 1
A getName() 0 3 1
A getMediaId() 0 3 1
A getValues() 0 4 1
A __construct() 0 4 1
A getAvailableData() 0 4 1
A isAllowed() 0 3 1
A getWebhookPayload() 0 4 1
1
<?php declare(strict_types=1);
2
3
namespace Shopware\Core\Content\Media\Event;
4
5
use Shopware\Core\Content\Flow\Dispatching\Action\FlowMailVariables;
6
use Shopware\Core\Content\Flow\Dispatching\Aware\MediaUploadedAware;
7
use Shopware\Core\Content\Flow\Dispatching\Aware\ScalarValuesAware;
8
use Shopware\Core\Framework\Context;
9
use Shopware\Core\Framework\Event\EventData\EventDataCollection;
10
use Shopware\Core\Framework\Event\EventData\ScalarValueType;
11
use Shopware\Core\Framework\Event\FlowEventAware;
12
use Shopware\Core\Framework\Log\Package;
13
use Shopware\Core\Framework\Webhook\AclPrivilegeCollection;
14
use Shopware\Core\Framework\Webhook\Hookable;
15
use Symfony\Contracts\EventDispatcher\Event;
16
17
/**
18
 * @deprecated tag:v6.6.0 - reason:class-hierarchy-change - MediaUploadedAware is deprecated and will be removed in v6.6.0
19
 */
20
#[Package('content')]
21
class MediaUploadedEvent extends Event implements MediaUploadedAware, ScalarValuesAware, FlowEventAware, Hookable
0 ignored issues
show
Deprecated Code introduced by
The interface Shopware\Core\Content\Fl...ware\MediaUploadedAware has been deprecated: tag:v6.6.0 - Will be removed, use ScalarValuesStorer/ScalarValuesAware instead ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

21
class MediaUploadedEvent extends Event implements /** @scrutinizer ignore-deprecated */ MediaUploadedAware, ScalarValuesAware, FlowEventAware, Hookable

This interface has been deprecated. The supplier of the interface has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the interface will be removed and what other interface to use instead.

Loading history...
22
{
23
    public const EVENT_NAME = 'media.uploaded';
24
25
    public function __construct(
26
        private readonly string $mediaId,
27
        private readonly Context $context
28
    ) {
29
    }
30
31
    public function getName(): string
32
    {
33
        return self::EVENT_NAME;
34
    }
35
36
    public static function getAvailableData(): EventDataCollection
37
    {
38
        return (new EventDataCollection())
39
            ->add('mediaId', new ScalarValueType(ScalarValueType::TYPE_STRING));
40
    }
41
42
    public function getValues(): array
43
    {
44
        return [
45
            FlowMailVariables::MEDIA_ID => $this->mediaId,
46
        ];
47
    }
48
49
    public function getMediaId(): string
50
    {
51
        return $this->mediaId;
52
    }
53
54
    public function getContext(): Context
55
    {
56
        return $this->context;
57
    }
58
59
    public function getWebhookPayload(): array
60
    {
61
        return [
62
            'mediaId' => $this->mediaId,
63
        ];
64
    }
65
66
    public function isAllowed(string $appId, AclPrivilegeCollection $permissions): bool
67
    {
68
        return $permissions->isAllowed('media', 'read');
69
    }
70
}
71