PreferenceMaker
Preference Maker Trait
Adds methods for modifying user preferences in a controller class, or a class
that contains a $controller property referencing a controller.
Table of Contents
- $preferenceCache : array<string|int, mixed>
- Cache for retrieved user preferences.
- clearUserPreference() : void
- Clears a single preference key from the user preferences for this controller/widget.
- clearUserPreferences() : void
- Clears all user preferences for this controller/widget.
- getUserPreference() : mixed
- Retrieves a widget related key/value pair from the user preferences
- getUserPreferences() : array<string|int, mixed>
- Retrieves and caches all user preferences for this particular controller/widget.
- putUserPreference() : void
- Saves a widget related key/value pair in to the users preferences
- getPreferenceKey() : string
- Returns a unique identifier for this widget and controller action for preference storage.
- getPreferenceStorage() : Model
- Specifies the model used for storing the user preferences.
Properties
$preferenceCache
Cache for retrieved user preferences.
protected
static array<string|int, mixed>
$preferenceCache
= []
Methods
clearUserPreference()
Clears a single preference key from the user preferences for this controller/widget.
public
clearUserPreference(string $key) : void
Parameters
- $key : string
-
Unique key for the data store.
Return values
void —clearUserPreferences()
Clears all user preferences for this controller/widget.
public
clearUserPreferences() : void
Return values
void —getUserPreference()
Retrieves a widget related key/value pair from the user preferences
public
getUserPreference([string $key = null ][, mixed $default = null ]) : mixed
Parameters
- $key : string = null
-
Unique key for the data store.
- $default : mixed = null
-
A default value to use when value is not found.
Return values
mixed —getUserPreferences()
Retrieves and caches all user preferences for this particular controller/widget.
public
getUserPreferences() : array<string|int, mixed>
Return values
array<string|int, mixed> —putUserPreference()
Saves a widget related key/value pair in to the users preferences
public
putUserPreference(string $key, mixed $value) : void
Parameters
- $key : string
-
Unique key for the data store.
- $value : mixed
-
The value to store.
Return values
void —getPreferenceKey()
Returns a unique identifier for this widget and controller action for preference storage.
protected
getPreferenceKey() : string
Return values
string —getPreferenceStorage()
Specifies the model used for storing the user preferences.
protected
getPreferenceStorage() : Model