Exemplo n.º 1
0
 private function changeFolderPermissions($folder, $mode)
 {
     if (!empty($errors = chmodDirFiles($folder, $mode))) {
         foreach ($errors as $error) {
             $this->io->writeln("Unable to change permissions for {$error}", 'red');
         }
     }
 }
Exemplo n.º 2
0
 /**
  * Method to change the permission for files recursively
  *
  * @param $dir
  * @param null $mod
  * @param bool $recursive
  * @return array $errors
  */
 function chmodDirFiles($dir, $mod = null, $recursive = true)
 {
     $errors = [];
     chmod($dir, 0755);
     if ($recursive && ($objs = glob($dir . DIRECTORY_SEPARATOR . "*"))) {
         foreach ($objs as $file) {
             if (is_dir($file)) {
                 chmodDirFiles($file, $mod, $recursive);
             } else {
                 if (!change_perms($file, decoct($mod))) {
                     $errors[] = $file;
                 }
             }
         }
     }
     return $errors;
 }