[TYPO3-mvc] ExtBase concept question about models and passing objects
Andrea Schmuttermair
abo at schmutt.de
Wed May 15 12:29:03 CEST 2013
Hi there,
I have a problem with designing ExtBase Models, and I think it is more
a problem about understanding the concept.
So this is the task:
1) action new -> input form, fills the model: contact
2) action create -> store to database in table contact
if create is successfull: redirect to process
3) action process
I have security sensitive data in contact from step 1).
In Step 2, I store them to database.
This is how it works right now, I redirect to process. I adding all
needed data directly in an array:
/**
* action create
*
* @dontverifyrequesthash
* @param Tx_MyExt_Domain_Model_Contact $newData
* @validate $newData Tx_MyExt_Domain_Validator_ContactValidator
* @return void
*/
public function createAction($newData) {
$insert = $this->contactRepository->insertCrypted($newData);
if ($insert) {
$this->flashMessageContainer->add('Added contact to
database successfully.','',t3lib_Flashmessage::OK);
$this->redirect('process','Contact','myext',array(
'firstname' => $newData->getConsumerFirstname(),
'lastname' => $newData->getConsumerLastname(),
'contactId' => $newData->getContactId(),
));
} else {
$this->flashMessageContainer->add('Could not add contact
to database','',t3lib_Flashmessage::ERROR);
$this->redirect('new');
}
}
If it was pure PHP, I can imagine 2 better solutions:
a) define a new Model "contactSanitized" that can be created from "contact"
function getContactSantizied(){
$obj = new contactSanitized($this->firstname,$this->lastname,...);
return $obj;
}
b) remove sensitive Data from Contact, and then pass newData object:
function removeSensitive(){
$this->bankaccount="";
...
}
I tried Nr. b) already, but got an Exception about persistence, even
the suggested "persistAll" did not work. And I am not sure, if this
function will really remove sensitive data from the object.
About a) creating a 2nd Model: this will be a model without database
table, its use is only for holding and passing data.
Now if I place it within Classes/Domain/Model I have no idea what
ExtBase Magic will do with that model? Will it try to find a a table?
And how it will be passed in browser as it has no UID?
As you can see, I am not deep enough in the Extbase Model and
persistance concept to understand and find a good solution. Any hints
would be great, even if it needs a redesign.
TYPO3 Version: 4.5.25
ExtBase: 1.3.4
Best regards,
Andrea
More information about the TYPO3-project-typo3v4mvc
mailing list