|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace eZ\Publish\Core\Event\Content; |
|
6
|
|
|
|
|
7
|
|
|
use eZ\Publish\API\Repository\Values\Content\Content; |
|
8
|
|
|
use eZ\Publish\API\Repository\Values\Content\ContentInfo; |
|
9
|
|
|
use eZ\Publish\API\Repository\Values\Content\VersionInfo; |
|
10
|
|
|
use eZ\Publish\API\Repository\Values\User\User; |
|
11
|
|
|
use eZ\Publish\Core\Event\BeforeEvent; |
|
12
|
|
|
|
|
13
|
|
|
final class BeforeCreateContentDraftEvent extends BeforeEvent |
|
14
|
|
|
{ |
|
15
|
|
|
public const NAME = 'ezplatform.event.content.draft_create.before'; |
|
16
|
|
|
|
|
17
|
|
|
/** |
|
18
|
|
|
* @var \eZ\Publish\API\Repository\Values\Content\ContentInfo |
|
19
|
|
|
*/ |
|
20
|
|
|
private $contentInfo; |
|
21
|
|
|
|
|
22
|
|
|
/** |
|
23
|
|
|
* @var \eZ\Publish\API\Repository\Values\Content\VersionInfo |
|
24
|
|
|
*/ |
|
25
|
|
|
private $versionInfo; |
|
26
|
|
|
|
|
27
|
|
|
/** |
|
28
|
|
|
* @var \eZ\Publish\API\Repository\Values\User\User |
|
29
|
|
|
*/ |
|
30
|
|
|
private $creator; |
|
31
|
|
|
|
|
32
|
|
|
/** |
|
33
|
|
|
* @var \eZ\Publish\API\Repository\Values\Content\Content|null |
|
34
|
|
|
*/ |
|
35
|
|
|
private $contentDraft; |
|
36
|
|
|
|
|
37
|
|
|
|
|
38
|
|
|
public function __construct(ContentInfo $contentInfo, VersionInfo $versionInfo, User $creator) |
|
39
|
|
|
{ |
|
40
|
|
|
$this->contentInfo = $contentInfo; |
|
41
|
|
|
$this->versionInfo = $versionInfo; |
|
42
|
|
|
$this->creator = $creator; |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
|
|
46
|
|
|
public function getContentInfo(): ContentInfo |
|
47
|
|
|
{ |
|
48
|
|
|
return $this->contentInfo; |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
|
|
52
|
|
|
public function getVersionInfo(): VersionInfo |
|
53
|
|
|
{ |
|
54
|
|
|
return $this->versionInfo; |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
|
|
58
|
|
|
public function getCreator(): User |
|
59
|
|
|
{ |
|
60
|
|
|
return $this->creator; |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
|
|
64
|
|
|
function getContentDraft(): ?Content |
|
|
|
|
|
|
65
|
|
|
{ |
|
66
|
|
|
return $this->contentDraft; |
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
|
|
|
|
70
|
|
|
function setContentDraft(?Content $contentDraft): void |
|
|
|
|
|
|
71
|
|
|
{ |
|
72
|
|
|
$this->contentDraft = $contentDraft; |
|
73
|
|
|
} |
|
74
|
|
|
|
|
75
|
|
|
|
|
76
|
|
|
function hasContentDraft(): bool |
|
|
|
|
|
|
77
|
|
|
{ |
|
78
|
|
|
return $this->contentDraft instanceof Content; |
|
79
|
|
|
} |
|
80
|
|
|
} |
|
81
|
|
|
|
Adding explicit visibility (
private,protected, orpublic) is generally recommend to communicate to other developers how, and from where this method is intended to be used.