AddUserController extends SetUserController

This is the AddUserController controller class.

This class extends FWK\Core\Controllers\SetUserController, see this class.

Tags
see
SetUserController

Table of Contents

ARRAY_FIELDS This constant is an array that defines the fields of type ARRAY.  = [\FWK\Enums\Parameters::CUSTOM_TAGS]
BILLING  = 'billing'
BILLING_FIELDS This constant is an array that defines the fields to consider for a billing address.  = [\FWK\Enums\Parameters::ALIAS, \FWK\Enums\Parameters::ADDRESS_ID, \FWK\Enums\Parameters::USER_TYPE, \FWK\Enums\Parameters::DEFAULT_ADDRESS, \FWK\Enums\Parameters::FIRST_NAME, \FWK\Enums\Parameters::LAST_NAME, \FWK\Enums\Parameters::COMPANY, \FWK\Enums\Parameters::ADDRESS, \FWK\Enums\Parameters::ADDRESS_ADDITIONAL_INFORMATION, \FWK\Enums\Parameters::NUMBER, \FWK\Enums\Parameters::CITY, \FWK\Enums\Parameters::STATE, \FWK\Enums\Parameters::POSTAL_CODE, \FWK\Enums\Parameters::VAT, \FWK\Enums\Parameters::NIF, \FWK\Enums\Parameters::PHONE, \FWK\Enums\Parameters::MOBILE, \FWK\Enums\Parameters::FAX, \FWK\Enums\Parameters::LOCATION_LIST, \FWK\Enums\Parameters::COUNTRY]
BOOL_FIELDS This constant is an array that defines the fields of type BOOL.  = [\FWK\Enums\Parameters::USE_SHIPPING_ADDRESS, \FWK\Enums\Parameters::SUBSCRIBED, \FWK\Enums\Parameters::CREATE_ACCOUNT]
CONTROLLER_ITEM This is the name of the main controller item, for example, if your request is over a productController, the itemController has the product that referer the url.  = 'controllerItem'
CREATE_ACCOUNT_FIELDS This constant is an array that defines the fields to consider when creating a user.  = [\FWK\Enums\Parameters::EMAIL, \FWK\Enums\Parameters::PASSWORD, \FWK\Enums\Parameters::GODFATHER_CODE, \FWK\Enums\Parameters::CREATE_ACCOUNT, \FWK\Enums\Parameters::CUSTOM_TAGS, \FWK\Enums\Parameters::P_ID, \FWK\Enums\Parameters::NICK, \FWK\Enums\Parameters::GENDER, \FWK\Enums\Parameters::BIRTHDAY, \FWK\Enums\Parameters::USE_SHIPPING_ADDRESS, \FWK\Enums\Parameters::SUBSCRIBED, \FWK\Enums\Parameters::IMAGE]
CUSTOM_TAGS  = 'customTags'
DATA  = 'data'
DATE_FIELDS This constant is an array that defines the fields of type DATE.  = [\FWK\Enums\Parameters::BIRTHDAY]
SHIPPING  = 'shipping'
SHIPPING_FIELDS This constant is an array that defines the fields to consider for a shipping address.  = self::BILLING_FIELDS
SUBSCRIBED  = 'subscribed'
UPDATE_ACCOUNT_FIELDS This constant is an array that defines the fields to consider when updating a user.  = [\FWK\Enums\Parameters::P_ID, \FWK\Enums\Parameters::NICK, \FWK\Enums\Parameters::GENDER, \FWK\Enums\Parameters::BIRTHDAY, \FWK\Enums\Parameters::USE_SHIPPING_ADDRESS, \FWK\Enums\Parameters::SUBSCRIBED, \FWK\Enums\Parameters::IMAGE]
USER  = 'user'
CODE  = 'code'
MESSAGE  = 'message'
REQUEST_ID  = 'requestId'
RESPONSE  = 'response'
STATUS  = 'status'
SUCCESS  = 'success'
$appliedParameters  : array<string|int, mixed>
$availableParams  : array<string|int, mixed>
$billingAddressParametersGroup  : BillingAddressParametersGroup|null
$commerceCalendar  : IntlCalendar|null
$commerceDateTime  : DateTime|null
$language $route will contains the language retuned from the API in route['language']<br> Default value 'en'  : Language
$loggedInRequired This attribute define if the controller required a logged in session  : bool
$requestParams This attribute contains the parameters of the request (GET or POST parameters)  : array<string|int, mixed>
$responseMessage  : string
$responseMessageError  : string
$salesAgentRequired This attribute define if the controller required a sales Agent in session  : bool
$shippingAddressParametersGroup  : ShippingAddressParametersGroup|null
$simulatedUserForbbiden This attribute define if the controller simulated user  : bool
$theme  : Theme|null
$twig This attribute references the TwigLoader instance of the controller, this is the component of our MVC that is in charge of rendering the response.  : TwigLoaderInterface|null
$userParametersGroup  : UserParametersGroup|null
$userService  : UserService|null
__construct() Constructor.  : mixed
getGlobalDataKeys() This method returns the global data keys  : array<string|int, mixed>
getInputFilterParameters() This method returns an array of the input params indicating in each node the param name, and the filter to apply.  : array<string|int, mixed>
getRequestParam() Returns the value of a filtered request parameter.  : mixed|null
getRequestParams() Returns a array with de filtered parameters  : array<string|int, mixed>
getUserGroupPId() This method calculates the UserGroupId to apply to the user  : string
parseData() This method parses the request params  : array<string|int, mixed>
run() This method executes the controller following these steps: <ol> <li>Get required data</li> <li>Create TwigLoader</li> <li>Render Twig template</li> <li>Output Twig response</li> </ol>  : void
addResponseHeaders() This method sets the the response header when execute self::run().  : void
addTwigBaseExtensions() This method is the one in charge of defining base extensions that are needed for the Twig template and adding them to the TwigLoader given by parameter.  : void
addTwigBaseFunctions() This method is the one in charge of defining base functions that are needed for the Twig template and adding them to the TwigLoader given by parameter.  : void
breakControllerProcess() This method breaks the execution of the controller throwing a CommerceException with the message and code given by parameters.  : void
checkCriticalServiceLoaded() This method checks if the data required for the correct run of the controller has a correct value, in opposite, it breaks the execution of the controller  : void
deleteControllerData() This method delete the value from controller data by key value, if the key doesn't exist it returns false  : bool
fillParametersGroup()  : void
forbiddenSimulatedUser() This method validate if the session is a simulated user  : void
getControllerData() This method returns the value from controller data by key value, if the key doesn't exist it returns null  : mixed|null
getFilterParams() This method returns an array of the params indicating in each node the param name, and the filter to apply.  : mixed
getLanguageSheet() This method returns the language sheet of the controller's language  : array<string|int, mixed>
getOriginParams() This method returns the origin of the params (see FilterInputHandler::PARAMS_FROM_GET, FilterInputHandler::PARAMS_FROM_QUERY_STRING or FilterInputHandler::PARAMS_FROM_POST,...).  : mixed
getParsedParamsData()  : array<string|int, mixed>
getResponse() This method returns an array containing the response information.  : array<string|int, mixed>
getResponseData() This method launches the adequate actions against the SDK (through the FWK services) and returns the response data.  : Element
getResponseError() This method returns an array containing the response error information.  : array<string|int, mixed>
getRoute() This method returns the route of this controller  : Route
getSeoItems() This method returns the metatags value  : SeoItems|null
getSession() This method returns the session value, if the request is cacheable returns null  : Session|null
getStatus() This method returns an array containing the status information, based on the given parameters.  : array<string|int, mixed>
getTheme()  : Theme
getTypeForm() This method returns the type of the form.  : string
getUrlRedirect() This method returns the url to redirect.  : string
initializeAppliedParameters() This method initialize applied parameters, runs previously to run preSendControllerBaseBatchData  : void
isForbidden() This method returns if the request should be run as a forbidden request.  : bool
parseResponseData() This method parses the given Element and returns it.  : Element
preSendControllerBaseBatchData() This method runs previously to run ControllerBaseBatchData  : void
preSetControllerBaseData() This method runs previously to run setControllerBaseData  : void
render() This method executes the renderization of the page and returns this renderization.  : string
response() This method generates the request response  : void
setBatchData() This method is the one in charge of defining all the data batch requests that are needed for the controller and adding them to the BatchRequests given by parameter.  : void
setControllerBaseBatchData() This method is the one in charge of defining all the data batch requests that are basic for the controller and adding them to the BatchRequests given by parameter.  : void
setControllerBaseData() This method is in charge of defining the basic data necessary for the correct operation of the controller.  : void
setData() This method runs after the batch requests (defined in the setBatchData methods) are resolved, so here you can work with the response of the batch requests and calculate and set more needed data.  : void
setDataValue() This method sets a key->value into de controller data.  : void
setTwig() This method builds the Twig object that will render the request.  : TwigLoader
setType() This method sets the response type when execute self::run()  : void
userExists()  : bool
validateLoggedIn() This method validate if the session is logged in  : void
validateSalesAgent() This method validate if the session is sales agent  : void

Constants

ARRAY_FIELDS

This constant is an array that defines the fields of type ARRAY.

public mixed ARRAY_FIELDS = [\FWK\Enums\Parameters::CUSTOM_TAGS]

BILLING_FIELDS

This constant is an array that defines the fields to consider for a billing address.

public mixed BILLING_FIELDS = [\FWK\Enums\Parameters::ALIAS, \FWK\Enums\Parameters::ADDRESS_ID, \FWK\Enums\Parameters::USER_TYPE, \FWK\Enums\Parameters::DEFAULT_ADDRESS, \FWK\Enums\Parameters::FIRST_NAME, \FWK\Enums\Parameters::LAST_NAME, \FWK\Enums\Parameters::COMPANY, \FWK\Enums\Parameters::ADDRESS, \FWK\Enums\Parameters::ADDRESS_ADDITIONAL_INFORMATION, \FWK\Enums\Parameters::NUMBER, \FWK\Enums\Parameters::CITY, \FWK\Enums\Parameters::STATE, \FWK\Enums\Parameters::POSTAL_CODE, \FWK\Enums\Parameters::VAT, \FWK\Enums\Parameters::NIF, \FWK\Enums\Parameters::PHONE, \FWK\Enums\Parameters::MOBILE, \FWK\Enums\Parameters::FAX, \FWK\Enums\Parameters::LOCATION_LIST, \FWK\Enums\Parameters::COUNTRY]

BOOL_FIELDS

This constant is an array that defines the fields of type BOOL.

public mixed BOOL_FIELDS = [\FWK\Enums\Parameters::USE_SHIPPING_ADDRESS, \FWK\Enums\Parameters::SUBSCRIBED, \FWK\Enums\Parameters::CREATE_ACCOUNT]

CONTROLLER_ITEM

This is the name of the main controller item, for example, if your request is over a productController, the itemController has the product that referer the url.

public mixed CONTROLLER_ITEM = 'controllerItem'

CREATE_ACCOUNT_FIELDS

This constant is an array that defines the fields to consider when creating a user.

public mixed CREATE_ACCOUNT_FIELDS = [\FWK\Enums\Parameters::EMAIL, \FWK\Enums\Parameters::PASSWORD, \FWK\Enums\Parameters::GODFATHER_CODE, \FWK\Enums\Parameters::CREATE_ACCOUNT, \FWK\Enums\Parameters::CUSTOM_TAGS, \FWK\Enums\Parameters::P_ID, \FWK\Enums\Parameters::NICK, \FWK\Enums\Parameters::GENDER, \FWK\Enums\Parameters::BIRTHDAY, \FWK\Enums\Parameters::USE_SHIPPING_ADDRESS, \FWK\Enums\Parameters::SUBSCRIBED, \FWK\Enums\Parameters::IMAGE]

DATE_FIELDS

This constant is an array that defines the fields of type DATE.

public mixed DATE_FIELDS = [\FWK\Enums\Parameters::BIRTHDAY]

SHIPPING_FIELDS

This constant is an array that defines the fields to consider for a shipping address.

public mixed SHIPPING_FIELDS = self::BILLING_FIELDS

UPDATE_ACCOUNT_FIELDS

This constant is an array that defines the fields to consider when updating a user.

public mixed UPDATE_ACCOUNT_FIELDS = [\FWK\Enums\Parameters::P_ID, \FWK\Enums\Parameters::NICK, \FWK\Enums\Parameters::GENDER, \FWK\Enums\Parameters::BIRTHDAY, \FWK\Enums\Parameters::USE_SHIPPING_ADDRESS, \FWK\Enums\Parameters::SUBSCRIBED, \FWK\Enums\Parameters::IMAGE]

Properties

$availableParams

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

$billingAddressParametersGroup

protected BillingAddressParametersGroup|null $billingAddressParametersGroup = null

$commerceCalendar

protected IntlCalendar|null $commerceCalendar = null

$commerceDateTime

protected DateTime|null $commerceDateTime = null

$language

$route will contains the language retuned from the API in route['language']<br> Default value 'en'

protected Language $language

$loggedInRequired

This attribute define if the controller required a logged in session

protected bool $loggedInRequired = false

$requestParams

This attribute contains the parameters of the request (GET or POST parameters)

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

$salesAgentRequired

This attribute define if the controller required a sales Agent in session

protected bool $salesAgentRequired = false

$shippingAddressParametersGroup

protected ShippingAddressParametersGroup|null $shippingAddressParametersGroup = null

$simulatedUserForbbiden

This attribute define if the controller simulated user

protected bool $simulatedUserForbbiden = false

$theme

protected static Theme|null $theme = null

$twig

This attribute references the TwigLoader instance of the controller, this is the component of our MVC that is in charge of rendering the response.

protected TwigLoaderInterface|null $twig = null

$userParametersGroup

protected UserParametersGroup|null $userParametersGroup = null

Methods

__construct()

Constructor.

public __construct(Route $route) : mixed
Parameters
$route : Route
Return values
mixed

getGlobalDataKeys()

This method returns the global data keys

public final static getGlobalDataKeys() : array<string|int, mixed>
Return values
array<string|int, mixed>

getInputFilterParameters()

This method returns an array of the input params indicating in each node the param name, and the filter to apply.

public static getInputFilterParameters(string|null $typeForm[, bool $isUserAddress = false ][, User|null $user = null ]) : array<string|int, mixed>
Parameters
$typeForm : string|null
$isUserAddress : bool = false
$user : User|null = null
Return values
array<string|int, mixed>

getRequestParam()

Returns the value of a filtered request parameter.

public getRequestParam(string $parameter[, bool $required = false ][, mixed $default = null ]) : mixed|null
Parameters
$parameter : string
$required : bool = false

Sets if the request paramenter is required.

$default : mixed = null
Tags
throws
CommerceException
Return values
mixed|null

getRequestParams()

Returns a array with de filtered parameters

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

getUserGroupPId()

This method calculates the UserGroupId to apply to the user

public getUserGroupPId(bool $newUser) : string
Parameters
$newUser : bool
Return values
string

parseData()

This method parses the request params

public static parseData(mixed $requestParams[, bool $simulaterUser = false ]) : array<string|int, mixed>
Parameters
$requestParams : mixed
$simulaterUser : bool = false
Return values
array<string|int, mixed>

run()

This method executes the controller following these steps: <ol> <li>Get required data</li> <li>Create TwigLoader</li> <li>Render Twig template</li> <li>Output Twig response</li> </ol>

public run([array<string|int, mixed> $additionalData = [] ][, string $header = null ]) : void
Parameters
$additionalData : array<string|int, mixed> = []

with the data to add to the controller data.

$header : string = null

to be added to the header of the request response (default null)

Return values
void

addResponseHeaders()

This method sets the the response header when execute self::run().

protected addResponseHeaders() : void

By default sets 'Access-Control-Allow-Origin:' to the host commerce

Tags
abstract
see
self::run()
Return values
void

addTwigBaseExtensions()

This method is the one in charge of defining base extensions that are needed for the Twig template and adding them to the TwigLoader given by parameter.

protected abstract addTwigBaseExtensions(TwigLoader $twig) : void
Parameters
$twig : TwigLoader
Tags
abstract
Return values
void

addTwigBaseFunctions()

This method is the one in charge of defining base functions that are needed for the Twig template and adding them to the TwigLoader given by parameter.

protected abstract addTwigBaseFunctions(TwigLoader $twig) : void
Parameters
$twig : TwigLoader
Tags
abstract
Return values
void

breakControllerProcess()

This method breaks the execution of the controller throwing a CommerceException with the message and code given by parameters.

protected breakControllerProcess(string $exceptionMessage[, int $exceptionCode = CommerceException::CONTROLLER_REDIRECT_ERROR ]) : void
Parameters
$exceptionMessage : string
$exceptionCode : int = CommerceException::CONTROLLER_REDIRECT_ERROR
Tags
throws
CommerceException
Return values
void

checkCriticalServiceLoaded()

This method checks if the data required for the correct run of the controller has a correct value, in opposite, it breaks the execution of the controller

protected checkCriticalServiceLoaded(object $data[, string $onExceptionCode = CommerceException::CONTROLLER_UNDEFINED_CRITICAL_DATA ]) : void
Parameters
$data : object

is the data required for the correct run of the controller

$onExceptionCode : string = CommerceException::CONTROLLER_UNDEFINED_CRITICAL_DATA

is the Exception to be thrown if the check is ko.

Return values
void

deleteControllerData()

This method delete the value from controller data by key value, if the key doesn't exist it returns false

protected deleteControllerData(string $key) : bool
Parameters
$key : string
Return values
bool

fillParametersGroup()

protected fillParametersGroup(bool $newUser) : void
Parameters
$newUser : bool
Return values
void

forbiddenSimulatedUser()

This method validate if the session is a simulated user

protected abstract forbiddenSimulatedUser() : void
Tags
abstract
Return values
void

getControllerData()

This method returns the value from controller data by key value, if the key doesn't exist it returns null

protected getControllerData(string $key) : mixed|null
Parameters
$key : string
Return values
mixed|null

getFilterParams()

This method returns an array of the params indicating in each node the param name, and the filter to apply.

protected getFilterParams() : mixed

This function must be override in extended controllers to add new parameters to self::requestParams

Return values
mixed

getLanguageSheet()

This method returns the language sheet of the controller's language

protected getLanguageSheet() : array<string|int, mixed>
Return values
array<string|int, mixed>

getOriginParams()

This method returns the origin of the params (see FilterInputHandler::PARAMS_FROM_GET, FilterInputHandler::PARAMS_FROM_QUERY_STRING or FilterInputHandler::PARAMS_FROM_POST,...).

protected getOriginParams() : mixed

This function must be override in extended controllers to add new parameters to self::requestParams

Tags
see
FilterInputHandler
Return values
mixed

getParsedParamsData()

protected getParsedParamsData() : array<string|int, mixed>
Return values
array<string|int, mixed>

getResponse()

This method returns an array containing the response information.

protected getResponse() : array<string|int, mixed>

Format of the returned array:

  • Position self::SUCCESS => contains 1
  • Position self::MESSAGE => contains the message response
Return values
array<string|int, mixed>

getResponseData()

This method launches the adequate actions against the SDK (through the FWK services) and returns the response data.

protected abstract getResponseData() : Element
Tags
abstract
Return values
Element

getResponseError()

This method returns an array containing the response error information.

protected getResponseError() : array<string|int, mixed>

Format of the returned array:

  • Position self::SUCCESS => contains 0
  • Position self::MESSAGE => contains the error message response
Return values
array<string|int, mixed>

getRoute()

This method returns the route of this controller

protected getRoute() : Route
Return values
Route

getSession()

This method returns the session value, if the request is cacheable returns null

protected getSession() : Session|null
Return values
Session|null

getStatus()

This method returns an array containing the status information, based on the given parameters.

protected getStatus(int $code, string $message) : array<string|int, mixed>

Format of the returned array:

  • Position self::CODE => contains the given code
  • Position self::MESSAGE => contains the given message
Parameters
$code : int
$message : string
Return values
array<string|int, mixed>

getTheme()

protected static getTheme() : Theme
Return values
Theme

initializeAppliedParameters()

This method initialize applied parameters, runs previously to run preSendControllerBaseBatchData

protected initializeAppliedParameters() : void
Return values
void

isForbidden()

This method returns if the request should be run as a forbidden request.

protected isForbidden() : bool
Return values
bool

parseResponseData()

This method parses the given Element and returns it.

protected parseResponseData(Element $response) : Element
Parameters
$response : Element
Return values
Element

preSendControllerBaseBatchData()

This method runs previously to run ControllerBaseBatchData

protected preSendControllerBaseBatchData() : void
Return values
void

preSetControllerBaseData()

This method runs previously to run setControllerBaseData

protected preSetControllerBaseData() : void
Return values
void

render()

This method executes the renderization of the page and returns this renderization.

protected render([string $content = null ][, string $layout = null ][, string $version = null ][, string $format = 'html' ]) : string
Parameters
$content : string = null

-> If different to null, it overrides the theme content to load in Twig

$layout : string = null

-> If different to null, it overrides the theme layout to load in Twig

$version : string = null

-> If different to null, it overrides the theme version to load in Twig

$format : string = 'html'

-> Default value: 'html'. Set the format to mark the name of the layout. For example, with "json" value, Twig render going to load default.json.twig

Return values
string

containing the renderization of the page.

response()

This method generates the request response

protected final response(string $output[, string $header = null ]) : void
Parameters
$output : string

is the render of the page to be set to the response.

$header : string = null

is a header to be added to the response.

Return values
void

setBatchData()

This method is the one in charge of defining all the data batch requests that are needed for the controller and adding them to the BatchRequests given by parameter.

protected abstract setBatchData(BatchRequests $request) : void
Parameters
$request : BatchRequests

where the method will add the batch requests.

Tags
abstract
Return values
void

setControllerBaseBatchData()

This method is the one in charge of defining all the data batch requests that are basic for the controller and adding them to the BatchRequests given by parameter.

protected abstract setControllerBaseBatchData(BatchRequests $requests) : void
Parameters
$requests : BatchRequests
Tags
abstract
Return values
void

setControllerBaseData()

This method is in charge of defining the basic data necessary for the correct operation of the controller.

protected abstract setControllerBaseData() : void

operation of the controller.

Tags
abstract
Return values
void

setData()

This method runs after the batch requests (defined in the setBatchData methods) are resolved, so here you can work with the response of the batch requests and calculate and set more needed data.

protected abstract setData([array<string|int, mixed> $additionalData = [] ]) : void
Parameters
$additionalData : array<string|int, mixed> = []
Tags
abstract
see
self::setBatchData()
Return values
void

setDataValue()

This method sets a key->value into de controller data.

protected setDataValue(string $key, mixed $value) : void
  • If the key that you try to insert is a self::DATA_RESERVED_KEYS then it throws an exception with code CommerceException::CODE_CONTROLLER_SET_DATA_VALUE_RESERVED_KEY
  • If the key already exists then it throws an exception with code CommerceException::CODE_CONTROLLER_SET_DATA_VALUE_ALREADY_DEFINED_KEY
Parameters
$key : string
$value : mixed
Tags
throws
CommerceException
Return values
void

setTwig()

This method builds the Twig object that will render the request.

protected setTwig([array<string|int, mixed> $data = [] ][, bool $loadCore = true ], int $autoescape[, string $themeName = null ]) : TwigLoader
Parameters
$data : array<string|int, mixed> = []

-> This data will be merged with the controller.data

$loadCore : bool = true

-> Set if is required to load the Twig Core Macros functionality

$autoescape : int

-> @see \FWK\Enums\TwigAutoescape

$themeName : string = null

-> Set the theme name overwriting the Theme->getInstance->getName()

Tags
see
TwigAutoescape
Return values
TwigLoader

setType()

This method sets the response type when execute self::run()

protected abstract setType() : void
Tags
abstract
see
self::run()
Return values
void

userExists()

protected userExists(string $value) : bool
Parameters
$value : string
Return values
bool

validateLoggedIn()

This method validate if the session is logged in

protected abstract validateLoggedIn() : void
Tags
abstract
Return values
void

validateSalesAgent()

This method validate if the session is sales agent

protected abstract validateSalesAgent() : void
Tags
abstract
Return values
void

Search results