Comprobar que el directorio RBAC existe y añadido .gitkeep

This commit is contained in:
unknown
2025-04-12 21:11:20 +02:00
parent 8cd4570845
commit 9ee2a833b5

View File

@ -29,8 +29,12 @@ if (!function_exists('generate_php_roles_constant')) {
// Close the array // Close the array
$phpCode .= "];\n"; $phpCode .= "];\n";
// Write PHP code to a file $dirPath = APPPATH . "Config/RBAC";
$filePath = APPPATH . "Config/RBAC/roles.php"; if (!is_dir($dirPath)) {
mkdir($dirPath, 0775, true); // true permite crear carpetas anidadas
}
$filePath = $dirPath . "/roles.php";
file_put_contents($filePath, $phpCode); file_put_contents($filePath, $phpCode);
} }
@ -58,9 +62,14 @@ if (!function_exists('generate_php_permissions_constant')) {
// Close the array // Close the array
$phpCode .= "];\n"; $phpCode .= "];\n";
// Write PHP code to a file $dirPath = APPPATH . "Config/RBAC";
$filePath = APPPATH . "Config/RBAC/permissions.php"; if (!is_dir($dirPath)) {
mkdir($dirPath, 0775, true); // true permite crear carpetas anidadas
}
$filePath = $dirPath . "/permissions.php";
file_put_contents($filePath, $phpCode); file_put_contents($filePath, $phpCode);
} }
} }
@ -87,8 +96,12 @@ if (!function_exists('generate_php_permissions_matrix_constant')) {
// Close the array // Close the array
$phpCode .= "];\n"; $phpCode .= "];\n";
// Write PHP code to a file $dirPath = APPPATH . "Config/RBAC";
$filePath = APPPATH . "Config/RBAC/permissionMatrix.php"; if (!is_dir($dirPath)) {
mkdir($dirPath, 0775, true); // true permite crear carpetas anidadas
}
$filePath = $dirPath . "/permissionMatrix.php";
file_put_contents($filePath, $phpCode); file_put_contents($filePath, $phpCode);
} }
} }
@ -130,9 +143,9 @@ if (!function_exists('checkGroups')) {
*/ */
function checkGroups(array $groups, string $redirectRoute = null) function checkGroups(array $groups, string $redirectRoute = null)
{ {
$session = \Config\Services::session(); $session = \Config\Services::session();
$response = \Config\Services::response(); $response = \Config\Services::response();
$auth = auth(); // Shield auth service $auth = auth(); // Shield auth service
$user = $auth->user(); $user = $auth->user();