|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* This file is part of the Zikula package. |
|
5
|
|
|
* |
|
6
|
|
|
* Copyright Zikula Foundation - http://zikula.org/ |
|
7
|
|
|
* |
|
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
9
|
|
|
* file that was distributed with this source code. |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
namespace Zikula\BlocksModule\Entity; |
|
13
|
|
|
|
|
14
|
|
|
use Zikula\Core\Doctrine\EntityAccess; |
|
15
|
|
|
use Doctrine\ORM\Mapping as ORM; |
|
16
|
|
|
|
|
17
|
|
|
/** |
|
18
|
|
|
* BlockPlacement entity class. |
|
19
|
|
|
* |
|
20
|
|
|
* @ORM\Entity |
|
21
|
|
|
* @ORM\Table(name="block_placements",indexes={@ORM\Index(name="bid_pid_idx",columns={"bid","pid"})}) |
|
22
|
|
|
* |
|
23
|
|
|
* @ORM\HasLifecycleCallbacks |
|
24
|
|
|
*/ |
|
25
|
|
|
class BlockPlacementEntity extends EntityAccess |
|
26
|
|
|
{ |
|
27
|
|
|
/** |
|
28
|
|
|
* The id of the block postion |
|
29
|
|
|
* |
|
30
|
|
|
* @ORM\Id |
|
31
|
|
|
* @ORM\ManyToOne(targetEntity="Zikula\BlocksModule\Entity\BlockPositionEntity", inversedBy="placements") |
|
32
|
|
|
* @ORM\JoinColumn(name="pid", referencedColumnName="pid", nullable=false) |
|
33
|
|
|
*/ |
|
34
|
|
|
private $position; |
|
35
|
|
|
|
|
36
|
|
|
/** |
|
37
|
|
|
* The id of the block |
|
38
|
|
|
* |
|
39
|
|
|
* @var \Zikula\BlocksModule\Entity\BlockEntity |
|
40
|
|
|
* @ORM\Id |
|
41
|
|
|
* @ORM\ManyToOne(targetEntity="Zikula\BlocksModule\Entity\BlockEntity", inversedBy="placements") |
|
42
|
|
|
* @ORM\JoinColumn(name="bid", referencedColumnName="bid", nullable=false) |
|
43
|
|
|
*/ |
|
44
|
|
|
private $block; |
|
45
|
|
|
|
|
46
|
|
|
/** |
|
47
|
|
|
* The sort order of the block within the position |
|
48
|
|
|
* |
|
49
|
|
|
* @ORM\Column(type="integer") |
|
50
|
|
|
*/ |
|
51
|
|
|
private $sortorder; |
|
52
|
|
|
|
|
53
|
|
|
/** |
|
54
|
|
|
* constructor |
|
55
|
|
|
*/ |
|
56
|
|
|
public function __construct() |
|
57
|
|
|
{ |
|
58
|
|
|
$this->sortorder = 0; |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
/** |
|
62
|
|
|
* @return BlockPositionEntity |
|
63
|
|
|
*/ |
|
64
|
|
|
public function getPosition() |
|
65
|
|
|
{ |
|
66
|
|
|
return $this->position; |
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
|
|
public function setPosition(BlockPositionEntity $position = null) |
|
70
|
|
|
{ |
|
71
|
|
|
if ($this->position !== null) { |
|
72
|
|
|
$this->position->removePlacement($this); |
|
73
|
|
|
} |
|
74
|
|
|
|
|
75
|
|
|
if ($position !== null) { |
|
76
|
|
|
$position->addPlacement($this); |
|
77
|
|
|
} |
|
78
|
|
|
|
|
79
|
|
|
$this->position = $position; |
|
80
|
|
|
|
|
81
|
|
|
return $this; |
|
82
|
|
|
} |
|
83
|
|
|
|
|
84
|
|
|
/** |
|
85
|
|
|
* @return BlockEntity |
|
86
|
|
|
*/ |
|
87
|
|
|
public function getBlock() |
|
88
|
|
|
{ |
|
89
|
|
|
return $this->block; |
|
90
|
|
|
} |
|
91
|
|
|
|
|
92
|
|
|
public function setBlock(BlockEntity $block = null) |
|
93
|
|
|
{ |
|
94
|
|
|
if ($this->block !== null) { |
|
95
|
|
|
$this->block->removePlacement($this); |
|
96
|
|
|
} |
|
97
|
|
|
|
|
98
|
|
|
if ($block !== null) { |
|
99
|
|
|
$block->addPlacement($this); |
|
100
|
|
|
} |
|
101
|
|
|
|
|
102
|
|
|
$this->block = $block; |
|
103
|
|
|
|
|
104
|
|
|
return $this; |
|
105
|
|
|
} |
|
106
|
|
|
|
|
107
|
|
|
/** |
|
108
|
|
|
* get the sortorder of the placement |
|
109
|
|
|
* |
|
110
|
|
|
* @return integer the placement |
|
111
|
|
|
*/ |
|
112
|
|
|
public function getSortorder() |
|
113
|
|
|
{ |
|
114
|
|
|
return $this->sortorder; |
|
115
|
|
|
} |
|
116
|
|
|
|
|
117
|
|
|
/** |
|
118
|
|
|
* set the sortorder for the placement |
|
119
|
|
|
* |
|
120
|
|
|
* @param integer $sortorder the placement |
|
121
|
|
|
*/ |
|
122
|
|
|
public function setSortorder($sortorder) |
|
123
|
|
|
{ |
|
124
|
|
|
$this->sortorder = $sortorder; |
|
125
|
|
|
} |
|
126
|
|
|
|
|
127
|
|
|
/** |
|
128
|
|
|
* @ORM\PreRemove |
|
129
|
|
|
*/ |
|
130
|
|
|
public function preRemoveCallback() |
|
131
|
|
|
{ |
|
132
|
|
|
$this->setPosition(null); |
|
133
|
|
|
$this->setBlock(null); |
|
134
|
|
|
} |
|
135
|
|
|
} |
|
136
|
|
|
|