Jose Prato Posted June 18, 2023 Share Posted June 18, 2023 Hello people, I need to run specific action after Clear Cache action finish so I need to extend the clearCacheAction module on PrestaShopBundle\Controller\Admin\Configure\AdvancedParameters\PerformanceController, as far I know, we cant override those kind of controllers by the normal way (override folder), I read on PS devdocs that I could do an override for the path using routes.yml file on my custom module folder but after doing the step, the "Class not exists" error throws when I try to clear the cache from Admin Performance config. Is there an example of what I'm trying to achiveve? Thanks in advance! Link to comment Share on other sites More sharing options...
Kogkalidis Posted July 13, 2023 Share Posted July 13, 2023 For the moment I copy the genuine file in my module, make my modifications and then replace genuine <-> modified on install/uninstall. Not the best method but it works 😆 Link to comment Share on other sites More sharing options...
Jose Prato Posted July 16, 2023 Author Share Posted July 16, 2023 On 7/13/2023 at 4:55 AM, Kogkalidis said: For the moment I copy the genuine file in my module, make my modifications and then replace genuine <-> modified on install/uninstall. Not the best method but it works 😆 That would be a bad practice but will work for emergency cases... As an update for this thread, I had to learn about decorating/overriding services and remapping routes to make this work in a 'good practice' way. People just need to follow this doc to learn about. Link to comment Share on other sites More sharing options...
Kogkalidis Posted July 17, 2023 Share Posted July 17, 2023 Yeah but unfortunately I think it is quite bad practise to rename well known procedures. I have experimented with the decoration etc but when Override was like "add some extra stuff in the core class", nowadays Override means "get rid of the core file". 🤮 Moreover the modules section due to retro compatibility reasons have not been entirely deployed based on the new standards. As an outcome when a class or controller has a "use ...." declaration, an override is not possible (learned it the hard way.... ) So I do respect your willingness to obey the rules but I cannot spend weeks for a simple thing. Link to comment Share on other sites More sharing options...
Jose Prato Posted July 17, 2023 Author Share Posted July 17, 2023 7 hours ago, Kogkalidis said: Yeah but unfortunately I think it is quite bad practise to rename well known procedures. I have experimented with the decoration etc but when Override was like "add some extra stuff in the core class", nowadays Override means "get rid of the core file". 🤮 Moreover the modules section due to retro compatibility reasons have not been entirely deployed based on the new standards. As an outcome when a class or controller has a "use ...." declaration, an override is not possible (learned it the hard way.... ) So I do respect your willingness to obey the rules but I cannot spend weeks for a simple thing. Currently Symfony (which is the framework used in the back-office, while front-end is handled by Smarty) allows both extending and overriding classes with those decorators/service override and routes remapping, I had that issue with classes with "use ..." but was solved creating modules with classes mapped with autoloader (just to learn about Composer to know how to generate) and extending core classes if we just need to override just one method instead the whole class, I think this is just OOP knowledge mixed with Symfony skills... I think the hard thing is to understand the structure of config/routes.yml and config/services.yml to achieve your goal, and of course, create the habit to always review the core yml's of Prestashop to know which core service you need to extend Link to comment Share on other sites More sharing options...
joseantgv Posted July 26, 2023 Share Posted July 26, 2023 On 7/13/2023 at 11:55 AM, Kogkalidis said: For the moment I copy the genuine file in my module, make my modifications and then replace genuine <-> modified on install/uninstall. Not the best method but it works 😆 💀💀 Probably you would find an example here https://github.com/PrestaShop/example-modules Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now