Common presenter in modules

about a month ago

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

about a month ago

dkorpar
Member | 41
+
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 :)

about a month ago

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

Board footer

Terms and conditions