[TYPO3-mvc] Use 2 Repositories in 1 Controller?

g4-lisz at tonarchiv.ch g4-lisz at tonarchiv.ch
Tue Nov 15 22:43:32 CET 2011


On 15.11.2011 16:40, Roland wrote:
>> maybe i understood you wrong but the way you described should work.
>>
>> maybe there is some misspelling in the injection method for the brand
>> repository?
>>
>> i see no reason why this should not work when the repository has been
>> injected properly:
>>
>> $this->brandRepository->findByXX();
>
> hi till,
>
> thanks for your answer.
>
> nice to hear, that in my attempt should work - then maybe it really 
> only is a typo that caused it. i will try and report.
>
> after incecting i tried this:
>
> $brand = $this->brandRepository->findByUid(5);
> $this->view->assign('brand', $brand);
>
> > what exactly does "does not wok" mean?
>
> e.g. {brand.name} lead to no output.
>
> kind regards.
>
> roland
>
> ps: "5" was hardcoded only for testing purpose
>
hi roland,

if u use ->findByUid() then an array is returned. if you expect (and 
display) only one object then you could use findOneByUid().

In case of an array you will need a loop over all objects like this:

<f:for each="{brands}" as="brand" >{brand.name}</f:for>

cheers,
till


More information about the TYPO3-project-typo3v4mvc mailing list