AddressBookEditController
extends BaseHtmlController
in package
Uses
AddDefaultCountryAndLocationsTrait
This is the user address book edit controller.
This class extends BaseHtmlController (FWK\Core\Controllers\BaseHtmlController), see this class.
Tags
Table of Contents
ADDRESS_FORM | = 'addressForm' | |
---|---|---|
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' |
DEFAULT_SELECTED_COUNTRY | = 'defaultSelectedCountry' | |
DEFAULT_SELECTED_COUNTRY_LOCATIONS | = 'defaultSelectedCountryLocations' | |
PREFIX | = 'prefix' | |
$availableParams | : array<string|int, mixed> | |
$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> |
$salesAgentRequired | This attribute define if the controller required a sales Agent in session | : bool |
$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 |
__construct() | Constructor. | : mixed |
getGlobalDataKeys() | This method returns the global data keys | : 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> |
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 |
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 |
getDefaultCountry() | returns default country | : CountrySettings |
getDefaultCountryLocations() | returns default selected country locations | : array<string|int, mixed> |
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 |
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 |
getTheme() | : Theme | |
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 |
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() | {@inheritdoc} | : void |
setControllerBaseBatchData() | {@inheritdoc} | : void |
setControllerBaseData() | This method is in charge of defining the basic data necessary for the correct operation of the controller. | : void |
setData() | {@inheritdoc} | : 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 |
validateLoggedIn() | This method validate if the session is logged in | : void |
validateSalesAgent() | This method validate if the session is sales agent | : void |
Constants
ADDRESS_FORM
public
mixed
ADDRESS_FORM
= 'addressForm'
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'
DEFAULT_SELECTED_COUNTRY
public
mixed
DEFAULT_SELECTED_COUNTRY
= 'defaultSelectedCountry'
DEFAULT_SELECTED_COUNTRY_LOCATIONS
public
mixed
DEFAULT_SELECTED_COUNTRY_LOCATIONS
= 'defaultSelectedCountryLocations'
PREFIX
public
mixed
PREFIX
= 'prefix'
Properties
$availableParams
protected
array<string|int, mixed>
$availableParams
= []
$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
$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
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> —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
Return values
mixed|null —getRequestParams()
Returns a array with de filtered parameters
public
getRequestParams() : array<string|int, mixed>
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
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
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
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
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 —forbiddenSimulatedUser()
This method validate if the session is a simulated user
protected
abstract forbiddenSimulatedUser() : void
Tags
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 —getDefaultCountry()
returns default country
protected
getDefaultCountry() : CountrySettings
Return values
CountrySettings —getDefaultCountryLocations()
returns default selected country locations
protected
getDefaultCountryLocations() : array<string|int, mixed>
Return values
array<string|int, mixed> —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
Return values
mixed —getRoute()
This method returns the route of this controller
protected
getRoute() : Route
Return values
Route —getSeoItems()
This method returns the metatags value
protected
getSeoItems() : SeoItems|null
Return values
SeoItems|null —getSession()
This method returns the session value, if the request is cacheable returns null
protected
getSession() : Session|null
Return values
Session|null —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 —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()
{@inheritdoc}
protected
setBatchData(BatchRequests $request) : void
Parameters
- $request : BatchRequests
Tags
Return values
void —setControllerBaseBatchData()
{@inheritdoc}
protected
final setControllerBaseBatchData(BatchRequests $requests) : void
Parameters
- $requests : BatchRequests
Tags
Return values
void —setControllerBaseData()
This method is in charge of defining the basic data necessary for the correct operation of the controller.
protected
setControllerBaseData() : void
Tags
Return values
void —setData()
{@inheritdoc}
protected
setData([array<string|int, mixed> $additionalData = [] ]) : void
Parameters
- $additionalData : array<string|int, mixed> = []
Tags
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
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
Return values
TwigLoader —setType()
This method sets the response type when execute self::run()
protected
abstract setType() : void
Tags
Return values
void —validateLoggedIn()
This method validate if the session is logged in
protected
abstract validateLoggedIn() : void
Tags
Return values
void —validateSalesAgent()
This method validate if the session is sales agent
protected
abstract validateSalesAgent() : void