Skip to content

Commit f2f0491

Browse files
authored
Merge pull request #9 from tattersoftware/suggest
2 parents 92aeb98 + b455cdb commit f2f0491

File tree

3 files changed

+10
-8
lines changed

3 files changed

+10
-8
lines changed

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ Persistent user-specific settings for CodeIgniter 4
1515
## Description
1616

1717
`Preferences` is a wrapper for [CodeIgniter Settings](https://github.com/codeigniter4/settings)
18-
to provide authenticated user context to each setting. This allows you to get and set preferences
19-
on a per-user basis with a single command.
18+
to provide user context to each setting. This allows you to get and set preferences on a
19+
per-user basis with a single command.
2020

2121
## Installation
2222

@@ -31,10 +31,10 @@ Once the files are downloaded and included in the autoload, run any library migr
3131
to ensure the database is set up correctly:
3232
* `> php spark migrate -all`
3333

34-
`Preferences` requires the Composer provision for `codeigniter4/authentication-implementation` as describe in the
35-
[CodeIgniter authentication guidelines](https://codeigniter4.github.io/CodeIgniter4/extending/authentication.html),
36-
so be sure to install a [supported package](https://packagist.org/providers/codeigniter4/authentication-implementation)
37-
as well.
34+
`Preferences` suggests the Composer provision for `codeigniter4/authentication-implementation` as describe in the
35+
[CodeIgniter authentication guidelines](https://codeigniter4.github.io/CodeIgniter4/extending/authentication.html).
36+
Without this each preference will be limited to the session duration so it is highly recommended
37+
you install and configure a [supported package](https://packagist.org/providers/codeigniter4/authentication-implementation).
3838

3939
## Usage
4040

composer.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
],
2121
"require": {
2222
"php": "^7.3 || ^8.0",
23-
"codeigniter4/authentication-implementation": "^1.0",
2423
"codeigniter4/settings": "^2.1"
2524
},
2625
"require-dev": {
@@ -47,6 +46,9 @@
4746
"url": "https://github.com/codeigniter4/codeigniter4"
4847
}
4948
],
49+
"suggest": {
50+
"codeigniter4/authentication-implementation": "Required to enable database persistence."
51+
},
5052
"minimum-stability": "dev",
5153
"prefer-stable": true,
5254
"scripts": {

src/Helpers/preferences_helper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ function preference(string $key, $value = null)
1818
}
1919

2020
// Authenticated
21-
if ($userId = user_id()) {
21+
if (function_exists('user_id') && $userId = user_id()) {
2222
$settings = service('settings');
2323

2424
// Getting

0 commit comments

Comments
 (0)