[TYPO3-mvc] passing on demand object to various views/formats
Nikolas Hagelstein
lists at shr.cc
Wed Mar 2 10:31:13 CET 2011
Hi,
i use to solve it this way:
public function indexAction(array $demandOverwrite = NULL) {
$demand = $this->getDemandFromSettings();
if ($demandOverwrite) {
$demand = $this->overwriteDemand($demand, $overwriteDemand)
}
$records = $myRepository->findDemanded($demand);
...
}
sampe overrride function:
---
protected function overwriteDemandObject($demand, $overwriteDemand) {
foreach ($overwriteDemand as $propertyName => $propertyValue) {
// @todo: consider adding an per mode access check
$setterMethod = 'set' . ucfirst($propertyName);
if (method_exists(Tx_News2_Domain_Model_NewsDemand, $setterMethod)) {
$demand->{$setterMethod}($propertyValue);
}
}
return $demand;
}
---
sample link:
----
<f:link.action pageUid="{listPid}" arguments="{overwriteDemand:{year:
year, month: month, dateField: dateField}}">
----
1. Don't pass arroud the whole demand object. This is not possible
trough links due to hmac issues (even if you disable it).
2. Insteand pass arround an "overwrite" deman array which consists of
key/properties you whish to manipulate.
3. usually you got an initial i.e. default demand (generated from
settings in my example- change it to your needs).
4. consider adding access checks withhin the override function. You
probably don't want all properties to be overwritable.
Hope this helps,
Cheers,
Nikolas
More information about the TYPO3-project-typo3v4mvc
mailing list