$defaultFields : array
The fields (by ID) that should be included by default.
This filter will allow certain fields, which would otherwise be visible based upon their actual definition/permissions, to be excluded in certain contexts. The most common use of this filter is to allow a user to select which particular columns they'd like to be visible in a listing table.
$dbAdapter : \Dewdrop\Db\Adapter
The DB adapter used for DB access.
$user : \Dewdrop\Db\Row
A DB row representing the currently logged-in user.
__construct(string $componentName, \Dewdrop\Db\Adapter $dbAdapter, string $dbTableName = 'dewdrop_visible_fields')
Provide the information needed to store selections in the database.
Typically, you won't need to specify the database table name, except in testing.
setDefaultFields(array|\Dewdrop\Fields $defaultFields) : \Dewdrop\Fields\Filter\Visibility
Set the fields that should be displayed by default (if no user selections have been made). Your array can contain either FieldInterface objects or string IDs for those fields.
setUser(\Dewdrop\Db\Row $user) : $this
Set the logged-in user that can be used when saving/loading per-user settings.
getUser() : \Dewdrop\Db\Row
Get the logged-in user row object for use when loading and saving per-user filter settings. Will attempt to retrieve this from Pimple if not set explicitly.
save(\Dewdrop\Fields $fields, array $selections, boolean $applyToAllUsers = false) : void
Save the user's visible field selections back to the database. We expect the selections array to just contain field IDs. Only those that match IDs of fields in the supplied Fields object will be saved.
apply(\Dewdrop\Fields $fields) : \Dewdrop\Fields
Apply the field to the supplied set of fields. If after filtering no fields are left, we'll return the full set of fields as a fallback.
If no preferences are saved to the DB, we will use either pre-defined defaults (@see setDefaults()) or the first 4 fields.
While saving, delete existing values. If the new values will be limited to the logged-in user, we only delete any settings specific to that user. Otherwise, we also delete any current values not specific to a user.
selectForLoad() : \Dewdrop\Db\Select
Create a Select object for use when loading filter settings from the DB.