-
Notifications
You must be signed in to change notification settings - Fork 453
/
AssociationControl.php
146 lines (122 loc) · 3.33 KB
/
AssociationControl.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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
<?php
namespace Concrete\Core\Entity\Express\Control;
use Concrete\Core\Entity\Express\Association;
use Concrete\Core\Form\Context\ContextInterface;
use Concrete\Core\Express\Form\Control\Type\SaveHandler\AssociationControlSaveHandler;
use Concrete\Core\Form\Context\Registry\ControlRegistry;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity
* @ORM\Table(name="ExpressFormFieldSetAssociationControls")
*/
class AssociationControl extends Control
{
const TYPE_HTML_INPUT = 0;
const TYPE_ENTRY_SELECTOR = 5;
/**
* @var \Concrete\Core\Entity\Express\Association
* @ORM\ManyToOne(targetEntity="\Concrete\Core\Entity\Express\Association", inversedBy="controls")
*/
protected $association;
/**
* @ORM\Column(type="string", nullable=true)
*/
protected $association_entity_label_mask;
/**
* The association selector mode (one of the self::TYPE_... constants).
*
* @ORM\Column(type="integer", options={"unsigned": true, "default": 0})
*
* @var int
*/
protected $entry_selector_mode;
/**
* Does the control give us the ability to reorder entries in the association?
*
* @ORM\Column(type="boolean")
*/
protected $enable_entry_reordering = false;
public function __construct()
{
$this->entry_selector_mode = self::TYPE_HTML_INPUT;
}
/**
* @return mixed
*/
public function getAssociationEntityLabelMask()
{
return $this->association_entity_label_mask;
}
public function getControlView(ContextInterface $context)
{
$registry = \Core::make(ControlRegistry::class);
return $registry->getControlView($context, 'express_control_association', [
$this,
]);
}
/**
* @param mixed $association_entity_label_mask
*/
public function setAssociationEntityLabelMask($association_entity_label_mask)
{
$this->association_entity_label_mask = $association_entity_label_mask;
}
/**
* @return int
*/
public function getEntrySelectorMode()
{
return $this->entry_selector_mode;
}
/**
* @param int $entry_selector_mode
*/
public function setEntrySelectorMode($entry_selector_mode)
{
$this->entry_selector_mode = $entry_selector_mode;
}
/**
* @return Association
*/
public function getAssociation()
{
return $this->association;
}
/**
* @param mixed $association
*/
public function setAssociation($association)
{
$this->association = $association;
}
public function getControlSaveHandler()
{
return new AssociationControlSaveHandler();
}
public function getControlLabel()
{
return $this->getAssociation()->getTargetEntity()->getName();
}
public function getType()
{
return 'association';
}
public function getExporter()
{
return new \Concrete\Core\Export\Item\Express\Control\AssociationControl();
}
/**
* @return mixed
*/
public function enableEntryReordering()
{
return $this->enable_entry_reordering;
}
/**
* @param mixed $enable_entry_reordering
*/
public function setEnableEntryReordering($enable_entry_reordering)
{
$this->enable_entry_reordering = $enable_entry_reordering;
}
}