I am creating a plugin that I want integrated within the admin section of my application. My application structure for the admin section looks like this:
src/Controller/Admin/AdminsController.php
src/Controller/Admin/ProductsController.php
src/Controller/Admin/BlogsController.php
AdminsController.php looks like this:
namespace App\Controller\Admin;
use App\Controller\AppController;
use Cake\Event\Event;
use Cake\Network\Exception\ForbiddenException;
class AdminsController extends AppController{
And my Admin controllers, ie BlogsController.php looks like this:
namespace App\Controller\Admin;
use App\Controller\Admin\AdminsController;
class BlogsController extends AdminsController {
My plugin has a FeedbacksController that looks just like the Blogs Controller above, which also uses AdminsController from the application: plugin/AkkaFeedback/src/Controller/Admin/FeedbacksController.php
namespace App\Controller\Admin;
use App\Controller\Admin\AdminsController;
class FeedbacksController extends AdminsController {`
Also, within my plugin I have plugin/AkkaFeedback/src/Controller/FeedbacksController.php
My Intention is to have /admin/feedbacks point to this controller. Is this even possible within CakePHP? I have tried many possibilities without success. Here is what I have tried as well as others without success:
Router::prefix('admin', function ($routes) {
$routes->connect('/', ['controller' => 'Dashboards', 'action' => 'index']);
$routes->connect('/feedbacks', ['plugin' => 'AkkaFeedback', 'controller' => 'Feedbacks', 'action' => 'index']);
// I have tried this
//$routes->connect('/feedbacks', ['plugin' => 'AkkaFeedback', 'controller' => 'Feedbacks', 'action' => 'index', 'prefix' => 'admin']); // I have also tried this
// And this without succcess
// /admin/akka_feedback/feedbacks
// $routes->plugin('AkkaFeedback', function ($routes) {
// $routes->connect('/:controller');
// });
$routes->fallbacks('InflectedRoute');
});
The error I get is: Controller class Feedbacks could not be found., but there is a Feedbacks class, both in Controller and Controller/Admin within the plugin.
Not sure what else to try. Any ideas would be appreciated!