method delete documentation in bbn\Ide\Actions

function($data) { $cfg = $directories->dirs(); if ( isset($data['dir'], $data['name'], $data['path'], $data['type'], $cfg[$data['dir']]) && (strpos($data['path'], '../') === false) && bbn\Str::checkFilename($data['name']) ){ $type = $data['type'] === 'file' ? 'file' : 'dir'; $wtype = $type === 'dir' ? 'directory' : 'file'; $delete = []; $dirs =& $cfg[$data['dir']]; if ( $type === 'file' ){ if ( $this->isMvc($dirs) ){ $tab_url_mvc = $data['dir'] . '/' . $data['path']; if ( $data['name'] != '_ctrl' ){ foreach ( $cfg[$data['dir']]['files'] as $f ){ $p = $f['fpath'] . substr($data['path'], 0, -3) . $f['ext']; if ( file_exists($p) && !\in_array($p, $delete) ){ array_push($delete, $p); } } } else { $p = $cfg[$data['dir']]['files']['CTRL']['fpath'].$data['path']; if ( file_exists($p) && !\in_array($p, $delete) ){ array_push($delete, $p); } } } else { foreach ( $dirs['files'] as $f ){ if ( $f['ext'] === bbn\Str::fileExt($data['path']) ){ $p = $f['fpath'] . $data['path']; if ( file_exists($p) && !\in_array($p, $delete) ){ array_push($delete, $p); } } } } } if ($type === 'dir'){ $p_mvc = false; $p_mvc2 = false; if ( $this->isMvc($cfg[$data['dir']]) ){ foreach ( $cfg[$data['dir']]['files'] as $f ){ $p = $f['fpath'] . $data['path']; if ( $f['title'] === 'Controller' ){ $p_mvc = $f['fpath'] . $data['path']; $p_mvc2 = $f['fpath']; } if ( is_dir($p) && !\in_array($p, $delete) ){ array_push($delete, $p); } } } else { $p = $cfg[$data['dir']]['root_path'].$data['path']; if ( is_dir($p) && !\in_array($p, $delete) ){ array_push($delete, $p); } } // Files and directories to check if they're opened $sub_files = bbn\File\Dir::scan(empty($p_mvc) ? $p : $p_mvc); foreach ( $sub_files as $i => $sub ){ if ( is_file($sub) ){ $sub_files[$i] = str_replace((empty($p_mvc2) ? $cfg[$data['dir']]['root_path'] : $p_mvc2), $data['dir'] . '/', $sub); } else { unset($sub_files[$i]); } } } foreach ( $delete as $d ){ $r = $type === 'dir' ? bbn\File\Dir::delete($d) : unlink($d); if ( empty($r) ){ return $this->error("Impossible to delete the $wtype $d"); } } $ret = [ 'path' => empty($p_mvc) ? $p : $p_mvc, 'sub_files' => empty($sub_files) ? false : array_values($sub_files) ]; if ( empty($ret['sub_files']) ){ $ret['tab_url'] = [empty($tab_url_mvc) ? str_replace($cfg[$data['dir']]['root_path'], $data['dir'].'/', $ret['path']) : $tab_url_mvc]; } return $ret; } else { return $this->error("There is a problem in the name you entered"); } }

BBN is a suite of PHP and JS libraries and VueJS components - all open-source! bbn.io, build applications, the quick way

This website uses cookies to ensure you get the best experience on our website.