@internal

@param array|string|bool $permissions
@param string|NULL $type
@param array|object|NULL $context

@return bool
165374
protected function dispatch($permissions, $type = NULL, $context = NULL) {
    if(is_bool($permissions)) {
      return $this->dispatchBoolean($permissions, $type, $context);
    }

    if(is_string($permissions)) {
      return $this->dispatchString($permissions, $type, $context);
    }

    if(is_array($permissions)) {
      return $this->dispatchArray($permissions, $type, $context);
    }

    throw new InvalidArgumentTypeException("A permission must either be a boolean, a string or an array. Evaluated permissions: " . print_r($permissions, TRUE));
  }
95496
protected function processNAND($permissions, $type = NULL, $context) {
    if(!is_array($permissions)) {
      throw new InvalidValueForLogicGateException("The value of a NAND gate must be an array. Current value: " . print_r($permissions, TRUE));
    }
    if(count($permissions) < 1) {
      throw new InvalidValueForLogicGateException("The value array of a NAND gate must contain a minimum of one element. Current value: " . print_r($permissions, TRUE));
    }

    return !$this->processAND($permissions, $type, $context);
  }
1024514
public function grantPermissions($permissions): void
    {
        if (!is_array($permissions) && !$permissions instanceof Collection) {
            $permissions = func_get_args();
        }

        foreach ($permissions as $permission) {
            $permission = $this->resolvePermission($permission);

            $permission->assignTo($this);
        }
    }
373849
public function allows(ActorInterface $actor, string $permission, array $context): bool
    {
        $parameters = compact('actor', 'permission', 'context') + $context;

        //Mounting aliases
        foreach (static::ALIASES as $target => $alias) {
            $parameters[$target] = $parameters[$alias];
        }

        try {
            $method = new \ReflectionMethod($this, static::CHECK_METHOD);
            $method->setAccessible(true);
        } catch (\ReflectionException $e) {
            throw new RuleException($e->getMessage(), $e->getCode(), $e);
        }

        try {
            return $method->invokeArgs($this, $this->resolver->resolveArguments($method, $parameters));
        } catch (\Throwable $e) {
            throw new RuleException(sprintf("[%s] %s", get_class($this), $e->getMessage()), $e->getCode(), $e);
        }
    }
1224586
protected function createPermissionObject($resource, $context, $action, $roles) {
    $permission = $this->persistenceFacade->create($this->permissionType);
    $permission->setValue('resource', $resource);
    $permission->setValue('context', $context);
    $permission->setValue('action', $action);
    $permission->setValue('roles', $roles);
    return $permission;
  }
1086180
public function assignPermission($permissionId = null)
    {
        $permissions = $this->permissions;

        if (! $permissions->contains($permissionId)) {
            $this->permissions()->attach($permissionId);

            return true;
        }

        return false;
    }
452056
private function mapPermissions(array $userPermission, array $permissions, callable $reduce)
    {
        foreach ($permissions as $attribute => $value) {
            if (!isset($userPermission[$attribute])) {
                $userPermission[$attribute] = false;
            }

            $userPermission[$attribute] = $reduce($userPermission[$attribute], $value);
        }

        return $userPermission;
    }
414205
public function setPermissionType($permissionType) {
    $this->permissionType = $permissionType;
    $this->actionKeyProvider->setEntityType($this->permissionType);
  }
1338616
public PermissionsBuilder setAllowed(PermissionType... types) {
        for (PermissionType type : types) {
            setState(type, PermissionState.ALLOWED);
        }
        return this;
    }
151555
protected function processAND($permissions, $type = NULL, $context) {
    if(!is_array($permissions)) {
      throw new InvalidValueForLogicGateException("The value of an AND gate must be an array. Current value: " . print_r($permissions, TRUE));
    }
    if(count($permissions) < 1) {
      throw new InvalidValueForLogicGateException("The value array of an AND gate must contain a minimum of one element. Current value: " . print_r($permissions, TRUE));
    }

    $access = TRUE;
    foreach(array_keys($permissions) as $key) {
      $subpermissions = [$key => $permissions[$key]];
      $access = $access && $this->dispatch($subpermissions, $type, $context);
      if(!$access) {
        break;
      }
    }

    return $access;
  }
1222815
public function setPermissions($permissions)
	{
		if (is_string($permissions))
		{
			$permissions = '0'.ltrim($permissions, '0');
			$permissions = octdec($permissions);
		}

		return chmod($this->path, $permissions);
	}
670836
public static function check($permissions)
    {
        if (Schema::hasTable('laralum_permissions')) {
            foreach ($permissions as $permission) {
                if (!self::allCached()->contains('slug', $permission['slug'])) {
                    Cache::forget('laralum_permissions');
                    if (!self::allCached()->contains('slug', $permission['slug'])) {
                        Permission::create([
                            'name'        => $permission['name'],
                            'slug'        => $permission['slug'],
                            'description' => $permission['desc'],
                        ]);
                    }
                }
            }
        }
        session(['laralum_permissions::mandatory' => array_merge(static::mandatory(), $permissions)]);
    }
516358
public static function createFromData($permissions)
    {
        return array_map(function ($permission) {
            if (is_array($permission)) {
                return PermissionFactory::createFromArray($permission);
            } else {
                return PermissionFactory::createFromObject($permission);
            }
        }, $permissions);
    }
112955
protected function checkPermissions(array $permissions, $reset = FALSE) {

    if (!isset($this->availablePermissons) || $reset) {
      $this->availablePermissons = array_keys(module_invoke_all('permission'));
    }

    $valid = TRUE;
    foreach ($permissions as $permission) {
      if (!in_array($permission, $this->availablePermissons)) {
        $valid = FALSE;
      }
    }
    return $valid;
  }
536353
public function grantAccessByPermissions($permissions, UserInterface $user = null)
    {
        $user = $user ? : $this->currentUser;
        return count(array_diff($permissions, $this->gatherPermissions($user))) === 0;
    }
727088
public function syncPermissions(array $permissions)
    {
        $permissionIds = [];
        foreach ($permissions as $name) {
            $permissionIds[] = app(Permission::class)->firstOrCreate(['name' => $name])->id;
        }
        $this->permissions()->sync($permissionIds);
    }
237189
public static function permission( $type, $name = null, $options = null, $fields = null, $pod = null, $id = null, $params = null ) {

		$permission = pods_permission( $options );

		$permission = (boolean) apply_filters( 'pods_form_field_permission', $permission, $type, $name, $options, $fields, $pod, $id, $params );

		return $permission;
	}