当前位置: 首页>>代码示例>>PHP>>正文


PHP EmailAddress::setOptions方法代码示例

本文整理汇总了PHP中Zend\Validator\EmailAddress::setOptions方法的典型用法代码示例。如果您正苦于以下问题:PHP EmailAddress::setOptions方法的具体用法?PHP EmailAddress::setOptions怎么用?PHP EmailAddress::setOptions使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Zend\Validator\EmailAddress的用法示例。


在下文中一共展示了EmailAddress::setOptions方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: __construct

 public function __construct()
 {
     $validatorEmail = new EmailAddress();
     $validatorEmail->setOptions(array('domain' => FALSE));
     $this->add(array('name' => 'email', 'filters' => array(array('name' => 'StringTrim'), array('name' => 'StripTags')), 'validators' => array($validatorEmail, array('name' => 'NotEmpty', 'options' => array('messages' => array('isEmpty' => 'Digite corretamente o seu e-mail!'))))));
     $this->add(array('name' => 'senha', 'required' => true, 'filters' => array(array('name' => 'StringTrim'), array('name' => 'StripTags'))));
 }
开发者ID:RodrigoAngeloValentini,项目名称:curso-zf2,代码行数:7,代码来源:Login.php

示例2: testSetOptions

 /**
  * Testing setOptions
  */
 public function testSetOptions()
 {
     $this->validator->setOptions(array('messages' => array(EmailAddress::INVALID => 'TestMessage')));
     $messages = $this->validator->getMessageTemplates();
     $this->assertEquals('TestMessage', $messages[EmailAddress::INVALID]);
     $oldHostname = $this->validator->getHostnameValidator();
     $this->validator->setOptions(array('hostnameValidator' => new Hostname(Hostname::ALLOW_ALL)));
     $hostname = $this->validator->getHostnameValidator();
     $this->assertNotEquals($oldHostname, $hostname);
 }
开发者ID:navassouza,项目名称:zf2,代码行数:13,代码来源:EmailAddressTest.php

示例3: validateAndCheckDiscountData

 /**
  * @param $data
  * @param bool $reservationId
  * @return array
  */
 public function validateAndCheckDiscountData($data, $reservationId = false)
 {
     $result = ['valid' => false, 'message' => ''];
     try {
         if ($reservationId) {
             /**
              * @var \DDD\Dao\Booking\Booking $reservationDao
              */
             $reservationDao = $this->getServiceLocator()->get('dao_booking_booking');
             $reservationData = $reservationDao->getDataForDiscountValidationById($reservationId);
             $data = ['email' => $reservationData->getGuestEmail(), 'aff_id' => $reservationData->getPartnerId()];
         }
         $visitor = new Container('visitor');
         if (!isset($data['aff_id']) && !is_null($visitor->partnerId) && (int) $visitor->partnerId) {
             $data['aff_id'] = (int) $visitor->partnerId;
         }
         $emailValidator = new EmailAddress();
         $emailValidator->setOptions(['domain' => true]);
         // validate Email for ginosiks
         if (isset($data['aff_id']) && $data['aff_id'] == self::SECRET_DISCOUNT_AFFILIATE_ID) {
             if (!isset($data['email']) || empty($data['email'])) {
                 $result['message'] .= "Email field is not submitted.\n";
             } elseif (!$emailValidator->isValid($data['email'])) {
                 $result['message'] .= "Email not valid.\n";
             } else {
                 /**
                  * @var UserManager $userManager
                  */
                 $userManager = $this->getServiceLocator()->get('dao_user_user_manager');
                 $userRow = $userManager->getUserIdByEmailAddress($data['email']);
                 // validate User
                 if (!$userRow['id']) {
                     $result['message'] .= "Email does not match the Ginosi User.\n";
                 } elseif ($userRow['system'] != 0 || $userRow['disabled'] != 0) {
                     $result['message'] .= "User disabled or system.\n";
                 } else {
                     $result['email'] = strtolower($data['email']);
                 }
             }
         }
         // validate Affiliate Id
         if (!isset($data['aff_id']) || !is_numeric($data['aff_id'])) {
             $result['message'] .= "Affiliate Id field is not submitted.\n";
         } else {
             $result['aff_id'] = (int) $data['aff_id'];
         }
         // get Affiliate Discount Value
         if (isset($result['aff_id'])) {
             /**
              * @var PartnersDAO $partnerDao
              */
             $partnerDao = $this->getServiceLocator()->get('dao_partners_partners');
             $partnerData = $partnerDao->getPartnerNameAndDiscountById($result['aff_id']);
             // check Affiliate Discount Value
             if (empty($partnerData['discount']) && $partnerData['discount'] <= 0) {
                 $result['message'] .= "Affiliate does not have discounts.\n";
             } else {
                 $result['discount_value'] = $partnerData['discount'];
                 $result['partner_name'] = $partnerData['partner_name'];
             }
         }
         // final judgment
         if (empty($result['message'])) {
             $result['valid'] = true;
             unset($result['message']);
         }
     } catch (\Exception $e) {
         $this->gr2logException($e, 'Cannot validate and check reservation discount data', $data);
     }
     return $result;
 }
开发者ID:arbi,项目名称:MyCode,代码行数:76,代码来源:BookingTicket.php

示例4: getEmailValidator

 public function getEmailValidator()
 {
     if ($this->emailValidator === NULL) {
         $validator = new EmailAddress();
         $validator->setOptions($this->getEmailConfig())->setMessages(array(EmailAddress::DOT_ATOM => $this->getErrorMessage('EMAILADDRESS::DOT_ATOM'), EmailAddress::INVALID => $this->getErrorMessage('EMAILADDRESS::INVALID'), EmailAddress::INVALID_FORMAT => $this->getErrorMessage('EMAILADDRESS::INVALID_FORMAT'), EmailAddress::INVALID_HOSTNAME => $this->getErrorMessage('EMAILADDRESS::INVALID_HOSTNAME'), EmailAddress::INVALID_LOCAL_PART => $this->getErrorMessage('EMAILADDRESS::INVALID_LOCAL_PART'), EmailAddress::INVALID_MX_RECORD => $this->getErrorMessage('EMAILADDRESS::INVALID_MX_RECORD'), EmailAddress::INVALID_SEGMENT => $this->getErrorMessage('EMAILADDRESS::INVALID_SEGMENT'), EmailAddress::LENGTH_EXCEEDED => $this->getErrorMessage('EMAILADDRESS::LENGTH_EXCEEDED'), EmailAddress::QUOTED_STRING => $this->getErrorMessage('EMAILADDRESS::QUOTED_STRING')));
         $this->setEmailValidator($validator);
     }
     return $this->emailValidator;
 }
开发者ID:b-medias,项目名称:bZF2,代码行数:9,代码来源:AbstractValidator.php


注:本文中的Zend\Validator\EmailAddress::setOptions方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。