laminas-api-tools / api-tools-admin

Laminas API Tools Admin module
https://api-tools.getlaminas.org/documentation
BSD 3-Clause "New" or "Revised" License
13 stars 21 forks source link

Can't find controller using LazyControllerAbstractFactory with admin tool created RPC #96

Open nomadinteractif opened 9 months ago

nomadinteractif commented 9 months ago

### Bug Report

Can't generate $requestedName Class in Laminas\Mvc\Controller\LazyControllerAbstractFactory [102]

$reflectionClass = new ReflectionClass($requestedName);

Q A
Version(s) 1.5.1 dev

Summary

I would like to use LazyControllerAbstractFactory for multiple Rpc Controller with same behavior.

Current behavior

When creating a new Rpc the mapping in the module.config.php will be generated like so:

//...
 'controllers' => [
    'factories' => [
        'Clients\\V1\\Rpc\\GetClientDetail\\Controller' => \Clients\V1\Rpc\GetClientDetail\GetClientDetailControllerFactory::class
    ],
],
// ...
    'clients.rpc.get-client-detail' => [
        'type' => 'Segment',
        'options' => [
            'route' => '/clients/details',
            'defaults' => [
                'controller' => 'Clients\\V1\\Rpc\\GetClientDetail\\Controller',
                'action' => 'getClientDetail',
            ],
        ],
    ],
// ...  and more using same class mapping  'Clients\\V1\\Rpc\\GetClientDetail\\Controller'

Than in Laminas\Mvc\Controller\LazyControllerAbstractFactory [102]

// $requestedName = "Clients\V1\Rpc\GetClientDetail\Controller" // same used as in the module.config.php
$reflectionClass = new ReflectionClass($requestedName); // throw ReflexionException "Class "Clients\V1\Rpc\GetClientDetail\Controller" does not exist"

How to reproduce

Simply use any Controller class mapping in config and $reflectionClass = new ReflectionClass("My\V1\Rpc\Module\Controller");

Expected behavior

I have tried to find/replace

'Clients\\V1\\Rpc\\GetClientDetail\\Controller'

with

\Clients\V1\Rpc\GetClientDetail\GetClientDetailController::class 

in all the the module.config.php and this resolve the problem.

Thank you