Commit | Line | Data |
---|---|---|
19b53e5b C |
1 | <?php |
2 | ||
380f3545 TO |
3 | /* |
4 | +--------------------------------------------------------------------+ | |
5 | | CiviCRM version 5 | | |
6 | +--------------------------------------------------------------------+ | |
f299f7db | 7 | | Copyright CiviCRM LLC (c) 2004-2020 | |
380f3545 TO |
8 | +--------------------------------------------------------------------+ |
9 | | This file is a part of CiviCRM. | | |
10 | | | | |
11 | | CiviCRM is free software; you can copy, modify, and distribute it | | |
12 | | under the terms of the GNU Affero General Public License | | |
13 | | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. | | |
14 | | | | |
15 | | CiviCRM is distributed in the hope that it will be useful, but | | |
16 | | WITHOUT ANY WARRANTY; without even the implied warranty of | | |
17 | | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | | |
18 | | See the GNU Affero General Public License for more details. | | |
19 | | | | |
20 | | You should have received a copy of the GNU Affero General Public | | |
21 | | License and the CiviCRM Licensing Exception along | | |
22 | | with this program; if not, contact CiviCRM LLC | | |
23 | | at info[AT]civicrm[DOT]org. If you have questions about the | | |
24 | | GNU Affero General Public License or the licensing of CiviCRM, | | |
25 | | see the CiviCRM license FAQ at http://civicrm.org/licensing | | |
26 | +--------------------------------------------------------------------+ | |
27 | */ | |
28 | ||
29 | /** | |
30 | * | |
31 | * @package CRM | |
f299f7db | 32 | * @copyright CiviCRM LLC (c) 2004-2020 |
380f3545 TO |
33 | * $Id$ |
34 | * | |
35 | */ | |
36 | ||
37 | ||
19b53e5b C |
38 | namespace Civi\Api4\Service\Spec; |
39 | ||
40 | class CustomFieldSpec extends FieldSpec { | |
41 | /** | |
42 | * @var int | |
43 | */ | |
44 | protected $customFieldId; | |
45 | ||
46 | /** | |
47 | * @var int | |
48 | */ | |
49 | protected $customGroup; | |
50 | ||
51 | /** | |
52 | * @var string | |
53 | */ | |
54 | protected $tableName; | |
55 | ||
56 | /** | |
57 | * @var string | |
58 | */ | |
59 | protected $columnName; | |
60 | ||
61 | /** | |
62 | * @inheritDoc | |
63 | */ | |
64 | public function setDataType($dataType) { | |
65 | switch ($dataType) { | |
66 | case 'ContactReference': | |
67 | $this->setFkEntity('Contact'); | |
68 | $dataType = 'Integer'; | |
69 | break; | |
70 | ||
71 | case 'File': | |
72 | case 'StateProvince': | |
73 | case 'Country': | |
74 | $this->setFkEntity($dataType); | |
75 | $dataType = 'Integer'; | |
76 | break; | |
77 | } | |
78 | return parent::setDataType($dataType); | |
79 | } | |
80 | ||
81 | /** | |
82 | * @return int | |
83 | */ | |
84 | public function getCustomFieldId() { | |
85 | return $this->customFieldId; | |
86 | } | |
87 | ||
88 | /** | |
89 | * @param int $customFieldId | |
90 | * | |
91 | * @return $this | |
92 | */ | |
93 | public function setCustomFieldId($customFieldId) { | |
94 | $this->customFieldId = $customFieldId; | |
95 | ||
96 | return $this; | |
97 | } | |
98 | ||
99 | /** | |
100 | * @return int | |
101 | */ | |
102 | public function getCustomGroupName() { | |
103 | return $this->customGroup; | |
104 | } | |
105 | ||
106 | /** | |
107 | * @param string $customGroupName | |
108 | * | |
109 | * @return $this | |
110 | */ | |
111 | public function setCustomGroupName($customGroupName) { | |
112 | $this->customGroup = $customGroupName; | |
113 | ||
114 | return $this; | |
115 | } | |
116 | ||
117 | /** | |
118 | * @return string | |
119 | */ | |
120 | public function getCustomTableName() { | |
121 | return $this->tableName; | |
122 | } | |
123 | ||
124 | /** | |
125 | * @param string $customFieldColumnName | |
126 | * | |
127 | * @return $this | |
128 | */ | |
129 | public function setCustomTableName($customFieldColumnName) { | |
130 | $this->tableName = $customFieldColumnName; | |
131 | ||
132 | return $this; | |
133 | } | |
134 | ||
135 | /** | |
136 | * @return string | |
137 | */ | |
138 | public function getCustomFieldColumnName() { | |
139 | return $this->columnName; | |
140 | } | |
141 | ||
142 | /** | |
143 | * @param string $customFieldColumnName | |
144 | * | |
145 | * @return $this | |
146 | */ | |
147 | public function setCustomFieldColumnName($customFieldColumnName) { | |
148 | $this->columnName = $customFieldColumnName; | |
149 | ||
150 | return $this; | |
151 | } | |
152 | ||
153 | } |