Skip to content

Commit 3cbe9e6

Browse files
author
Patrick Rathje
committed
Dynamic setter
1 parent 0cbc8ff commit 3cbe9e6

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

Model/Translatable/TranslatableMethods.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@ public function translateProperty($name) {
160160
return $this->translate($this->getDefaultLocale())->$functionName();
161161
}
162162
}
163+
163164
/**
164165
* @param $name
165166
* proxy getter for translation values
@@ -168,4 +169,14 @@ public function translateProperty($name) {
168169
public function __get($name) {
169170
return $this->translateProperty($name);
170171
}
172+
173+
/**
174+
* @param $name
175+
* proxy setter for translation values
176+
* @return mixed
177+
*/
178+
public function __set($name, $value) {
179+
$functionName = 'set' . ucfirst($name);
180+
$value = $this->translate()->$functionName($value);
181+
}
171182
}

0 commit comments

Comments
 (0)