Plugin AppController not loaded by default


#1

I’m trying to load plugin helpers from my plugin called “CustomControls” so I’ve added the following line in my Plugin AppController but nothing happen:

public $helpers = ['Form' => ['templates' => 'CustomControls.app_form']];

When I add the same line into the main AppController of CakePHP root folder, it works so the line is not the problem and in fact, I’ve realized that my Plugin AppController is not even executed.

The code of my Plugin AppController located in “Website\plugins\CustomControls\src\Controller” is:

<?php
namespace App\Controller;

use Cake\Controller\Controller;
use Cake\Event\Event;

class CustomControlsController extends AppController {
    public $helpers = ['Form' => ['templates' => 'CustomControls.app_form']];
            
    public function initialize() {
        parent::initialize();    
    }
}

if someone has an idea of the problem, I will be much appreciate some help.

Thanks!
Ignacio


#2

Hi ! I think your namespace is wrong: it should be something like CustomControls\Controller.

That won’t solve everything, but it’s a good start.


#3

Hi MTancoigne,

Thanks for your reply. You were right, the namespace was not correct and based on your comment, I’ve also realized that another controller was not pointing to the proper namespace neither and I finally, I was able to make it work! :slight_smile: Thanks for your suggestion.

May I ask you an additional thing, is there any way to initialize my plugin appcontroller on demand? I mean, inside another function?

Thanks dude
Ignacio


#4

I don’t think so. You should make component in your plugin with the methods you want to share with other controllers.