Jump to content

Prestashop module with Symfony cant find the Admin controller


Recommended Posts

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

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.

  • Like 1
Link to comment
Share on other sites

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 😁

  • Like 1
Link to comment
Share on other sites

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...