Documentation

UserSettingsManager extends StaticFactory

User Extended by Shawn Clake Class UserSettingsManager User Extended is licensed under the MIT license.

Tags
author

Shawn Clake shawn.clake@gmail.com

link
https://github.com/ShawnClake/UserExtended
license

https://github.com/ShawnClake/UserExtended/blob/master/LICENSE MIT

Table of Contents

UE_FORM_CHECKBOX  = 'checkbox'
UE_FORM_COLOR  = 'color'
UE_FORM_DATE  = 'date'
UE_FORM_EMAIL  = 'email'
UE_FORM_FILE  = 'file'
UE_FORM_NUMBER  = 'number'
UE_FORM_PASSWORD  = 'password'
UE_FORM_RADIO  = 'radio'
UE_FORM_RANGE  = 'range'
UE_FORM_SWITCH  = 'switch'
UE_FORM_TEL  = 'tel'
UE_FORM_TEXT  = 'text'
Field types TODO: Change the values to be HTML form types if they aren't already.
UE_FORM_TIME  = 'time'
UE_FORM_URL  = 'url'
$settings  : mixed
Settings column from the user object
$settingsTemplate  : array<string|int, mixed>
Settings config file
$twig  : Twig_Environment
Stores the twig environment
$user  : null
Stores the user object
$defaults  : array<string|int, mixed>
Setting option defaults
__callStatic()  : mixed
Main factory function which utilizes PHP's magic method to call a suffixed factory function on the child class.
all()  : array<string|int, mixed>
Returns an array in the form of [setting1=>[value. options=>[]], setting2=>[value. options=>[]]] representing all of the settings on a user model
checkValidation()  : bool|
currentUser()  :
currentUserFactory()  : $this
Factory function for using the current user
decrypt()  : mixed
Returns the decrypted version of the passed value It will return the value if encryption is not required
encrypt()  : mixed
Returns an encrypted version of the passed value.
factory()  : mixed
Helper function which can also be used to simply create an instance of a child class in cases where initialization functions aren't needed.
getRegisterable()  : array<string|int, mixed>
Returns an array of setting values and options for each setting marked with the option 'registerable'
getSetting()  : array<string|int, mixed>|null
Returns an array in the form of [value, options=>[]] for a setting on a user model
getSettingOptions()  : array<string|int, mixed>|false
Gets the setting's options prioritizing config and then defaults
getSettingsTemplate()  : array<string|int, mixed>
Get templated settings
getSettingValue()  : mixed|string
Gets the value of a setting on a user model
getUpdateable()  : array<string|int, mixed>
Returns an array of setting values and options for each setting marked with the option 'editable'
isCreateable()  : mixed
Returns whether or not a setting can be updated or created, Overrides both editable and registerable
isEditable()  : bool
Returns whether or not a setting should exist on an update form page
isEncrypted()  : bool
Returns whether or not a setting should be encrypted
isRegisterable()  : mixed
Returns whether a setting should exist on a sign up form
isSetting()  : bool
Determines whether the passed string is a valid setting according to the config
isValidated()  : bool
Returns whether or not a setting has validation rules
mergeOptionsWithDefaults()  : array<string|int, mixed>
Helper function for merging the config options with defaults
render()  : mixed
save()  : $this
Save the settings to the user model
setSetting()  : bool|Validator
Sets a setting by checking whether or not it can be edited, then validates it, then encrypts it if requried.
userCheck()  : null
Returns the user instance Useful for debugging and tests
userSettingsCheck()  : mixed
Returns the user settings on the user instance Useful for debugging and tests
validate()  : bool|
Returns whether or not a passed value passes its validation rules Will return true if the setting does not require validation
validation()  :
validationFactory()  : $this
Loads the settings without getting the current user This is useful for validation while a user isn't logged in.
with()  :
withFactory()  : $this
Factory function for passing in a custom user
yamlCheck()  : array<string|int, mixed>
Returns the config file contents Useful for debugging and tests
load()  : mixed
Used as a sort of intermediary function for translating the DB Field Model into something which is backwards compatible TODO: Utilize sort order

Constants

UE_FORM_TEXT

Field types TODO: Change the values to be HTML form types if they aren't already.

public mixed UE_FORM_TEXT = 'text'

Properties

$settingsTemplate

Settings config file

protected array<string|int, mixed> $settingsTemplate = []

$defaults

Setting option defaults

private array<string|int, mixed> $defaults = ['label' => '', 'type' => 'text', 'validation' => '', 'editable' => true, 'createable' => true, 'registerable' => false, 'encrypt' => false]

Methods

__callStatic()

Main factory function which utilizes PHP's magic method to call a suffixed factory function on the child class.

public static __callStatic( $name,  $arguments) : mixed
Parameters
$name :
$arguments :
Return values
mixed

all()

Returns an array in the form of [setting1=>[value. options=>[]], setting2=>[value. options=>[]]] representing all of the settings on a user model

public all() : array<string|int, mixed>
Return values
array<string|int, mixed>

checkValidation()

public checkValidation( $setting,  $value) : bool|
Parameters
$setting :
$value :
Return values
bool|

currentUserFactory()

Factory function for using the current user

public currentUserFactory() : $this
Return values
$this

decrypt()

Returns the decrypted version of the passed value It will return the value if encryption is not required

public decrypt( $setting,  $value) : mixed
Parameters
$setting :
$value :
Return values
mixed

encrypt()

Returns an encrypted version of the passed value.

public encrypt( $setting,  $value) : mixed

It will return the NON encrypted value if encryption is not required for the setting

Parameters
$setting :
$value :
Return values
mixed

factory()

Helper function which can also be used to simply create an instance of a child class in cases where initialization functions aren't needed.

public static factory() : mixed

Generally you will want to use the static magic method below.

Return values
mixed

getRegisterable()

Returns an array of setting values and options for each setting marked with the option 'registerable'

public getRegisterable() : array<string|int, mixed>
Return values
array<string|int, mixed>

getSetting()

Returns an array in the form of [value, options=>[]] for a setting on a user model

public getSetting( $setting) : array<string|int, mixed>|null
Parameters
$setting :
Return values
array<string|int, mixed>|null

getSettingOptions()

Gets the setting's options prioritizing config and then defaults

public getSettingOptions( $setting) : array<string|int, mixed>|false
Parameters
$setting :
Return values
array<string|int, mixed>|false

getSettingsTemplate()

Get templated settings

public getSettingsTemplate([bool $core = false ]) : array<string|int, mixed>
Parameters
$core : bool = false
Return values
array<string|int, mixed>

getSettingValue()

Gets the value of a setting on a user model

public getSettingValue( $setting) : mixed|string
Parameters
$setting :
Return values
mixed|string

getUpdateable()

Returns an array of setting values and options for each setting marked with the option 'editable'

public getUpdateable() : array<string|int, mixed>
Return values
array<string|int, mixed>

isCreateable()

Returns whether or not a setting can be updated or created, Overrides both editable and registerable

public isCreateable( $setting) : mixed
Parameters
$setting :
Return values
mixed

isEditable()

Returns whether or not a setting should exist on an update form page

public isEditable( $setting) : bool
Parameters
$setting :
Return values
bool

isEncrypted()

Returns whether or not a setting should be encrypted

public isEncrypted( $setting) : bool
Parameters
$setting :
Return values
bool

isRegisterable()

Returns whether a setting should exist on a sign up form

public isRegisterable( $setting) : mixed
Parameters
$setting :
Return values
mixed

isSetting()

Determines whether the passed string is a valid setting according to the config

public isSetting( $setting) : bool
Parameters
$setting :
Return values
bool

isValidated()

Returns whether or not a setting has validation rules

public isValidated( $setting) : bool
Parameters
$setting :
Return values
bool

mergeOptionsWithDefaults()

Helper function for merging the config options with defaults

public mergeOptionsWithDefaults( $options) : array<string|int, mixed>
Parameters
$options :
Return values
array<string|int, mixed>

render()

public render( $settingName,  $options) : mixed
Parameters
$settingName :
$options :
Return values
mixed

save()

Save the settings to the user model

public save() : $this
Return values
$this

setSetting()

Sets a setting by checking whether or not it can be edited, then validates it, then encrypts it if requried.

public setSetting( $setting,  $value) : bool|Validator
Parameters
$setting :
$value :
Return values
bool|Validator

userCheck()

Returns the user instance Useful for debugging and tests

public userCheck() : null
Return values
null

userSettingsCheck()

Returns the user settings on the user instance Useful for debugging and tests

public userSettingsCheck() : mixed
Return values
mixed

validate()

Returns whether or not a passed value passes its validation rules Will return true if the setting does not require validation

public validate( $setting,  $value) : bool|
Parameters
$setting :
$value :
Return values
bool|

validation()

public static validation() :

UserSettingsManager

Terminology and flow: A user has many settings. A setting has many finite options. Options have default values below. A setting has a value. An option has a state.

Return values

validationFactory()

Loads the settings without getting the current user This is useful for validation while a user isn't logged in.

public validationFactory() : $this

Use cases: Programatically registering or updating a user

Return values
$this

with()

public static with(mixed $user) :

UserSettingsManager

Parameters
$user : mixed
Return values

yamlCheck()

Returns the config file contents Useful for debugging and tests

public yamlCheck() : array<string|int, mixed>
Return values
array<string|int, mixed>

load()

Used as a sort of intermediary function for translating the DB Field Model into something which is backwards compatible TODO: Utilize sort order

protected load() : mixed
Return values
mixed

Search results