[TYPO3-mvc] Models and logic

Toke Herkild th at t3cms.dk
Mon Apr 16 13:28:33 CEST 2012


Hi,

Well, if you're creating a survey, you might want to compare the number 
of questions in the survey to the number of answers given from the 
actual user, inorder to get a persentage of the completion of the survey.

This you wouldn't want to save in the DB as this isnt really anything 
you'd need there, and it'll change rapidly anyway.

My question is: how do the reflection and autoload react to getters and 
setters in a Domain Model which do not have a corresponding TCA field ?

I'm just trying to figure out how to get the models doing more of the 
stuff which is model logick instead of having it done in the controller 
or view.

EG:

function aModelGetState(){
   $res = array();
   $this->getChildren()->rewind();
   while($this->getChildren()->current->valid()){
     $cur = $this->getChildren()->current();
     $res['children'][$cur->getUid()] = $cur->getState();
   }
   return $res;
}

I know simplified, but should make my question clearer.

Regards,
Toke Herkild

Den 16-04-2012 10:25, Frank Gerards skrev:
> Hi,
>
> +1 with TIM...
> to be more concrete:
> DB-related methods shouldn't be handled by a model imho.
>
> Children of a model are normally referred in a model-property of type Tx_Extbase_...._ObjectStorage.
> What exactly do you mean with "state of completion" and "state" ?
>
> Persistence mechanisms like the persistAll() method are built-in features of extbase.
>
> Greetz,
> frank
>
>
> -----Ursprüngliche Nachricht-----
> Von: typo3-project-typo3v4mvc-bounces at lists.typo3.org [mailto:typo3-project-typo3v4mvc-bounces at lists.typo3.org] Im Auftrag von Toke Herkild
> Gesendet: Montag, 16. April 2012 10:03
> An: typo3-project-typo3v4mvc at lists.typo3.org
> Betreff: [TYPO3-mvc] Models and logic
>
> Hi all,
>
> Having started using Extbase, I've come to the following question:
>
> Is it possible to add non DB logic to a model ?
>
> Often when doing a MVC project you often got operations which are not really DB logic, but still is part of the model and not the controller, nor the view, but you need those operations inorder for the view to do the right thing.
>
> EG: if you have a larger relational three, and you need a combined state of it's completion. you'd have to parse through the different states of the model and it's children, and return an array, containing the total state.
> ex: this->view->assign('state', $TModel->getState());
>
> Regards
> Toke Herkild
> _______________________________________________
> TYPO3-project-typo3v4mvc mailing list
> TYPO3-project-typo3v4mvc at lists.typo3.org
> http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-project-typo3v4mvc



More information about the TYPO3-project-typo3v4mvc mailing list