Problem when declaring an association inside a plugin in Cakephp 4

51 Views Asked by At

I'm creating a plugin RubriquesManager in which there are the 2 associated Tables Rubriques and Blocs.

Rubriques hasmany Blocs

Blocs belongsTo Rubriques

When Rubriques and Blocs were not in the RubriquesManager all worked well but now there are, I have the following error inside BlocsTable::initialization() : Table class for alias Rubriques could not be found.

Here's my code :

// in plugin/RubriquesManager/Model/Table/BlocsTable.php
namespace RubriquesManager\Model\Table;

class BlocsTable extends AbstractBlocsTable
{
    public function initialize(array $config): void
        {
            parent::initialize($config);

            $this->belongsTo('RubriquesManager.Rubriques');

            $rubriques = $this->Rubriques->find(); // Trigger the error : "Table class for alias Rubriques could not be found."
            // [...]
        }

Anyone could help me to understand what's going on please ?

0

There are 0 best solutions below