Get the ID of the passed in permission.  Permission
can be an ID, name, or Permission object

@param $permission integer|string|\Searsaw\Drawbridge\Models\BridgePermission The permission whose ID to get

@return integer
@throws \InvalidArgumentException
353459
public function getPermissionId($permission)
    {
        if (is_numeric($permission))
            return $permission;
        elseif (is_string($permission))
            return $this->getPermissionIdFromName($permission);
        elseif ($permission instanceof BridgePermission)
            return $permission->id;
        else
            throw new \InvalidArgumentException('Permission to check must be a name, ID, or Permission object.');
    }
682067
public function get($identifier)
    {
        if(!isset($this->managers[$identifier]))
            throw new InvalidArgumentException('A manager with that identifier does not exist.');

        return $this->managers[$identifier];
    }
676422
public function getId($alias)
    {
        if (!isset($this->aliases[$alias])) {
            return null;
        }

        $id = $this->aliases[$alias];
        while (isset($this->aliases[$id])) {
            $id = $this->aliases[$id];
        }

        return $id;
    }
978302
public function grantAccessByPermission($permission, UserInterface $user = null)
    {
        $user = $user ? : $this->currentUser();
        return in_array($permission, $this->gatherPermissions($user));
    }
186763
public function hasPermission($permission)
    {
        foreach ($this->permissions()->get() as $p) {
            if ($p->name == $permission) {
                return true;
            }
        }
        return false;
    }
93744
public function authorize($permission)
    {
        $this->requiredPermissions[] = $permission instanceof IPermission
            ? $permission
            : Permission::named($permission);
    }
309440
public function findWithoutPermission($permission)
    {
        return array_filter(
            $this->findAll(),
            function ($role) use ($permission) {
                return $role->hasnt($permission);
            }
        );
    }
1220085
public function permissionGetIdByName($name)
  {
    if(!array_key_exists((string) $name, $this->permissionList()))
    {
      throw new Exception("invalid permission ID", 0xA02);
    }

    return $this->permissionList[(string) $name]["permid"];
  }
197411
public function hasDirectPermission($permission)
    {
        $name = $permission instanceof Permission ? $permission->name : $permission;
        return (bool) $this->permissions->where('name', $name)->count();
    }
720411
protected function hasPermission($permission)
    {
        return $this->getPermissions()->contains(function ($value, $key) use ($permission) {
            return $permission == $value->id || Str::is($permission, $value->slug);
        });
    }
1327108
public function findWithPermission($permission)
    {
        return array_filter(
            $this->findAll(),
            function ($role) use ($permission) {
                return $role->has($permission);
            }
        );
    }
611517
public function equals($privilege)
    {
        if (is_scalar($privilege)) {
            $privilege = new self($privilege);
        } elseif (!$privilege instanceof self) {
            throw new \InvalidArgumentException('$privilege is expected to be of type string or Gobline\Acl\Privilege');
        }

        return $privilege->getName() === $this->name;
    }
887776
public function inferControllerAction($permission)
    {
        $area = null;
        if ($permission[0] === '/') {
            if ($areas = $this->router->getAreas()) {
                $pos = strpos($permission, '/', 1);
                $area = Text::camelize($pos === false ? substr($permission, 1) : substr($permission, 1, $pos - 1));
                if (in_array($area, $areas, true)) {
                    $permission = $pos === false || $pos === strlen($permission) - 1 ? '' : (string)substr($permission, $pos + 1);
                } else {
                    $area = null;
                    $permission = $permission === '/' ? '' : (string)substr($permission, 1);
                }
            } else {
                $permission = $permission === '/' ? '' : (string)substr($permission, 1);
            }
        } else {
            $area = $this->dispatcher->getArea();
        }

        if ($permission === '') {
            $controller = 'Index';
            $action = 'index';
        } elseif ($pos = strpos($permission, '/')) {
            if ($pos === false || $pos === strlen($permission) - 1) {
                $controller = Text::camelize($pos === false ? $permission : substr($permission, 0, -1));
                $action = 'index';
            } else {
                $controller = Text::camelize(substr($permission, 0, $pos));
                $action = lcfirst(Text::camelize(substr($permission, $pos + 1)));
            }
        } else {
            $controller = Text::camelize($permission);
            $action = 'index';
        }

        if ($area) {
            return ["@ns.app\\Areas\\$area\\Controllers\\{$controller}Controller", $action];
        } else {
            return ["@ns.app\\Controllers\\{$controller}Controller", $action];
        }
    }
156911
public function checkAccess($userId, $permissionName)
    {
        if (ValidatorHelper::isInteger($userId) == false) {
            throw new InvalidArgumentException('User identifier must be number.');
        }

        /** @var integer $permissionId */
        $permissionId = $this->repositoryRegistry
            ->getPermissionRepository()
            ->getPermissionIdByName($permissionName);

        if (ValidatorHelper::isInteger($permissionId)) {

            /** @var integer[] $rootRoleIds */
            $rootRoleIds = $this->repositoryRegistry
                ->getUserRoleRepository()
                ->getUserRoleIds($userId);

            if (count($rootRoleIds) > 0) {

                /** @var integer[] $allRoleIds */
                $allRoleIds = $this->repositoryRegistry
                    ->getRoleHierarchyRepository()
                    ->getAllRoleIdsHierarchy($rootRoleIds);

                return $this->repositoryRegistry
                    ->getRolePermissionRepository()
                    ->isPermissionAssigned($permissionId, $allRoleIds);
            }
        }

        return false;
    }
281138
public function hasPermission($permission)
    {
        if (!is_array($this->permissionsMap)) {
            $permissionsMap = cache()->get('permissions:' . $this->id, null);
            if ($permissionsMap === null) { // Not in cache
                $this->permissionsMap = $this->buildPermissionsMap();
                cache()->forever('permissions:' . $this->id, $this->permissionsMap);
            } else {
                $this->permissionsMap = $permissionsMap;
            }
        }
        return in_array($permission, $this->permissionsMap);
    }
696857
public function getPermissionIdByName($permissionName)
    {
        $qb = $this->createQueryBuilder('permission');

        $result = $qb->select('permission.id')
            ->where($qb->expr()->eq('permission.name', $qb->expr()->literal($permissionName)))
            ->setMaxResults(1)
            ->getQuery()
            ->getArrayResult();

        if (count($result) > 0) {
            return $result[0]['id'];
        }

        return null;
    }
740089
private function checkPermission($permission)
    {
        if (!$permission)
        {
            return;
        }

        $user = $this->securityApi->getUser(true);
        if ($user instanceof Permissible && $user->hasAccess($permission))
        {
            return;
        }

        throw Unauthorized::permissionDenied($permission, $this->securityApi);
    }