ZF\Apigility\Admin\Model\ModuleModel::detectSourcePathFromModule PHP Method

detectSourcePathFromModule() private method

The path will vary based on: - PSR-0 module generated by Apigility - PSR-4 module generated by Apigility, using ModuleAutoloader - PSR-4 module using Composer autoloading, with Module class under the source tree The first case has been covered since the beginning, and the third has "just worked", but the second causes problems due to the fact that the Module class is in the root of the module (PSR-0 solved this by having that file require the class file within the source tree).
private detectSourcePathFromModule ( string $moduleName, ZF\Apigility\Provider\ApigilityProviderInterface | ZF\Apigility\ApigilityModuleInterface $module ) : string
$moduleName string
$module ZF\Apigility\Provider\ApigilityProviderInterface | ZF\Apigility\ApigilityModuleInterface
return string
    private function detectSourcePathFromModule($moduleName, $module)
    {
        $r = new ReflectionObject($module);
        $path = dirname($r->getFileName());
        $ds = sprintf('[/%s]', preg_quote('\\'));
        $pattern = sprintf('#%ssrc(%s%s)?$#', $ds, $ds, preg_quote($moduleName));
        if (!preg_match($pattern, $path)) {
            $path .= DIRECTORY_SEPARATOR . 'src';
        }
        return $path;
    }