method optionToPermission documentation in bbn\User\Permissions

Returns the corresponding permission of a given option.

function(string $id_option, bool $create = false) { /** @var string The result - an option's ID */ $id_perm = null; if (!Str::isUid($id_option)) { throw new Exception("The string sent is not a UID: $id_option"); } if (!$this->opt->exists($id_option)) { throw new Exception("The options with a UID $id_option doesn't exist"); } /** @var array List of aliases (permissions have aliases to the original options) */ $aliases = $this->opt->getAliasItems($id_option); /** @var string The root (with options code) for this option's permission */ $root = $this->optionPermissionRoot($id_option); foreach ($aliases as $a) { $parents = $this->opt->parents($a); if (in_array($root, $parents)) { $id_perm = $a; break; } } if (!$id_perm && $create) { return $this->createFromId($id_option); } return $id_perm ?: null; }

Returns the corresponding permission of a given option. 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.