Skip to content

Using tables from another plugin breaks links #326

@mehov

Description

@mehov
public function initialize(): void
{
    parent::initialize();

    $this->loadComponent('Flash');

    $this->loadComponent('Crud.Crud', [
        'actions' => [
            'Crud.Index',
            'Crud.View',
            'Crud.Add',
            'Crud.Edit',
            'Crud.Delete',
            'Crud.Lookup',
        ],
        'listeners' => [
            // New listeners that need to be added:
            'CrudView.View',
            'Crud.Redirect',
            'Crud.RelatedModels',
        ]
    ]);
    $this->Crud->useModel('MyOtherPluginWithTables.'.$this->Crud->model()->getAlias());
}

Results in:

Missing Route
Cake\Routing\Exception\MissingRouteException
Error A route matching array ( 'plugin' => 'MyOtherPluginWithTables', 'controller' => 'Customers', 'action' => 'view', 0 => 1, 'prefix' => 'Backend', '_ext' => NULL, ) could not be found.

The plugin alias is being automatically picked up from the table name in dot notation here:

$associationConfiguration[$type][$assocKey]['plugin'] = pluginSplit($association->getClassName())[0];

Using it in link generation has been introduced in #138

I looked at the code and there doesn't seem to be an obvious way to tell the system that while I use the table from another plugin, the links shouldn't refer to it.

I'm hoping there's a way to somehow pass some flag through in an event callback of some kind?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions