FormFactory
in package
This is the FormFactory class, a factory of Form instances.
This class facilitates the creation of some predefined Forms:
- Login
- Delete account
- Lost password
- Product contact
- Product recommend
- Newsletter
- Stock alert
- Change password
- Comment
- Search
- Send Wishlist
- ...
Tags
Table of Contents
ATTRIBUTE_WILDCARD | = '{{attributeWildcard}}' | |
---|---|---|
BLOG_CATEGORY_SUBSCRIBE | = 'categorySubscribe' | |
BLOG_POST_SUBSCRIBE | = 'postSubscribe' | |
BLOG_SUBSCRIBE | = 'subscribe' | |
CLASS_WILDCARD | = '{{class}}' | |
LOGIN_USERNAME_VALIDATION_EMAIL | = 'email' | |
LOGIN_USERNAME_VALIDATION_ID | = 'id' | |
RETURN_POINTS | = 'returnPoints' | |
RETURN_PRODUCTS | = 'returnProducts' | |
SALES_AGENT_CUSTOMERS | = 'salesAgentCustomers' | |
SALES_AGENT_SALES | = 'salesAgentSales' | |
SET_USER_TYPE_ADD_CUSTOMER | = 'customer' | |
SET_USER_TYPE_ADD_USER | = 'user' | |
SET_USER_TYPE_ADD_USER_FAST_REGISTER | = 'fastRegister' | |
getAddress() | This static method returns the address Form . | : Form |
getBlogSubscribe() | This static method returns the blog subscribe form. | : Form|null |
getComment() | This static method returns the products 'comment' Form. | : Form |
getContact() | This static method returns the 'contact' Form. | : Form |
getDeleteAccount() | This static method returns the 'delete account' Form. | : Form |
getDeletePaymentCard() | This static method returns the 'delete payment card' Form. | : Form |
getDeleteWishlist() | This static method returns the 'delete wishlist' Form. | : Form |
getLogin() | This static method returns the 'login' Form. | : Form |
getLostPassword() | This static method returns the 'lost password' Form. | : Form |
getNewPassword() | This static method returns the 'new password' Form. | : Form |
getNewsletter() | This static method returns the 'newsletter' Form. | : Form|null |
getPhysicalLocations() | This static method returns the physical locations Form. | : Form |
getPostComment() | This static method returns the posts 'comment' Form. | : Form |
getProductContact() | This static method returns the 'product contact' Form. | : Form |
getProductRecommend() | This static method returns the 'product recommend' Form. | : Form |
getReturnRequest() | This static method returns the return products Form. | : Form |
getSalesAgentCustomers() | This static method returns the sales agent customer Form. | : Form |
getSalesAgentSales() | This static method returns the sales agent sales Form. | : Form |
getSearch() | This static method returns the 'search' Form. | : Form |
getSendMail() | This static method returns the 'send mail' Form. | : Form |
getSendWishlist() | This static method returns the 'send wishlist' Form. | : Form |
getStockAlert() | This static method returns the 'stock alert' Form. | : Form |
getUpdatePassword() | This static method returns the 'update password' Form. | : Form |
getUserKeyElement() | This static method returns the 'user key' Input Element. | : Element |
setUser() | This static method returns the 'set user' Form for the current user of the commerce session. | : Form |
getConfiguration() | : Configuration |
Constants
ATTRIBUTE_WILDCARD
public
mixed
ATTRIBUTE_WILDCARD
= '{{attributeWildcard}}'
BLOG_CATEGORY_SUBSCRIBE
public
mixed
BLOG_CATEGORY_SUBSCRIBE
= 'categorySubscribe'
BLOG_POST_SUBSCRIBE
public
mixed
BLOG_POST_SUBSCRIBE
= 'postSubscribe'
BLOG_SUBSCRIBE
public
mixed
BLOG_SUBSCRIBE
= 'subscribe'
CLASS_WILDCARD
public
mixed
CLASS_WILDCARD
= '{{class}}'
LOGIN_USERNAME_VALIDATION_EMAIL
public
mixed
LOGIN_USERNAME_VALIDATION_EMAIL
= 'email'
LOGIN_USERNAME_VALIDATION_ID
public
mixed
LOGIN_USERNAME_VALIDATION_ID
= 'id'
RETURN_POINTS
public
mixed
RETURN_POINTS
= 'returnPoints'
RETURN_PRODUCTS
public
mixed
RETURN_PRODUCTS
= 'returnProducts'
SALES_AGENT_CUSTOMERS
public
mixed
SALES_AGENT_CUSTOMERS
= 'salesAgentCustomers'
SALES_AGENT_SALES
public
mixed
SALES_AGENT_SALES
= 'salesAgentSales'
SET_USER_TYPE_ADD_CUSTOMER
public
mixed
SET_USER_TYPE_ADD_CUSTOMER
= 'customer'
SET_USER_TYPE_ADD_USER
public
mixed
SET_USER_TYPE_ADD_USER
= 'user'
SET_USER_TYPE_ADD_USER_FAST_REGISTER
public
mixed
SET_USER_TYPE_ADD_USER_FAST_REGISTER
= 'fastRegister'
Methods
getAddress()
This static method returns the address Form .
public
static getAddress(string $type[, string|null $address = null ][, bool $simulatedUser = false ]) : Form
Parameters
- $type : string
-
SetUserTypeForms::SHIPPING | SetUserTypeForms::BILLING
- $address : string|null = null
- $simulatedUser : bool = false
Tags
Return values
Form —getBlogSubscribe()
This static method returns the blog subscribe form.
public
static getBlogSubscribe(string $type, int $id) : Form|null
Parameters
- $type : string
-
FormFactory::BLOG_SUBSCRIBE | FormFactory::BLOG_CATEGORY_SUBSCRIBE | FormFactory::BLOG_POST_SUBSCRIBE
- $id : int
Tags
Return values
Form|null —getComment()
This static method returns the products 'comment' Form.
public
static getComment(int $id[, string $nick = '' ]) : Form
Parameters
- $id : int
-
If set, it autofills the corresponding input of the form.
- $nick : string = ''
Return values
Form —getContact()
This static method returns the 'contact' Form.
public
static getContact([User $User = null ]) : Form
The given parameters (firstName, lastName, email or phone) will autofill the corresponding inputs if you provide them.
Parameters
- $User : User = null
-
If set, it autofills the corresponding input of the form.
Return values
Form —getDeleteAccount()
This static method returns the 'delete account' Form.
public
static getDeleteAccount() : Form
Return values
Form —getDeletePaymentCard()
This static method returns the 'delete payment card' Form.
public
static getDeletePaymentCard(int $id[, string $token = '' ]) : Form
Parameters
- $id : int
- $token : string = ''
Return values
Form —getDeleteWishlist()
This static method returns the 'delete wishlist' Form.
public
static getDeleteWishlist() : Form
Return values
Form —getLogin()
This static method returns the 'login' Form.
public
static getLogin([array<string|int, mixed> $plugins = [] ]) : Form
Parameters
- $plugins : array<string|int, mixed> = []
Return values
Form —getLostPassword()
This static method returns the 'lost password' Form.
public
static getLostPassword() : Form
Return values
Form —getNewPassword()
This static method returns the 'new password' Form.
public
static getNewPassword([string $hash = '' ]) : Form
Parameters
- $hash : string = ''
Return values
Form —getNewsletter()
This static method returns the 'newsletter' Form.
public
static getNewsletter() : Form|null
Return values
Form|null —getPhysicalLocations()
This static method returns the physical locations Form.
public
static getPhysicalLocations([User|null $user = null ]) : Form
Parameters
- $user : User|null = null
-
Sets the user to add the default value to the country selector
Return values
Form —getPostComment()
This static method returns the posts 'comment' Form.
public
static getPostComment(int $id[, string $nick = '' ]) : Form
Parameters
- $id : int
-
If set, it autofills the corresponding input of the form.
- $nick : string = ''
-
If set, it autofills the corresponding input of the form.
Return values
Form —getProductContact()
This static method returns the 'product contact' Form.
public
static getProductContact(int $id[, string $name = '' ][, string $firstName = '' ][, string $lastName = '' ][, string $email = '' ][, string $phone = '' ]) : Form
The given parameters (id, firstName, lastName, email or phone) will autofill the corresponding inputs if you provide them.
Parameters
- $id : int
-
If set, it autofills the corresponding input of the form.
- $name : string = ''
- $firstName : string = ''
-
If set, it autofills the corresponding input of the form.
- $lastName : string = ''
-
If set, it autofills the corresponding input of the form.
- $email : string = ''
-
If set, it autofills the corresponding input of the form.
- $phone : string = ''
-
If set, it autofills the corresponding input of the form.
Return values
Form —getProductRecommend()
This static method returns the 'product recommend' Form.
public
static getProductRecommend(int $id[, string $userName = '' ][, string $userEmail = '' ]) : Form
The given parameters (id, username, userEmail) will autofill the corresponding inputs if you provide them.
Parameters
- $id : int
-
If set, it autofills the corresponding input of the form.
- $userName : string = ''
-
If set, it autofills the corresponding input of the form.
- $userEmail : string = ''
-
If set, it autofills the corresponding input of the form.
Return values
Form —getReturnRequest()
This static method returns the return products Form.
public
static getReturnRequest(int $id, ElementCollection $returnProducts, ElementCollection $returnPoints) : Form
Parameters
- $id : int
- $returnProducts : ElementCollection
-
It autofills the corresponding input of the form.
- $returnPoints : ElementCollection
-
If set, it autofills the corresponding input of the form, else generate an input hidden than will be fill with the corresponding return delivery id
Return values
Form —getSalesAgentCustomers()
This static method returns the sales agent customer Form.
public
static getSalesAgentCustomers([string $q = '' ][, DateTime|null $fromDate = null ][, DateTime|null $toDate = null ]) : Form
Parameters
- $q : string = ''
- $fromDate : DateTime|null = null
- $toDate : DateTime|null = null
Return values
Form —getSalesAgentSales()
This static method returns the sales agent sales Form.
public
static getSalesAgentSales([DateTime|null $fromDate = null ][, DateTime|null $toDate = null ]) : Form
Parameters
- $fromDate : DateTime|null = null
- $toDate : DateTime|null = null
Return values
Form —getSearch()
This static method returns the 'search' Form.
public
static getSearch([bool $small = true ][, string $formSubmitPath = null ]) : Form
Parameters
- $small : bool = true
-
Set classes and attributes to show version normal or small
- $formSubmitPath : string = null
-
If set, it fill the submit url path. Default value RoutePaths::getPath(RouteType::SEARCH)
Return values
Form —getSendMail()
This static method returns the 'send mail' Form.
public
static getSendMail([string $typeFormFields = 'default' ]) : Form
string $typeFormFields
Parameters
- $typeFormFields : string = 'default'
Return values
Form —getSendWishlist()
This static method returns the 'send wishlist' Form.
public
static getSendWishlist() : Form
Return values
Form —getStockAlert()
This static method returns the 'stock alert' Form.
public
static getStockAlert() : Form
Return values
Form —getUpdatePassword()
This static method returns the 'update password' Form.
public
static getUpdatePassword() : Form
Return values
Form —getUserKeyElement()
This static method returns the 'user key' Input Element.
public
static getUserKeyElement() : Element
Tags
Return values
Element —setUser()
This static method returns the 'set user' Form for the current user of the commerce session.
public
static setUser([string $formUserType = '' ][, User|null $user = null ][, ElementCollection|null $userCustomTags = null ][, bool $showUserCustomTags = true ][, bool $showAddressBook = true ]) : Form
Parameters
- $formUserType : string = ''
-
To indicate the type of user. Possible values: FormFactory::SET_USER_TYPE_ADD_USER (by default), FormFactory::SET_USER_TYPE_ADD_CUSTOMER, SET_USER_TYPE_ADD_USER_FAST_REGISTER.
- $user : User|null = null
-
Sets the user for add default values to the form inputs
- $userCustomTags : ElementCollection|null = null
-
Sets the user custom tags to add in the form
- $showUserCustomTags : bool = true
-
Define if the user custom tags must be show
- $showAddressBook : bool = true
-
Define if the address book must be show
Tags
Return values
Form —getConfiguration()
protected
static getConfiguration() : Configuration