kacloudy Posted February 27, 2022 Share Posted February 27, 2022 I am creating a module in Prestashop with Symfony but when I try to access my routes I get this error: The controller for URI "/modules/youtuber/list" is not callable: Class "Myyoutubemc\Controller\YoutubeController" Below is my controller it's located in: /modules/myyotubemc/src/controllers/youtubeController.php ``` <?php namespace Myyoutubemc\Controller; use GuzzleHttp\Subscriber\Redirect; use Myyoutubemc\Entity\YoutubeComment; use Myyoutubemc\Forms\YoutubeType; use PrestaShopBundle\Controller\Admin\FrameworkBundleAdminController; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; class YoutubeController extends FrameworkBundleAdminController { public function demoAction() { return new Response('Hello Youtubers'); // return $this->render('@Modules/your-module/templates/admin/demo.html.twig'); } public function listAction() { $em = $this->getDoctrine()->getManager(); $data = $em->getRepository(YoutubeComment::class)->findAll(); return $this->render( '@Modules/myyoutubemc/templates/admin/list.html.twig', [ 'data' => $data ] ); } } ``` below is my routes located at my_module/config/routes.yml youtube-list: path: youtuber/list methods: [GET] defaults: _controller: 'Myyoutubemc\Controller\YoutubeController::listAction' Link to comment Share on other sites More sharing options...
jmauclair Posted February 28, 2022 Share Posted February 28, 2022 (edited) It's supposed to extends ModuleAdminController You can check the prestashop documentation about modules By the way this guide is quiet detailed : https://blog.floriancourgey.com/2018/05/create-an-admin-for-a-customized-sql-table/ Edited February 28, 2022 by jmauclair (see edit history) 1 Link to comment Share on other sites More sharing options...
Paul C Posted February 28, 2022 Share Posted February 28, 2022 10 minutes ago, jmauclair said: It's supposed to extends ModuleAdminController You can check the prestashop documentation about modules By the way this guide is quiet detailed : https://blog.floriancourgey.com/2018/05/create-an-admin-for-a-customized-sql-table/ He's working on a "modern" controller though, not a legacy one. I'm not expert enough to comment on the above though. Probably clear cache/run composer black magic. I hate the switch to Symphony and would probably still go for a legacy controller if I had the choice. 1 Link to comment Share on other sites More sharing options...
kacloudy Posted February 28, 2022 Author Share Posted February 28, 2022 Thank you guys i extended the ModuleAdminController, I was working on a modern controller but due to time i had to revert to old controller methods and it worked. Thank you all for the replies 1 Link to comment Share on other sites More sharing options...
jmauclair Posted February 28, 2022 Share Posted February 28, 2022 45 minutes ago, Paul C said: He's working on a "modern" controller though, not a legacy one. I'm not expert enough to comment on the above though. Probably clear cache/run composer black magic. I hate the switch to Symphony and would probably still go for a legacy controller if I had the choice. My bad, I’m used to still work with old controllers because it works fine 😁 1 Link to comment Share on other sites More sharing options...
Paul C Posted February 28, 2022 Share Posted February 28, 2022 Guys I have a module that has several admin controllers for functionality that's specific to one client and I keep swerving between whether I should convert it or not. I think you're safe using legacy controllers into PrestaShop 8 so there's probably no rush 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