method fetchCustomDir documentation in bbn\Mvc\Router
function(string $path, string $mode, string $plugin)
{
// Only for views and models
if (!self::isMode($mode) && !\in_array($mode, self::$_controllers)) {
throw new \Exception(X::_("The mode %s is invalid", $mode));
}
// If there is a prepath defined we prepend it to the path
if ($this->_prepath
&& (strpos($path, '/') !== 0)
&& (strpos($path, $this->_prepath) !== 0)
) {
$path = $this->_prepath . $path;
}
/** @var string $root Where the files will be searched for by default */
$root = $this->_get_custom_root($mode, $plugin);
$dir = false;
$dir1 = self::parse($root . $path);
if (is_dir($dir1) && (strpos($dir1, $root) === 0)) {
$dir = $dir1;
}
if (!$dir) {
throw new \Exception(X::_("Impossible to find the directory for %s", $path));
}
$res = [];
$files = bbn\File\Dir::getFiles($dir);
$prepath = $path && ($path !== '.') ? $path.'/' : '';
if (!is_array($files)) {
throw new \Exception(X::_("The directory %s doesn't exist", $dir));
}
foreach ($files as $f) {
if (\in_array(bbn\Str::fileExt($f), self::$_filetypes[$mode], true)) {
$res[] = $prepath.bbn\Str::fileExt($f, true)[0];
}
}
return $res;
}
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.
© 2011-2025
BBN Solutions