Open Restless-ET opened 9 years ago
Maybe you put in app/Resources/AdmingeneratorGeneratorBundle/templates/CommonAdmin/ExcelAction/ExcelBuilderAction.php.twig
a copy of the original ExcelBuilderAction.php.twig
and add replace line 15 with:
use {{ namespace }}\Controller{{ prefix ? "\\" ~ prefix : "" }}\ListController as CustomListController;
class ExcelController extends CustomListController
at the top.
This should trigger the symfony2 bundle inheritance and use your custom template to generate ExcelBuilder controller and the custom use
should point to the correct (customized) controller.
Hi @loostro
First of all, thanks for your reply.
I've tried your suggestion but unfortunately it does not seem to work. :( The custom template is not used.
Any ideas?
I can always make the change in the ExcelBuilderAction.php.twig
on my fork but I was trying to avoid that.
@Restless-ET thats weird.. i think you should go to symfony2 docs and study the bundle inheritance and check why this does not work.. i'm sure there is a way to use bundle inheritance to overwrite these templates
@loostro @Restless-ET I think we might be able to solve with a simple change in the ExcelBuilderAction.php.twig
template. If we change line 15 from
class ExcelController extends ListController
into:
class ExcelController extends \{{ namespace_prefix }}\{{ bundle_name }}\Controller\{{ builder.generator.BaseGeneratorName }}\ListController
I think we have exactly what Restless-ET needs, without breaking anything inside the bundle for others. I've tried it in my development environment and nothings breaks, but I do not have the usage as described in this ticket. @Restless-ET: Can you test this solution?
If this works, I can create a PR for all branches. @loostro, what's your opinion?
@loostro I find that awkward as well since I've already used that method to override views
from AvocodeFormExtensionsBundle
. Still I'm not being able to make it work for the templates
folder from this bundle. :-/
@bobvandevijver That does indeed work, I've already tried that before. I was just trying to find another solution because I didn't know if that would be a wanted/desired change on the bundle main repository code.
But if that change is ok by @loostro I don't mind create the PRs as well.
@Restless-ET Please take a look at this doc, you're probably missing the templates_dirs
in your config.yml
.
However, I still think that the code change is nice to do, as this is the only template which extends an action from the bundle itself (in this way at least).
Ohh.. I see.. now it works. :-) Thanks @bobvandevijver
Also, :+1: for the code change on the bundle.
Hi there,
Is there a way for the generated
ExcelController
to extend from the user projectListController
class instead of using the baseListController
created on thecache
folder?As this is right now.. if we override, for instance, the
processQuery($query)
orprocessFilters($query)
method on ourListController
class those changes won't be taken in consideration by theExcelController
thus forcing us to either:ExcelController
by copying all the functions from the generated one on our custom project and make it extend ourListController
(thus making the excel builder in our*-generator.yml
file obsolete );ListController
into ourExcelController
class ( thus having to maintain the same code in two different places :\ ).Any ideas @loostro , @bobvandevijver ?
Regards