public function prefetchAll($model)
{
$d = $this->d($model);
$dirs = $this->app->pathfinder->search($d[0], $d['path_prefix'], 'path');
$colls = array();
foreach ($dirs as $dir) {
// folder will contain collections
$dd = dir($dir);
while (false !== ($file = $dd->read())) {
// skip current folder and hidden files
if ($file[0] == '.') {
continue;
}
// skip folders in general
if (is_dir($dir . '/' . $file)) {
continue;
}
// do we strip extensios?
if ($d['strip_extension']) {
// remove any extension
$basefile = pathinfo($file, PATHINFO_FILENAME);
$ext = pathinfo($file, PATHINFO_EXTENSION);
if ($d['strip_extension'] !== true) {
if ($ext !== $d['strip_extension']) {
continue;
}
}
$file = $basefile;
}
$colls[] = array('base_path' => $dir . '/' . $file, 'name' => $file, 'id' => $file);
}
}
return $colls;
}