|
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 |
|
|
|
|
|
|
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
|
|
|
|
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.