how to use another presenter with current presenter

simeon2022
Member | 6
+
0
-

Hello i just want to know if theres another way to call a presenter with another presenter
i have shopPresenter and to perform a low couple concept i try to create a ProductPresenter to set a cohesion on specific presenter
and then when i try to use ProductPresntr in ShopPrsenter using DI
it appear error because its need to set also a parameter of ProductPresntr(another DI, DI2, DI3)
and it wont work. please help me here is my sample code

i also read an article about autowired and some DI

https://snipboard.io/kobO47.jpg

Rick Strafy
Nette Blogger | 54
+
+1
-

There is no way yo do that, it's not well designed and against MVC principles, you should have some service that you can retrieve products from and inject it in both presenters. You shouldn't have business logic in your presenter (controller layer), presenters just connect http requests with model services and logic.

Kamil Valenta
Member | 610
+
+1
-

Private $product must be a model, not a presenter.

simeon2022
Member | 6
+
0
-

Rick Strafy wrote:

There is no way yo do that, it's not well designed and against MVC principles, you should have some service that you can retrieve products from and inject it in both presenters. You shouldn't have business logic in your presenter (controller layer), presenters just connect http requests with model services and logic.

thanks for that response sir @RickStrafy i will be more in that solution