method realToPerm documentation in bbn\Appui\Ide
Returns the permission's id from a real file/dir's path
function(string $file, $type = 'file')
{
if (empty($file)) {
$file = self::$current_file;
}
if (empty($file)) {
throw new \Exception(X::_("The file can't be empty"));
}
if (
!empty($file)
// It must be a controller
&& (strpos($file, '/src/mvc/public/') !== false)
) {
$is_file = $type === 'file';
$plugin = false;
$root_path = $this->getAppPath() . 'mvc/public/';
if (strpos($file, $root_path) === 0) {
// Remove root path
$f = substr($file, \strlen($root_path));
}
// Internal route
if (empty($f)) {
// Check if it's an external route
foreach ($this->routes as $r) {
if (substr($r['path'], -1) !== '/') {
$r['path'] .= '/';
}
if (strpos($file, $r['path']) === 0) {
$plugin = $r['name'];
// Remove route
$f = substr($file, \strlen($r['path']));
// Remove /mvc/public
$f = substr($f, \strlen('src/mvc/public/'));
break;
}
}
}
if (!empty($f)) {
$bits = \bbn\X::removeEmpty(explode('/', $f));
$code = $is_file ? X::basename(array_pop($bits), '.php') : array_pop($bits) . '/';
$bits = array_map(
function ($b) {
return $b . '/';
},
array_reverse($bits)
);
array_unshift($bits, $code);
if ($plugin) {
array_push(
$bits,
'access',
'permissions',
strpos($plugin, 'appui-') === 0 ? substr($plugin, 6) : $plugin,
strpos($plugin, 'appui-') === 0 ? 'appui' : null
);
} else {
array_push($bits, $this->_permissions());
}
return $this->options->fromCode($bits);
}
}
return false;
}
Returns the permission's id from a real file/dir's path 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-2023
BBN Solutions