Common presenter in modules

Notice: This thread is very old.
pistols
Member | 26
+
0
-

Hello There, I have these modules in my app

admin, dealer

No there is an customer functionality a did for dealer. it has its presenter

dealerModule/presenters/CustomerPresenter.php

and his templates

dealerModule/templates/Customer/default.latte
dealerModule/templates/Customer/detail.latte

So far so good.

Now this CustomerPresenter functionality must be implemented into the admin module as well.

What is the best practice for this? I dont want to just copy the presenter and its templates.

Second thing I tried to move the presenter to a BasePresenters folder and just inherit its code to the presenter in the dealerModule. That worked partialy. It failed on the missing templates.

Thanks you for your suggestions

dkorpar
Member | 136
+
0
-

You need to set templates directory as well in BasePresenter…
you can override formatTemplateFiles function which returns array of possible location…
so something like:

	public function formatTemplateFiles()
	{
$locations = parent::formatTemplateFiles();
$locations[] = __DIR__ . "/templates/$this->view.latte";
return $locations;
	}

ps I wrote code here, did not test it, but you get the point :)

pistols
Member | 26
+
0
-

Yees!, I had the same idea but I did it a bit differently. at the end of the day I used your way :)

Thanks