PHP Класс Themosis\User\UserFactory

Наследование: extends Themosis\Field\Wrapper, implements Themosis\User\IUser
Показать файл Открыть проект

Защищенные свойства (Protected)

Свойство Тип Описание
$action Themosis\Hook\IHook
$capability string The capability in order to save custom data.
$fields array The user custom fields.
$hasNonce boolean Globally check if nonce inputs are inserted.
$rules array Validation rules for custom fields.
$sections array The user sections.
$validator Themosis\Validation\IValidate Validator instance.
$view Illuminate\View\View The user core/container view.

Открытые методы

Метод Описание
__construct ( Illuminate\View\View $view, Themosis\Validation\IValidate $validator, Themosis\Hook\IHook $action ) Build a UserFactory instance.
addFields ( array $fields, string $capability = 'edit_users' ) : Themosis\User\IUser Register custom fields for users.
addSections ( array $sections ) : Themosis\User\IUser Register sections for user custom fields.
current ( ) : User Look at the current user and return an instance.
displayFields ( $user ) Render the user fields.
get ( integer $id ) : User Return a User instance using its ID.
hasSections ( ) : boolean Check if there are any sections defined.
make ( string $username, string $password, string $email ) : User Create a new WordPress user.
saveFields ( integer $id, array $oldData = [] ) Triggered by the 'user_register' && 'profile_update' hooks.
validate ( array $rules = [] ) : Themosis\User\IUser Register validation rules for user custom fields.

Защищенные методы

Метод Описание
createUser ( integer $id ) : User Create a new User instance.
isUsingSections ( array $fields ) Check if the defined fields are using the sections defined or not.
parseCredentials ( array $credentials ) Check if given credentials to create a new WordPress user are valid.
parseTheFields ( array $fields ) : array Parse the list of registered fields. Remove the sections if defined.
register ( integer $id, array $fields ) Register custom user meta.
setDefaultValue ( WP_User | string $user, array $fields ) : array Set the default 'value' property for all fields.

Описание методов

__construct() публичный Метод

Build a UserFactory instance.
public __construct ( Illuminate\View\View $view, Themosis\Validation\IValidate $validator, Themosis\Hook\IHook $action )
$view Illuminate\View\View The user core view.
$validator Themosis\Validation\IValidate Validator instance.
$action Themosis\Hook\IHook

addFields() публичный Метод

Register custom fields for users.
public addFields ( array $fields, string $capability = 'edit_users' ) : Themosis\User\IUser
$fields array The user custom fields. By sections or not.
$capability string The minimum capability required to save user custom fields data.
Результат Themosis\User\IUser

addSections() публичный Метод

Register sections for user custom fields.
public addSections ( array $sections ) : Themosis\User\IUser
$sections array A list of sections to register.
Результат Themosis\User\IUser

createUser() защищенный Метод

Create a new User instance.
protected createUser ( integer $id ) : User
$id integer
Результат User

current() публичный Метод

Look at the current user and return an instance.
public current ( ) : User
Результат User

displayFields() публичный Метод

Render the user fields.
public displayFields ( $user )

get() публичный Метод

Return a User instance using its ID.
public get ( integer $id ) : User
$id integer
Результат User

hasSections() публичный Метод

Check if there are any sections defined.
public hasSections ( ) : boolean
Результат boolean

isUsingSections() защищенный Метод

If there are sections and the fields are not set to use a section, trigger an error.
protected isUsingSections ( array $fields )
$fields array

make() публичный Метод

Create a new WordPress user.
public make ( string $username, string $password, string $email ) : User
$username string
$password string
$email string
Результат User | \WP_Error

parseCredentials() защищенный Метод

Check if given credentials to create a new WordPress user are valid.
protected parseCredentials ( array $credentials )
$credentials array

parseTheFields() защищенный Метод

Parse the list of registered fields. Remove the sections if defined.
protected parseTheFields ( array $fields ) : array
$fields array The fields.
Результат array A clean list of fields.

register() защищенный Метод

Register custom user meta.
protected register ( integer $id, array $fields )
$id integer The user_ID
$fields array The custom fields to register.

saveFields() публичный Метод

Used in order to save custom fields for the users.
public saveFields ( integer $id, array $oldData = [] )
$id integer The user ID.
$oldData array Null by default. If user update, contains an array of previous user data.

setDefaultValue() защищенный Метод

Set the default 'value' property for all fields.
protected setDefaultValue ( WP_User | string $user, array $fields ) : array
$user WP_User | string
$fields array
Результат array

validate() публичный Метод

Register validation rules for user custom fields.
public validate ( array $rules = [] ) : Themosis\User\IUser
$rules array
Результат Themosis\User\IUser

Описание свойств

$action защищенное свойство

protected IHook,Themosis\Hook $action
Результат Themosis\Hook\IHook

$capability защищенное свойство

The capability in order to save custom data.
protected string $capability
Результат string

$fields защищенное свойство

The user custom fields.
protected array $fields
Результат array

$hasNonce защищенное статическое свойство

Globally check if nonce inputs are inserted.
protected static bool $hasNonce
Результат boolean

$rules защищенное свойство

Validation rules for custom fields.
protected array $rules
Результат array

$sections защищенное свойство

The user sections.
protected array $sections
Результат array

$validator защищенное свойство

Validator instance.
protected IValidate,Themosis\Validation $validator
Результат Themosis\Validation\IValidate

$view защищенное свойство

The user core/container view.
protected View,Illuminate\View $view
Результат Illuminate\View\View