Acl\AclExtras::_getNamespace PHP Method

_getNamespace() protected method

Get the namespace for a given class.
protected _getNamespace ( string $className, string $pluginPath = null, string $prefixPath = null ) : string
$className string The class you want a namespace for.
$pluginPath string The plugin path.
$prefixPath string The prefix path.
return string
    protected function _getNamespace($className, $pluginPath = null, $prefixPath = null)
    {
        $namespace = preg_replace('/(.*)Controller\\//', '', $className);
        $namespace = preg_replace('/\\//', '\\', $namespace);
        $namespace = preg_replace('/\\.php/', '', $namespace);
        $prefixPath = preg_replace('/\\//', '\\', Inflector::camelize($prefixPath));
        if (!$pluginPath) {
            $rootNamespace = Configure::read('App.namespace');
        } else {
            $rootNamespace = preg_replace('/\\//', '\\', $pluginPath);
        }
        $namespace = [$rootNamespace, 'Controller', $prefixPath, $namespace];
        return implode('\\', Hash::filter($namespace));
    }