@@ 244-271 (lines=28) @@ | ||
241 | * @param $fieldSlug |
|
242 | * @return null|FieldType |
|
243 | */ |
|
244 | public function getFieldType($fieldSlug) |
|
245 | { |
|
246 | $locale = config('app.locale'); |
|
247 | ||
248 | $assignment = $this->getAssignment($fieldSlug); |
|
249 | ||
250 | if (!$assignment) { |
|
251 | return null; |
|
252 | } |
|
253 | ||
254 | $type = $assignment->getFieldType(); |
|
255 | ||
256 | if ($assignment->isTranslatable()) { |
|
257 | ||
258 | $entry = $this->translateOrDefault($locale); |
|
259 | ||
260 | $type->setLocale($locale); |
|
261 | } else { |
|
262 | $entry = $this; |
|
263 | } |
|
264 | ||
265 | $type->setEntry($entry); |
|
266 | ||
267 | $type->setValue($this->getFieldValue($fieldSlug)); |
|
268 | $type->setEntry($this); |
|
269 | ||
270 | return $type; |
|
271 | } |
|
272 | ||
273 | /** |
|
274 | * Get the field type query. |
@@ 112-137 (lines=26) @@ | ||
109 | * @param string $key |
|
110 | * @param mixed $value |
|
111 | */ |
|
112 | public function setAttribute($key, $value) |
|
113 | { |
|
114 | if (!$parent = $this->getParent()) { |
|
115 | return null; |
|
116 | } |
|
117 | ||
118 | /* @var AssignmentInterface $assignment */ |
|
119 | $assignment = $parent->getAssignment($key); |
|
120 | ||
121 | if (!$assignment) { |
|
122 | ||
123 | parent::setAttribute($key, $value); |
|
124 | ||
125 | return; |
|
126 | } |
|
127 | ||
128 | $type = $assignment->getFieldType($this); |
|
129 | ||
130 | $type->setEntry($this); |
|
131 | $type->setLocale($this->locale); |
|
132 | ||
133 | $accessor = $type->getAccessor(); |
|
134 | $modifier = $type->getModifier(); |
|
135 | ||
136 | $accessor->set($modifier->modify($value)); |
|
137 | } |
|
138 | ||
139 | /** |
|
140 | * Fire field type events. |