Backend\Traits\PreferenceMaker

Overview

PreferenceMaker Trait adds methods for modifying user preferences in a controller class, or a class that contains a $controller property referencing a controller.


Protected Properties

protected static array $preferenceCache

Cache for retrieved user preferences.


Public Methods

public getUserPreference()

public getUserPreference(
    string $key = null,
    mixed $default = null
): mixed 

Retrieves a widget related key/value pair from the user preferences

public getUserPreferences()

public getUserPreferences(): array 

Retrieves and caches all user preferences for this particular controller/widget.

public putUserPreference()

public putUserPreference(string $key, mixed $value): void 

Saves a widget related key/value pair in to the users preferences

public resetUserPreference()

public resetUserPreference(string $key): void 

Clears a single preference key from the user preferences for this controller/widget.

public resetUserPreferences()

public resetUserPreferences(): void 

Clears all user preferences for this controller/widget.

Protected Methods

protected getPreferenceKey()

protected getPreferenceKey(): string 

Returns a unique identifier for this widget and controller action for preference storage.

protected getPreferenceStorage()

protected getPreferenceStorage(): October\Rain\Database\Model 

Specifies the model used for storing the user preferences.