-
Notifications
You must be signed in to change notification settings - Fork 13
/
BeforeCopyContentEvent.php
75 lines (60 loc) · 2.29 KB
/
BeforeCopyContentEvent.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
<?php
/**
* @copyright Copyright (C) Ibexa AS. All rights reserved.
* @license For full copyright and license information view LICENSE file distributed with this source code.
*/
declare(strict_types=1);
namespace Ibexa\Contracts\Core\Repository\Events\Content;
use Ibexa\Contracts\Core\Repository\Event\BeforeEvent;
use Ibexa\Contracts\Core\Repository\Values\Content\Content;
use Ibexa\Contracts\Core\Repository\Values\Content\ContentInfo;
use Ibexa\Contracts\Core\Repository\Values\Content\LocationCreateStruct;
use Ibexa\Contracts\Core\Repository\Values\Content\VersionInfo;
use UnexpectedValueException;
final class BeforeCopyContentEvent extends BeforeEvent
{
/** @var \Ibexa\Contracts\Core\Repository\Values\Content\ContentInfo */
private $contentInfo;
/** @var \Ibexa\Contracts\Core\Repository\Values\Content\LocationCreateStruct */
private $destinationLocationCreateStruct;
/** @var \Ibexa\Contracts\Core\Repository\Values\Content\VersionInfo */
private $versionInfo;
/** @var \Ibexa\Contracts\Core\Repository\Values\Content\Content|null */
private $content;
public function __construct(
ContentInfo $contentInfo,
LocationCreateStruct $destinationLocationCreateStruct,
?VersionInfo $versionInfo = null
) {
$this->contentInfo = $contentInfo;
$this->destinationLocationCreateStruct = $destinationLocationCreateStruct;
$this->versionInfo = $versionInfo;
}
public function getContentInfo(): ContentInfo
{
return $this->contentInfo;
}
public function getDestinationLocationCreateStruct(): LocationCreateStruct
{
return $this->destinationLocationCreateStruct;
}
public function getVersionInfo(): ?VersionInfo
{
return $this->versionInfo;
}
public function getContent(): Content
{
if (!$this->hasContent()) {
throw new UnexpectedValueException(sprintf('Return value is not set or not a type of %s. Check hasContent() or set it using setContent() before you call the getter.', Content::class));
}
return $this->content;
}
public function setContent(?Content $content): void
{
$this->content = $content;
}
public function hasContent(): bool
{
return $this->content instanceof Content;
}
}