GetProductCombinationDataController extends BaseJsonController Uses AddItemToBasketTrait

This is the GetProductCombinationDataController class.

This class extends BaseJsonController (FWK\Core\Controllers\BaseJsonController), see this class.

Tags
see
BaseJsonController

Table of Contents

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'
DATA  = 'data'
CODE  = 'code'
MESSAGE  = 'message'
REQUEST_ID  = 'requestId'
RESPONSE  = 'response'
STATUS  = 'status'
SUCCESS  = 'success'
$appliedParameters  : array<string|int, mixed>
$availableParams  : array<string|int, mixed>
$commerceCalendar  : IntlCalendar|null
$commerceDateTime  : DateTime|null
$getCombinationDataParametersGroup  : GetCombinationDataParametersGroup|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
$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
getFilterParams() {@inheritDoc}  : array<string|int, mixed>
getLanguageSheet() This method returns the language sheet of the controller's language  : array<string|int, mixed>
getOriginParams() {@inheritDoc}  : 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
initializeAppliedParameters() {@inheritDoc}  : void
isForbidden() This method returns if the request should be run as a forbidden request.  : bool
parseOptions()  : mixed
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() {@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() 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
validateLoggedIn() This method validate if the session is logged in  : void
validateSalesAgent() This method validate if the session is sales agent  : void

Constants

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'

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

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
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>

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

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

getLanguageSheet()

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

protected getLanguageSheet() : 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>

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

isForbidden()

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

protected isForbidden() : bool
Return values
bool

parseOptions()

protected parseOptions(array<string|int, mixed> $options, array<string|int, mixed> &$itemOptionsParameters, array<string|int, mixed> &$itemAppliedOptions) : mixed
Parameters
$options : array<string|int, mixed>
$itemOptionsParameters : array<string|int, mixed>
$itemAppliedOptions : array<string|int, mixed>
Return values
mixed

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

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

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