[TYPO3-mvc] getting the arguments of the form?
Stig Nørgaard Færch
snf at dkm.dk
Tue Feb 21 08:53:08 CET 2012
> Interesting to know is that the setter of a property is only called when
> the respective property was changed, the unchanged properties are
> initialized with some magic.
> You could make use of that by adding some getter that returns all
> changed fields:
>
> protected $modifiedProperties = array();
>
> public function setStreetName($streetName) {
> $this->modifiedProperties['streetName'] = $streetName;
> $this->streetName = $streetName;
> }
>
> public function getModifiedProperties() {
> return $this->modifiedProperties;
> }
>
> While this seems cleaner code-wise, it's still a bit tedious and
> error-prone (you have to remember to add the line for every new property).
Could I do something like this, to avoid unwanted errors later on?
public function getModifiedProperty($propertyName) {
$listOfRegisteredModifiedPropeties = array('fullName');
if(!in_array($propertyName, $listOfRegisteredModifiedPropeties) {
throw new Tx_Fluid_Core_Exception('Tried to get modified property "' .
$key . '", but the property name is not registered.', 1236080693);
} else {
return $this->modifiedProperties[$propertyName];
}
}
/Stig
More information about the TYPO3-project-typo3v4mvc
mailing list