芝麻web文件管理V1.00
编辑当前文件:/home/lekhnath/silverray.com.au/vendor/spatie/laravel-permission/src/WildcardPermission.php
record = $record; } public function getIndex(): array { $index = []; foreach ($this->record->getAllPermissions() as $permission) { $index[$permission->guard_name] = $this->buildIndex( $index[$permission->guard_name] ?? [], explode(static::PART_DELIMITER, $permission->name), $permission->name, ); } return $index; } protected function buildIndex(array $index, array $parts, string $permission): array { if (empty($parts)) { $index[null] = true; return $index; } $part = array_shift($parts); if (blank($part)) { throw WildcardPermissionNotProperlyFormatted::create($permission); } if (! Str::contains($part, static::SUBPART_DELIMITER)) { $index[$part] = $this->buildIndex( $index[$part] ?? [], $parts, $permission, ); } $subParts = explode(static::SUBPART_DELIMITER, $part); foreach ($subParts as $subPart) { if (blank($subPart)) { throw WildcardPermissionNotProperlyFormatted::create($permission); } $index[$subPart] = $this->buildIndex( $index[$subPart] ?? [], $parts, $permission, ); } return $index; } public function implies(string $permission, string $guardName, array $index): bool { if (! array_key_exists($guardName, $index)) { return false; } $permission = explode(static::PART_DELIMITER, $permission); return $this->checkIndex($permission, $index[$guardName]); } protected function checkIndex(array $permission, array $index): bool { if (array_key_exists(strval(null), $index)) { return true; } if (empty($permission)) { return false; } $firstPermission = array_shift($permission); if ( array_key_exists($firstPermission, $index) && $this->checkIndex($permission, $index[$firstPermission]) ) { return true; } if (array_key_exists(static::WILDCARD_TOKEN, $index)) { return $this->checkIndex($permission, $index[static::WILDCARD_TOKEN]); } return false; } }