Magento 2 Documentation
2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
|
Public Member Functions | |
__construct (CustomerFactory $customerFactory, ManagerInterface $eventManager, StoreManagerInterface $storeManager, Random $mathRandom, Validator $validator, ValidationResultsInterfaceFactory $validationResultsDataFactory, AddressRepositoryInterface $addressRepository, CustomerMetadataInterface $customerMetadataService, CustomerRegistry $customerRegistry, PsrLogger $logger, Encryptor $encryptor, ConfigShare $configShare, StringHelper $stringHelper, CustomerRepositoryInterface $customerRepository, ScopeConfigInterface $scopeConfig, TransportBuilder $transportBuilder, DataObjectProcessor $dataProcessor, Registry $registry, CustomerViewHelper $customerViewHelper, DateTime $dateTime, CustomerModel $customerModel, ObjectFactory $objectFactory, ExtensibleDataObjectConverter $extensibleDataObjectConverter, CredentialsValidator $credentialsValidator=null, DateTimeFactory $dateTimeFactory=null, AccountConfirmation $accountConfirmation=null, SessionManagerInterface $sessionManager=null, SaveHandlerInterface $saveHandler=null, CollectionFactory $visitorCollectionFactory=null, SearchCriteriaBuilder $searchCriteriaBuilder=null) | |
resendConfirmation ($email, $websiteId=null, $redirectUrl='') | |
activate ($email, $confirmationKey) | |
activateById ($customerId, $confirmationKey) | |
authenticate ($username, $password) | |
validateResetPasswordLinkToken ($customerId, $resetPasswordLinkToken) | |
initiatePasswordReset ($email, $template, $websiteId=null) | |
resetPassword ($email, $resetToken, $newPassword) | |
getConfirmationStatus ($customerId) | |
createAccount (CustomerInterface $customer, $password=null, $redirectUrl='') | |
createAccountWithPasswordHash (CustomerInterface $customer, $hash, $redirectUrl='') | |
getDefaultBillingAddress ($customerId) | |
getDefaultShippingAddress ($customerId) | |
changePassword ($email, $currentPassword, $newPassword) | |
changePasswordById ($customerId, $currentPassword, $newPassword) | |
validate (CustomerInterface $customer) | |
isEmailAvailable ($customerEmail, $websiteId=null) | |
isCustomerInStore ($customerWebsiteId, $storeId) | |
isReadonly ($customerId) | |
isResetPasswordLinkTokenExpired ($rpToken, $rpTokenCreatedAt) | |
changeResetPasswordLinkToken ($customer, $passwordLinkToken) | |
sendPasswordReminderEmail ($customer) | |
sendPasswordResetConfirmationEmail ($customer) | |
getPasswordHash ($password) | |
![]() | |
createAccount (\Magento\Customer\Api\Data\CustomerInterface $customer, $password=null, $redirectUrl='') | |
createAccountWithPasswordHash (\Magento\Customer\Api\Data\CustomerInterface $customer, $hash, $redirectUrl='') | |
validate (\Magento\Customer\Api\Data\CustomerInterface $customer) | |
Data Fields | |
const | XML_PATH_REGISTER_EMAIL_TEMPLATE = 'customer/create_account/email_template' |
const | XML_PATH_REGISTER_NO_PASSWORD_EMAIL_TEMPLATE = 'customer/create_account/email_no_password_template' |
const | XML_PATH_REGISTER_EMAIL_IDENTITY = 'customer/create_account/email_identity' |
const | XML_PATH_REMIND_EMAIL_TEMPLATE = 'customer/password/remind_email_template' |
const | XML_PATH_FORGOT_EMAIL_TEMPLATE = 'customer/password/forgot_email_template' |
const | XML_PATH_FORGOT_EMAIL_IDENTITY = 'customer/password/forgot_email_identity' |
const | XML_PATH_IS_CONFIRM = 'customer/create_account/confirm' |
const | XML_PATH_CONFIRM_EMAIL_TEMPLATE = 'customer/create_account/email_confirmation_template' |
const | XML_PATH_CONFIRMED_EMAIL_TEMPLATE = 'customer/create_account/email_confirmed_template' |
const | NEW_ACCOUNT_EMAIL_REGISTERED = 'registered' |
const | NEW_ACCOUNT_EMAIL_REGISTERED_NO_PASSWORD = 'registered_no_password' |
const | NEW_ACCOUNT_EMAIL_CONFIRMATION = 'confirmation' |
const | NEW_ACCOUNT_EMAIL_CONFIRMED = 'confirmed' |
const | EMAIL_REMINDER = 'email_reminder' |
const | EMAIL_RESET = 'email_reset' |
const | XML_PATH_MINIMUM_PASSWORD_LENGTH = 'customer/password/minimum_password_length' |
const | XML_PATH_REQUIRED_CHARACTER_CLASSES_NUMBER = 'customer/password/required_character_classes_number' |
const | XML_PATH_RESET_PASSWORD_TEMPLATE = 'customer/password/reset_password_template' |
const | MIN_PASSWORD_LENGTH = 6 |
![]() | |
const | ACCOUNT_CONFIRMED = 'account_confirmed' |
const | ACCOUNT_CONFIRMATION_REQUIRED = 'account_confirmation_required' |
const | ACCOUNT_CONFIRMATION_NOT_REQUIRED = 'account_confirmation_not_required' |
const | MAX_PASSWORD_LENGTH = 256 |
Protected Member Functions | |
checkPasswordStrength ($password) | |
makeRequiredCharactersCheck ($password) | |
getMinPasswordLength () | |
sendEmailConfirmation (CustomerInterface $customer, $redirectUrl) | |
createPasswordHash ($password) | |
sendNewAccountEmail ( $customer, $type=self::NEW_ACCOUNT_EMAIL_REGISTERED, $backUrl='', $storeId='0', $sendemailStoreId=null) | |
sendPasswordResetNotificationEmail ($customer) | |
getWebsiteStoreId ($customer, $defaultStoreId=null) | |
getTemplateTypes () | |
sendEmailTemplate ( $customer, $template, $sender, $templateParams=[], $storeId=null, $email=null) | |
isConfirmationRequired ($customer) | |
canSkipConfirmation ($customer) | |
getAddressById (CustomerInterface $customer, $addressId) | |
getFullCustomerObject ($customer) | |
Protected Attributes | |
$logger | |
$stringHelper | |
$dataProcessor | |
$registry | |
$customerViewHelper | |
$dateTime | |
$objectFactory | |
$extensibleDataObjectConverter | |
$customerModel | |
$authentication | |
Handle various customer account actions
@SuppressWarnings(PHPMD.CouplingBetweenObjects) @SuppressWarnings(PHPMD.TooManyFields) @SuppressWarnings(PHPMD.ExcessiveClassComplexity)
Definition at line 64 of file AccountManagement.php.
__construct | ( | CustomerFactory | $customerFactory, |
ManagerInterface | $eventManager, | ||
StoreManagerInterface | $storeManager, | ||
Random | $mathRandom, | ||
Validator | $validator, | ||
ValidationResultsInterfaceFactory | $validationResultsDataFactory, | ||
AddressRepositoryInterface | $addressRepository, | ||
CustomerMetadataInterface | $customerMetadataService, | ||
CustomerRegistry | $customerRegistry, | ||
PsrLogger | $logger, | ||
Encryptor | $encryptor, | ||
ConfigShare | $configShare, | ||
StringHelper | $stringHelper, | ||
CustomerRepositoryInterface | $customerRepository, | ||
ScopeConfigInterface | $scopeConfig, | ||
TransportBuilder | $transportBuilder, | ||
DataObjectProcessor | $dataProcessor, | ||
Registry | $registry, | ||
CustomerViewHelper | $customerViewHelper, | ||
DateTime | $dateTime, | ||
CustomerModel | $customerModel, | ||
ObjectFactory | $objectFactory, | ||
ExtensibleDataObjectConverter | $extensibleDataObjectConverter, | ||
CredentialsValidator | $credentialsValidator = null , |
||
DateTimeFactory | $dateTimeFactory = null , |
||
AccountConfirmation | $accountConfirmation = null , |
||
SessionManagerInterface | $sessionManager = null , |
||
SaveHandlerInterface | $saveHandler = null , |
||
CollectionFactory | $visitorCollectionFactory = null , |
||
SearchCriteriaBuilder | $searchCriteriaBuilder = null |
||
) |
CustomerFactory | $customerFactory | |
ManagerInterface | $eventManager | |
StoreManagerInterface | $storeManager | |
Random | $mathRandom | |
Validator | $validator | |
ValidationResultsInterfaceFactory | $validationResultsDataFactory | |
AddressRepositoryInterface | $addressRepository | |
CustomerMetadataInterface | $customerMetadataService | |
CustomerRegistry | $customerRegistry | |
PsrLogger | $logger | |
Encryptor | $encryptor | |
ConfigShare | $configShare | |
StringHelper | $stringHelper | |
CustomerRepositoryInterface | $customerRepository | |
ScopeConfigInterface | $scopeConfig | |
TransportBuilder | $transportBuilder | |
DataObjectProcessor | $dataProcessor | |
Registry | $registry | |
CustomerViewHelper | $customerViewHelper | |
DateTime | $dateTime | |
CustomerModel | $customerModel | |
ObjectFactory | $objectFactory | |
ExtensibleDataObjectConverter | $extensibleDataObjectConverter | |
CredentialsValidator | null | $credentialsValidator | |
DateTimeFactory | null | $dateTimeFactory | |
AccountConfirmation | null | $accountConfirmation | |
SessionManagerInterface | null | $sessionManager | |
SaveHandlerInterface | null | $saveHandler | |
CollectionFactory | null | $visitorCollectionFactory | |
SearchCriteriaBuilder | null | $searchCriteriaBuilder | @SuppressWarnings(PHPMD.ExcessiveParameterList) |
Definition at line 369 of file AccountManagement.php.
activate | ( | $email, | |
$confirmationKey | |||
) |
Activate a customer account using a key that was sent in a confirmation email.
string | ||
string | $confirmationKey |
Implements AccountManagementInterface.
Definition at line 481 of file AccountManagement.php.
activateById | ( | $customerId, | |
$confirmationKey | |||
) |
Activate a customer account using a key that was sent in a confirmation email.@api
int | $customerId | |
string | $confirmationKey |
Implements AccountManagementInterface.
Definition at line 490 of file AccountManagement.php.
authenticate | ( | $username, | |
$password | |||
) |
Authenticate a customer by username and password
string | ||
string | $password |
Implements AccountManagementInterface.
Definition at line 530 of file AccountManagement.php.
|
protected |
Check whether confirmation may be skipped when registering using certain email address
CustomerInterface | $customer |
Definition at line 1315 of file AccountManagement.php.
changePassword | ( | $email, | |
$currentPassword, | |||
$newPassword | |||
) |
Change customer password.
string | ||
string | $currentPassword | |
string | $newPassword |
Implements AccountManagementInterface.
Definition at line 947 of file AccountManagement.php.
changePasswordById | ( | $customerId, | |
$currentPassword, | |||
$newPassword | |||
) |
Change customer password.
int | $customerId | |
string | $currentPassword | |
string | $newPassword |
Implements AccountManagementInterface.
Definition at line 960 of file AccountManagement.php.
changeResetPasswordLinkToken | ( | $customer, | |
$passwordLinkToken | |||
) |
Change reset password link token
Stores new reset password link token
CustomerInterface | $customer | |
string | $passwordLinkToken |
InputException |
Definition at line 1371 of file AccountManagement.php.
|
protected |
Make sure that password complies with minimum security requirements.
string | $password |
InputException |
Definition at line 698 of file AccountManagement.php.
createAccount | ( | CustomerInterface | $customer, |
$password = null , |
|||
$redirectUrl = '' |
|||
) |
Definition at line 797 of file AccountManagement.php.
createAccountWithPasswordHash | ( | CustomerInterface | $customer, |
$hash, | |||
$redirectUrl = '' |
|||
) |
@SuppressWarnings(PHPMD.CyclomaticComplexity) @SuppressWarnings(PHPMD.NPathComplexity)
Definition at line 821 of file AccountManagement.php.
|
protected |
Create a hash for the given password
string | $password |
Definition at line 1009 of file AccountManagement.php.
|
protected |
Get address by id
CustomerInterface | $customer | |
int | $addressId |
Definition at line 1453 of file AccountManagement.php.
getConfirmationStatus | ( | $customerId | ) |
Gets the account confirmation status.
int | $customerId |
Implements AccountManagementInterface.
Definition at line 781 of file AccountManagement.php.
getDefaultBillingAddress | ( | $customerId | ) |
Retrieve default billing address for the given customerId.
int | $customerId |
Implements AccountManagementInterface.
Definition at line 903 of file AccountManagement.php.
getDefaultShippingAddress | ( | $customerId | ) |
Retrieve default shipping address for the given customerId.
int | $customerId |
Implements AccountManagementInterface.
Definition at line 912 of file AccountManagement.php.
|
protected |
Create an object with data merged from Customer and CustomerSecure
CustomerInterface | $customer |
Definition at line 1470 of file AccountManagement.php.
|
protected |
getPasswordHash | ( | $password | ) |
Return hashed password, which can be directly saved to database.
string | $password |
Implements AccountManagementInterface.
Definition at line 1490 of file AccountManagement.php.
|
protected |
Get template types
self::NEW_ACCOUNT_EMAIL_REGISTERED welcome email, when confirmation is disabled and password is set self::NEW_ACCOUNT_EMAIL_REGISTERED_NO_PASSWORD welcome email, when confirmation is disabled and password is not set self::NEW_ACCOUNT_EMAIL_CONFIRMED welcome email, when confirmation is enabled and password is set self::NEW_ACCOUNT_EMAIL_CONFIRMATION email with confirmation link
Definition at line 1225 of file AccountManagement.php.
|
protected |
Get either first store ID from a set website or the provided as default
CustomerInterface | $customer | |
int | string | null | $defaultStoreId |
LocalizedException |
Definition at line 1209 of file AccountManagement.php.
initiatePasswordReset | ( | $email, | |
$template, | |||
$websiteId = null |
|||
) |
Send an email to the customer with a password reset link.
string | ||
string | $template | |
int | $websiteId |
Implements AccountManagementInterface.
Definition at line 574 of file AccountManagement.php.
|
protected |
Check if accounts confirmation is required in config
CustomerInterface | $customer |
Definition at line 1298 of file AccountManagement.php.
isCustomerInStore | ( | $customerWebsiteId, | |
$storeId | |||
) |
@inheritDoc
Implements AccountManagementInterface.
Definition at line 1071 of file AccountManagement.php.
isEmailAvailable | ( | $customerEmail, | |
$websiteId = null |
|||
) |
Check if given email is associated with a customer account in given website.
string | $customerEmail | |
int | $websiteId | If not set, will use the current websiteId |
Implements AccountManagementInterface.
Definition at line 1055 of file AccountManagement.php.
isReadonly | ( | $customerId | ) |
Check if customer can be deleted.
int | $customerId |
Implements AccountManagementInterface.
Definition at line 1136 of file AccountManagement.php.
isResetPasswordLinkTokenExpired | ( | $rpToken, | |
$rpTokenCreatedAt | |||
) |
Check if rpToken is expired
string | $rpToken | |
string | $rpTokenCreatedAt |
Definition at line 1339 of file AccountManagement.php.
|
protected |
Check password for presence of required character sets
string | $password |
Definition at line 742 of file AccountManagement.php.
resendConfirmation | ( | $email, | |
$websiteId = null , |
|||
$redirectUrl = '' |
|||
) |
Resend confirmation email.
string | ||
int | $websiteId | |
string | $redirectUrl |
Implements AccountManagementInterface.
Definition at line 458 of file AccountManagement.php.
resetPassword | ( | $email, | |
$resetToken, | |||
$newPassword | |||
) |
Reset customer password.
string | If empty value given then the customer will be matched by the RP token. | |
string | $resetToken | |
string | $newPassword |
Implements AccountManagementInterface.
Definition at line 664 of file AccountManagement.php.
|
protected |
Send either confirmation or welcome email after an account creation
CustomerInterface | $customer | |
string | $redirectUrl |
Definition at line 925 of file AccountManagement.php.
|
protected |
Send corresponding email template
CustomerInterface | $customer | |
string | $template | configuration path of email template |
string | $sender | configuration path of email identity |
array | $templateParams | |
int | null | $storeId | |
string |
Definition at line 1257 of file AccountManagement.php.
|
protected |
Send email with new account related information
CustomerInterface | $customer | |
string | $type | |
string | $backUrl | |
string | $storeId | |
string | $sendemailStoreId |
LocalizedException |
Definition at line 1154 of file AccountManagement.php.
sendPasswordReminderEmail | ( | $customer | ) |
Send email with new customer password
CustomerInterface | $customer |
Definition at line 1399 of file AccountManagement.php.
sendPasswordResetConfirmationEmail | ( | $customer | ) |
Send email with reset password confirmation link
CustomerInterface | $customer |
Definition at line 1426 of file AccountManagement.php.
|
protected |
Send email to customer when his password is reset
CustomerInterface | $customer |
Definition at line 1195 of file AccountManagement.php.
validate | ( | CustomerInterface | $customer | ) |
Definition at line 1030 of file AccountManagement.php.
validateResetPasswordLinkToken | ( | $customerId, | |
$resetPasswordLinkToken | |||
) |
Check if password reset token is valid.
int | $customerId | If null is given then a customer will be matched by the RP token. |
string | $resetPasswordLinkToken |
Implements AccountManagementInterface.
Definition at line 565 of file AccountManagement.php.
|
protected |
Definition at line 304 of file AccountManagement.php.
|
protected |
Definition at line 299 of file AccountManagement.php.
|
protected |
Definition at line 279 of file AccountManagement.php.
|
protected |
Definition at line 269 of file AccountManagement.php.
|
protected |
Definition at line 284 of file AccountManagement.php.
|
protected |
Definition at line 294 of file AccountManagement.php.
|
protected |
Definition at line 214 of file AccountManagement.php.
|
protected |
Definition at line 289 of file AccountManagement.php.
|
protected |
Definition at line 274 of file AccountManagement.php.
|
protected |
Definition at line 234 of file AccountManagement.php.
const EMAIL_REMINDER = 'email_reminder' |
Constants for types of emails to send out. pdl: forgot, remind, reset email templates
Definition at line 147 of file AccountManagement.php.
const EMAIL_RESET = 'email_reset' |
Definition at line 149 of file AccountManagement.php.
const MIN_PASSWORD_LENGTH = 6 |
Definition at line 169 of file AccountManagement.php.
const NEW_ACCOUNT_EMAIL_CONFIRMATION = 'confirmation' |
Welcome email, when confirmation is enabled
Definition at line 133 of file AccountManagement.php.
const NEW_ACCOUNT_EMAIL_CONFIRMED = 'confirmed' |
Confirmation email, when account is confirmed
Definition at line 140 of file AccountManagement.php.
const NEW_ACCOUNT_EMAIL_REGISTERED = 'registered' |
Constants for the type of new account email to be sent
Definition at line 119 of file AccountManagement.php.
const NEW_ACCOUNT_EMAIL_REGISTERED_NO_PASSWORD = 'registered_no_password' |
Welcome email, when password setting is required
Definition at line 126 of file AccountManagement.php.
const XML_PATH_CONFIRM_EMAIL_TEMPLATE = 'customer/create_account/email_confirmation_template' |
Definition at line 107 of file AccountManagement.php.
const XML_PATH_CONFIRMED_EMAIL_TEMPLATE = 'customer/create_account/email_confirmed_template' |
Definition at line 112 of file AccountManagement.php.
const XML_PATH_FORGOT_EMAIL_IDENTITY = 'customer/password/forgot_email_identity' |
Definition at line 96 of file AccountManagement.php.
const XML_PATH_FORGOT_EMAIL_TEMPLATE = 'customer/password/forgot_email_template' |
Definition at line 91 of file AccountManagement.php.
const XML_PATH_IS_CONFIRM = 'customer/create_account/confirm' |
Definition at line 102 of file AccountManagement.php.
const XML_PATH_MINIMUM_PASSWORD_LENGTH = 'customer/password/minimum_password_length' |
Configuration path to customer password minimum length
Definition at line 154 of file AccountManagement.php.
const XML_PATH_REGISTER_EMAIL_IDENTITY = 'customer/create_account/email_identity' |
Definition at line 81 of file AccountManagement.php.
const XML_PATH_REGISTER_EMAIL_TEMPLATE = 'customer/create_account/email_template' |
Configuration paths for email templates and identities
Definition at line 71 of file AccountManagement.php.
const XML_PATH_REGISTER_NO_PASSWORD_EMAIL_TEMPLATE = 'customer/create_account/email_no_password_template' |
Definition at line 76 of file AccountManagement.php.
const XML_PATH_REMIND_EMAIL_TEMPLATE = 'customer/password/remind_email_template' |
Definition at line 86 of file AccountManagement.php.
const XML_PATH_REQUIRED_CHARACTER_CLASSES_NUMBER = 'customer/password/required_character_classes_number' |
Configuration path to customer password required character classes number
Definition at line 159 of file AccountManagement.php.
const XML_PATH_RESET_PASSWORD_TEMPLATE = 'customer/password/reset_password_template' |
Definition at line 164 of file AccountManagement.php.