1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* This file is part of the Superdesk Web Publisher Bridge Component. |
5
|
|
|
* |
6
|
|
|
* Copyright 2016 Sourcefabric z.ú. and contributors. |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please see the |
9
|
|
|
* AUTHORS and LICENSE files distributed with this source code. |
10
|
|
|
* |
11
|
|
|
* @copyright 2016 Sourcefabric z.ú |
12
|
|
|
* @license http://www.superdesk.org/license |
13
|
|
|
*/ |
14
|
|
|
|
15
|
|
|
namespace SWP\Component\Bridge\Model; |
16
|
|
|
|
17
|
|
|
use Doctrine\Common\Collections\ArrayCollection; |
18
|
|
|
use Doctrine\Common\Collections\Collection; |
19
|
|
|
use SWP\Component\Common\Model\EnableableTrait; |
20
|
|
|
use SWP\Component\Common\Model\SoftDeletableTrait; |
21
|
|
|
use SWP\Component\Common\Model\TimestampableTrait; |
22
|
|
|
use SWP\Component\Storage\Model\PersistableInterface; |
23
|
|
|
|
24
|
|
|
class Package extends BaseContent implements PackageInterface, PersistableInterface |
25
|
|
|
{ |
26
|
|
|
use TimestampableTrait, SoftDeletableTrait, EnableableTrait; |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* @var Collection |
30
|
|
|
*/ |
31
|
|
|
protected $items; |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* @var string |
35
|
|
|
*/ |
36
|
|
|
protected $body; |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* Package constructor. |
40
|
|
|
*/ |
41
|
|
|
public function __construct() |
42
|
|
|
{ |
43
|
|
|
$this->items = new ArrayCollection(); |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* {@inheritdoc} |
48
|
|
|
*/ |
49
|
13 |
|
public function getItems() |
50
|
|
|
{ |
51
|
13 |
|
return $this->items; |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* {@inheritdoc} |
56
|
|
|
*/ |
57
|
3 |
|
public function setItems(Collection $items) |
58
|
|
|
{ |
59
|
3 |
|
$this->items = $items; |
60
|
3 |
|
} |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* Add item. |
64
|
|
|
* |
65
|
|
|
* @param \SWP\Component\Bridge\Model\Item $item |
66
|
|
|
* |
67
|
|
|
* @return Package |
68
|
|
|
*/ |
69
|
|
|
public function addItem(\SWP\Component\Bridge\Model\Item $item) |
70
|
|
|
{ |
71
|
|
|
if (!$this->items->contains($item)) { |
72
|
|
|
$this->items->add($item); |
73
|
|
|
$item->setPackage($this); |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
return $this; |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
/** |
80
|
|
|
* Remove item. |
81
|
|
|
* |
82
|
|
|
* @param \SWP\Component\Bridge\Model\Item $item |
83
|
|
|
*/ |
84
|
|
|
public function removeItem(\SWP\Component\Bridge\Model\Item $item) |
85
|
|
|
{ |
86
|
|
|
if ($this->items->contains($item)) { |
87
|
|
|
$this->items->removeElement($item); |
88
|
|
|
$item->setPackage(null); |
89
|
|
|
} |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
/** |
93
|
|
|
* @return mixed |
94
|
|
|
*/ |
95
|
13 |
|
public function getBody() |
96
|
|
|
{ |
97
|
13 |
|
return $this->body; |
98
|
|
|
} |
99
|
|
|
|
100
|
|
|
/** |
101
|
|
|
* @param mixed $body |
102
|
|
|
*/ |
103
|
|
|
public function setBody($body) |
104
|
|
|
{ |
105
|
|
|
$this->body = $body; |
106
|
|
|
} |
107
|
|
|
} |
108
|
|
|
|