addPreference() public static method

Register a preference with a transformer and a default value.
public static addPreference ( string $key, callable $transformer = null, mixed $default = null )
$key string
$transformer callable
$default mixed
 /**
  * Register notification types.
  */
 public function registerNotificationTypes()
 {
     $blueprints = ['Flarum\\Core\\Notification\\DiscussionRenamedBlueprint' => ['alert']];
     $this->app->make('events')->fire(new ConfigureNotificationTypes($blueprints));
     foreach ($blueprints as $blueprint => $enabled) {
         Notification::setSubjectModel($type = $blueprint::getType(), $blueprint::getSubjectModel());
         User::addPreference(User::getNotificationPreferenceKey($type, 'alert'), 'boolval', in_array('alert', $enabled));
         if ((new ReflectionClass($blueprint))->implementsInterface('Flarum\\Core\\Notification\\MailableInterface')) {
             User::addPreference(User::getNotificationPreferenceKey($type, 'email'), 'boolval', in_array('email', $enabled));
         }
     }
 }
 public function add($key, callable $transformer = null, $default = null)
 {
     User::addPreference($key, $transformer, $default);
 }