BjyAuthorize の ACL セットアップをさまざまな状況でそれぞれ使用できるように、モジュールごとにルートを区別する必要がありました。
これには複数の方法がありますが、Jurian Sluimanが示したように、すべてのルートを読み込む (変数が変更されています):
<?php
// $this->services instanceof Zend\ServiceManager\ServiceManager
$config = $this->services->get('Config');
$routes = $config['router']['routes'];
関数内のモジュールごとに後で区別するために、次のように取得できます。
<?php
// $this->services instanceof Zend\ServiceManager\ServiceManager
/**
* Load the Application's active modules.
* @note May need to specify additional modules that may not be
* loaded at this runtime.
*/
$moduleManager = $this->services->get('ModuleManager');
$moduleManager->loadModules();
// Retrieve array of module names.
$modules = $moduleManager->getModules();
// Setup a container for all active routes.
$routes = [];
// Build array of all active routes.
foreach ($modules as $moduleName) {
$module = $moduleManager->getModule($moduleName);
$routes[$moduleName] = array_keys($module->getConfig()['router']['routes']);
}
// Whatever you care to do with them.
echo $routes;