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

g4-lisz at tonarchiv.ch g4-lisz at tonarchiv.ch
Tue Nov 15 16:16:11 CET 2011


On 15.11.2011 15:50, Roland wrote:
> Hello everybody,
>
> I built an extbase extension with the extension builder. it has 20 
> objects: 2 of them ar "Brand" and "Product".
>
> These 2 objects are both aggregate roots and n:1-associated with each 
> other.
>
> The only fe-plugin outputs this:
>
> + list of all products
> + list of all products of a specific brand
> + list of all products of a specific producer
> + list of all products of a specific type
> + details of a specific product
>
> Therefore i have implemented these methods in ProductRepository.php:
>
> + findByBrand()
> + findByProducer()
> + findByType()
>
> In ProduktController.php the products that should be displayed are 
> assigned to the view (via URL-parameters and a switch statement).
>
> This already works!
>
> MY PROBLEM WITH THE LIST OF PRODUCTS OF A SPECIFIC BRAND: the name of 
> the brand and an descriptive text to the brand must be output right 
> before the list.
>
> The object "Brand" already has the attributes "name" and "text".
>
> Unfortunatelly i don't know how to get this data into the Fluid template.
>
> I already tried zu inject the BrandRepository into the 
> ProductController, so that the ProductController would have access to 
> the data of the ProductRepository and the BrandRepository. It did not 
> work. "name" and "text" was NOT output.
>
> does anybody have a tipp?
>
> Kind regards.
>
> Roland

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();

what exactly does "does not wok" mean?

cheers,
till


More information about the TYPO3-project-typo3v4mvc mailing list