本文整理汇总了PHP中Thelia\Model\ConfigQuery::isCustomerEmailConfirmationEnable方法的典型用法代码示例。如果您正苦于以下问题:PHP ConfigQuery::isCustomerEmailConfirmationEnable方法的具体用法?PHP ConfigQuery::isCustomerEmailConfirmationEnable怎么用?PHP ConfigQuery::isCustomerEmailConfirmationEnable使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Thelia\Model\ConfigQuery
的用法示例。
在下文中一共展示了ConfigQuery::isCustomerEmailConfirmationEnable方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createOrUpdate
/**
* @param int $titleId customer title id (from customer_title table)
* @param string $firstname customer first name
* @param string $lastname customer last name
* @param string $address1 customer address
* @param string $address2 customer adress complement 1
* @param string $address3 customer adress complement 2
* @param string $phone customer phone number
* @param string $cellphone customer cellphone number
* @param string $zipcode customer zipcode
* @param string $city
* @param int $countryId customer country id (from Country table)
* @param string $email customer email, must be unique
* @param string $plainPassword customer plain password, hash is made calling setPassword method. Not mandatory parameter but an exception is thrown if customer is new without password
* @param string $lang
* @param int $reseller
* @param null $sponsor
* @param int $discount
* @param null $company
* @param null $ref
* @param bool $forceEmailUpdate true if the email address could be updated.
* @param int $stateId customer state id (from State table)
* @throws \Exception
* @throws \Propel\Runtime\Exception\PropelException
*/
public function createOrUpdate($titleId, $firstname, $lastname, $address1, $address2, $address3, $phone, $cellphone, $zipcode, $city, $countryId, $email = null, $plainPassword = null, $lang = null, $reseller = 0, $sponsor = null, $discount = 0, $company = null, $ref = null, $forceEmailUpdate = false, $stateId = null)
{
$this->setTitleId($titleId)->setFirstname($firstname)->setLastname($lastname)->setEmail($email, $forceEmailUpdate)->setPassword($plainPassword)->setReseller($reseller)->setSponsor($sponsor)->setDiscount($discount)->setRef($ref);
if (!is_null($lang)) {
$this->setLangId($lang);
}
$con = Propel::getWriteConnection(CustomerTableMap::DATABASE_NAME);
$con->beginTransaction();
try {
if ($this->isNew()) {
$address = new Address();
$address->setLabel(Translator::getInstance()->trans("Main address"))->setCompany($company)->setTitleId($titleId)->setFirstname($firstname)->setLastname($lastname)->setAddress1($address1)->setAddress2($address2)->setAddress3($address3)->setPhone($phone)->setCellphone($cellphone)->setZipcode($zipcode)->setCity($city)->setCountryId($countryId)->setStateId($stateId)->setIsDefault(1);
$this->addAddress($address);
if (ConfigQuery::isCustomerEmailConfirmationEnable()) {
$this->setConfirmationToken(bin2hex(random_bytes(32)));
}
} else {
$address = $this->getDefaultAddress();
$address->setCompany($company)->setTitleId($titleId)->setFirstname($firstname)->setLastname($lastname)->setAddress1($address1)->setAddress2($address2)->setAddress3($address3)->setPhone($phone)->setCellphone($cellphone)->setZipcode($zipcode)->setCity($city)->setCountryId($countryId)->setStateId($stateId)->save($con);
}
$this->save($con);
$con->commit();
} catch (PropelException $e) {
$con->rollBack();
throw $e;
}
}
示例2: getAuthentifiedUser
/**
* @see \Thelia\Core\Security\Authentication\AuthenticatorInterface::getAuthentifiedUser()
*/
public function getAuthentifiedUser()
{
if ($this->request->isMethod($this->options['required_method'])) {
if (!$this->loginForm->isValid()) {
throw new ValidatorException("Form is not valid.");
}
// Retreive user
$username = $this->getUsername();
$password = $this->loginForm->get($this->options['password_field_name'])->getData();
$user = $this->userProvider->getUser($username);
if ($user === null) {
throw new UsernameNotFoundException(sprintf("Username '%s' was not found.", $username));
}
// Check user password
$authOk = $user->checkPassword($password) === true;
if ($authOk !== true) {
throw new WrongPasswordException(sprintf("Wrong password for user '%s'.", $username));
}
if (ConfigQuery::isCustomerEmailConfirmationEnable() && $user instanceof Customer) {
// Customer (confirmation_token & enable) introduces since Thelia 2.4
// this test prevent backward compatibility and if option is enable when customer has been created
if ($user->getConfirmationToken() !== null && !$user->getEnable()) {
throw (new CustomerNotConfirmedException())->setUser($user);
}
}
return $user;
}
throw new \RuntimeException("Invalid method.");
}
示例3: create
public function create(CustomerCreateOrUpdateEvent $event, $eventName, EventDispatcherInterface $dispatcher)
{
$customer = new CustomerModel();
$plainPassword = $event->getPassword();
$this->createOrUpdateCustomer($customer, $event, $dispatcher);
if ($event->getNotifyCustomerOfAccountCreation()) {
$this->mailer->sendEmailToCustomer('customer_account_created', $customer, ['password' => $plainPassword]);
}
if (ConfigQuery::isCustomerEmailConfirmationEnable() && $customer->getConfirmationToken() !== null) {
$this->mailer->sendEmailToCustomer('customer_confirmation', $customer, ['customer' => $customer]);
}
}
示例4: createAction
/**
* Create a new customer.
* On success, redirect to success_url if exists, otherwise, display the same view again.
*/
public function createAction()
{
if (!$this->getSecurityContext()->hasCustomerUser()) {
$customerCreation = $this->createForm(FrontForm::CUSTOMER_CREATE);
try {
$form = $this->validateForm($customerCreation, "post");
$customerCreateEvent = $this->createEventInstance($form->getData());
$this->dispatch(TheliaEvents::CUSTOMER_CREATEACCOUNT, $customerCreateEvent);
$newCustomer = $customerCreateEvent->getCustomer();
// Newsletter
if (true === $form->get('newsletter')->getData()) {
$newsletterEmail = $newCustomer->getEmail();
$nlEvent = new NewsletterEvent($newsletterEmail, $this->getRequest()->getSession()->getLang()->getLocale());
$nlEvent->setFirstname($newCustomer->getFirstname());
$nlEvent->setLastname($newCustomer->getLastname());
// Security : Check if this new Email address already exist
if (null !== ($newsletter = NewsletterQuery::create()->findOneByEmail($newsletterEmail))) {
$nlEvent->setId($newsletter->getId());
$this->dispatch(TheliaEvents::NEWSLETTER_UPDATE, $nlEvent);
} else {
$this->dispatch(TheliaEvents::NEWSLETTER_SUBSCRIBE, $nlEvent);
}
}
if (ConfigQuery::isCustomerEmailConfirmationEnable() && !$newCustomer->getEnable()) {
return $this->generateRedirectFromRoute('customer.login.view');
}
$this->processLogin($customerCreateEvent->getCustomer());
$cart = $this->getSession()->getSessionCart($this->getDispatcher());
if ($cart->getCartItems()->count() > 0) {
$response = $this->generateRedirectFromRoute('cart.view');
} else {
$response = $this->generateSuccessRedirect($customerCreation);
}
return $response;
} catch (FormValidationException $e) {
$message = $this->getTranslator()->trans("Please check your input: %s", ['%s' => $e->getMessage()], Front::MESSAGE_DOMAIN);
} catch (\Exception $e) {
$message = $this->getTranslator()->trans("Sorry, an error occured: %s", ['%s' => $e->getMessage()], Front::MESSAGE_DOMAIN);
}
Tlog::getInstance()->error(sprintf("Error during customer creation process : %s. Exception was %s", $message, $e->getMessage()));
$customerCreation->setErrorMessage($message);
$this->getParserContext()->addForm($customerCreation)->setGeneralError($message);
// Redirect to error URL if defined
if ($customerCreation->hasErrorUrl()) {
return $this->generateErrorRedirect($customerCreation);
}
}
}