ManaPHP\Authorization\Rbac\PermissionBuilder::getControllerPermissions PHP Метод

getControllerPermissions() публичный Метод

public getControllerPermissions ( string $controller ) : array
$controller string
Результат array
    public function getControllerPermissions($controller)
    {
        $rc = new \ReflectionClass($controller);
        if (preg_match('#^[^/]*/([^/]*)/Controllers/(.*)Controller$#', str_replace('\\', '/', $controller), $match) !== 1) {
            return [];
        }
        $moduleName = $match[1];
        $controllerName = $match[2];
        $permissions = [];
        foreach ($rc->getMethods(\ReflectionMethod::IS_PUBLIC) as $method) {
            $methodName = $method->getName();
            if (preg_match('#^(.*)(Action)$#i', $methodName, $match) !== 1) {
                continue;
            }
            $actionName = $match[1];
            if ($match[2] !== 'Action') {
                throw new PermissionBuilderException('`:action` action of `:controller` is not suffix with `Action`', ['controller' => $rc->getName(), 'action' => $methodName]);
            }
            if (!$method->isPublic()) {
                throw new PermissionBuilderException('`:action` action of `:controller` does not have public visibility.', ['controller' => $rc->getName(), 'action' => $methodName]);
            }
            $permissions[] = ['module' => $moduleName, 'controller' => $controllerName, 'action' => $actionName, 'description' => $moduleName . '::' . $controllerName . '::' . $actionName];
        }
        return $permissions;
    }