Backend\Traits\PreferenceMaker

Source: ~/modules/backend/traits/PreferenceMaker.php

Preference Maker 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 void clearUserPreference(string $key)

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

Parameters
  • string $key - Unique key for the data store.

public void clearUserPreferences()

Clears all user preferences for this controller/widget.

public mixed getUserPreference(string $key=NULL, mixed $default=NULL)

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

Parameters
  • string $key - Unique key for the data store.
  • mixed $default - A default value to use when value is not found.

public array getUserPreferences()

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

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

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

Parameters
  • string $key - Unique key for the data store.
  • mixed $value - The value to store.

Protected methods

protected string getPreferenceKey()

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

protected October\Rain\Database\Model getPreferenceStorage()

Specifies the model used for storing the user preferences.