[TYPO3-mvc] Dependency Injection fails only in models

Christian Peters chp at digitale-avantgarde.com
Thu Mar 22 15:29:59 CET 2012


Thank you.

First, I'm having a new problem that I'm trying to solve: Extbase only
stores empty values in the database. Again, I have no idea why :(

However: Validation is not really in option, because it throws an error.
But it's not an error, it's just a decision that I want to make (if this
already exists, use the existing one (reference it), if not use the given
one). I don't think it would be a good idea to solve logical decisions with
throwing errors ...; having it in the controller would make my app unDRY,
as there are multiple controllers accessing the model (the importing
service and the original model controller). Maybe it'd be an idea to merge
the controllers or move the creation logic to someplace else.

Thank you.


2012/3/22 Bastian Waidelich <bastian at typo3.org>

> Christian Peters wrote:
>
>  Coming from TYPO3, i was used initiating objects via "new"; which is not
>> supported by Extbase.
>>
>
> Right, Extbase can't "hook" into the new keyword (this is possible in
> FLOW3 because we have the proxy generation there).
> BTW: Elsewhere in TYPO3 you should avoid the new keyword too and use
> t3lib_div::makeInstance() instead - otherwise the XCLASS and
> t3lib_singleton mechanisms are disabled.
>
>
>  *One final question: *Does dependency injection work, if I receive Models
>> through a Repository?
>>
>
> Yes.
>
>
>
>  @Frank: How would you suggest to solve the described problem, if you do
>> recommend to not use repositories in models (you have a point there)
>>
>
> In general it is *not* violating MVC or DDD concepts if you have
> repositories inside a model (we have that in the Blog example, too). But it
> might save you hassle if you can avoid it.
> For avoiding duplicate entries - I would probably rather check this in the
> controller or, transparently, with object validation.
>
> Best,
>
> --
> Bastian
>
> ______________________________**_________________
> TYPO3-project-typo3v4mvc mailing list
> TYPO3-project-typo3v4mvc@**lists.typo3.org<TYPO3-project-typo3v4mvc at lists.typo3.org>
> http://lists.typo3.org/cgi-**bin/mailman/listinfo/typo3-**
> project-typo3v4mvc<http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-project-typo3v4mvc>
>
>


More information about the TYPO3-project-typo3v4mvc mailing list