Evaluates the DNC entries for the Contact against the Client settings.

@return $this

@throws ContactClientException
185695
private function evaluateDnc()
    {
        if ($this->test) {
            return $this;
        }
        $channels = explode(',', $this->contactClient->getDncChecks());
        if ($channels) {
            foreach ($channels as $channel) {
                $dncRepo = $this->getDncRepo();
                $dncRepo->setDispatcher($this->dispatcher);
                $dncEntries = $dncRepo->getEntriesByLeadAndChannel(
                    $this->contact,
                    $channel
                );

                // @todo - Support external DNC checking should it be needed in the future.
                // if (empty($dncEntries)) {
                //     $event = new ContactDncCheckEvent($this->contact, $channels, $dncEntries);
                //     $this->dispatcher->dispatch(ContactClientEvents::EXTERNAL_DNC_CHECK, $event);
                // }

                if (!empty($dncEntries)) {
                    foreach ($dncEntries as $dnc) {
                        $comments = !in_array($dnc->getComments(), ['user', 'system']) ? $dnc->getComments() : '';
                        throw new ContactClientException(
                            trim(
                                $this->translator->trans(
                                    'mautic.contactclient.sendcontact.error.dnc',
                                    [
                                        '%channel%'  => $this->getDncChannelName($channel),
                                        '%date%'     => $dnc->getDateAdded()->format('Y-m-d H:i:s e'),
                                        '%comments%' => $comments,
                                    ]
                                )
                            ),
                            0,
                            null,
                            Stat::TYPE_DNC,
                            false
                        );
                    }
                }
            }
        }

        return $this;
    }
1196786
private function setSenderInformation()
    {
        $senderName = $this->_checkoutSession->getLastRealOrder()->getCustomerName();
        // If Guest
        if (
            $senderName == (string)__('Guest')
            || $senderName == 'Convidado'
            || $senderName == 'Visitante'
                
        ) {
            $address = $this->getBillingAddress();
            $senderName = $address->getFirstname() . ' ' . $address->getLastname();
        }
        $this->_paymentRequest->setSender()->setName($senderName);
        $this->_paymentRequest->setSender()->setEmail($this->_checkoutSession
            ->getLastRealOrder()->getCustomerEmail());
        $this->setSenderPhone();
        
    }
1000848
public function setContactType($contactType)
    {
        $allowedValues = $this->getContactTypeAllowableValues();
        if (!in_array($contactType, $allowedValues)) {
            throw new \InvalidArgumentException(
                sprintf(
                    "Invalid value for 'contactType', must be one of '%s'",
                    implode("', '", $allowedValues)
                )
            );
        }
        $this->container['contactType'] = $contactType;

        return $this;
    }
60402
private function resetContact($contact)
    {
        if ($contact->getCustomerId() && $contact->getEmailImported()) {
            $contact->setEmailImported(\Dotdigitalgroup\Email\Model\Contact::EMAIL_CONTACT_NOT_IMPORTED);
            $this->contactResource->save($contact);
        } elseif (! $contact->getCustomerId() && $contact->getIsSubscriber() && $contact->getSubscriberImported()) {
            $contact->setSubscriberImported(\Dotdigitalgroup\Email\Model\Contact::EMAIL_CONTACT_NOT_IMPORTED);
            $this->contactResource->save($contact);
        }
    }
493206
public function execute(\Magento\Framework\Event\Observer $observer)
    {
        $numImported = $this->contactFactory->create()
            ->getNumberOfImportedContacs();

        $updated = $this->contactResource->resetAllContacts();

        $this->helper->log(
            '-- Imported contacts: ' . $numImported
            . ' reseted :  ' . $updated . ' --'
        );

        return $this;
    }
200078
public function setContactType($v)
    {
        if ($v !== null) {
            $valueSet = DealerContactInfoTableMap::getValueSet(DealerContactInfoTableMap::CONTACT_TYPE);
            if (!in_array($v, $valueSet)) {
                throw new PropelException(sprintf('Value "%s" is not accepted in this enumerated column', $v));
            }
            $v = array_search($v, $valueSet);
        }

        if ($this->contact_type !== $v) {
            $this->contact_type = $v;
            $this->modifiedColumns[DealerContactInfoTableMap::CONTACT_TYPE] = true;
        }


        return $this;
    }
891013
public function evaluateLimits()
    {
        $limits = $this->getRepository()->findLimit(
            $this->contactClient,
            $this->getLimitRules(),
            $this->getTimezone(),
            $this->dateSend
        );
        if ($limits) {
            throw new ContactClientException(
                'Not able to send contact to client due to an exceeded budget.',
                Codes::HTTP_TOO_MANY_REQUESTS,
                null,
                Stat::TYPE_LIMITS,
                false,
                null,
                $limits
            );
        }
    }
302504
public function setContactId($v)
    {
        if ($v !== null) {
            $v = (int) $v;
        }

        if ($this->contact_id !== $v) {
            $this->contact_id = $v;
            $this->modifiedColumns[DealerContactInfoTableMap::CONTACT_ID] = true;
        }

        if ($this->aDealerContact !== null && $this->aDealerContact->getId() !== $v) {
            $this->aDealerContact = null;
        }


        return $this;
    }
814375
public function deleteContactIds()
    {
        $conn = $this->getConnection();
        $num = $conn->update(
            $this->getTable(Schema::EMAIL_CONTACT_TABLE),
            ['contact_id' => $this->expressionFactory->create(["expression" => 'null'])],
            $conn->quoteInto(
                'contact_id is ?',
                $this->expressionFactory->create(["expression" => 'not null'])
            )
        );

        return $num;
    }
1007156
public function applyDetailSettings()
    {
        $dbLookup   = $this->util->getDbLookup();
        $localized  = $this->util->getLocalized();
        $translated = $this->util->getTranslated();

        if ($this->loginCheck) {
            $this->addLoginCheck();
        }
        $this->resetOrder();
        if ($this->has('gr2o_id_organization')) {
            $this->set('gr2o_id_organization',
                    'label', $this->_('Organization'),
                    'tab', $this->_('Identification'),
                    'multiOptions', $this->currentUser->getRespondentOrganizations()
                    );

            $this->set('gr2o_id_organization', 'default', $this->currentUser->getCurrentOrganizationId());

            if (count($this->currentUser->getAllowedOrganizations()) == 1) {
                $this->set('gr2o_id_organization', 'elementClass', 'Exhibitor');
            }
        }

        // The SSN
        if ($this->hashSsn !== self::SSN_HIDE) {
            $this->set('grs_ssn', 'label', $this->_('SSN'),
                    'tab', $this->_('Identification'));
        }

        $this->setIfExists('gr2o_patient_nr', 'label', $this->_('Respondent number'),
                'tab', $this->_('Identification'));

        $this->setIfExists('grs_initials_name',  'label', $this->_('Initials'));
        $this->setIfExists('grs_first_name',  'label', $this->_('First name'));
        $this->setIfExists('grs_surname_prefix', 'label', $this->_('Surname prefix'),
                'description', $this->_('de, ibn, Le, Mac, von, etc...'));

        $this->setIfExists('grs_last_name',   'label', $this->_('Last name'));

        $this->setIfExists('grs_partner_surname_prefix', 'label', $this->_('Partner surname prefix'),
                'description', $this->_('de, ibn, Le, Mac, von, etc...'));
        $this->setIfExists('grs_partner_last_name',   'label', $this->_('Partner last name'));

        $this->setIfExists('grs_gender',      'label', $this->_('Gender'),
                'multiOptions', $translated->getGenderHello()
                );

        $this->setIfExists('grs_birthday',    'label', $this->_('Birthday'),
                'dateFormat', \Zend_Date::DATE_MEDIUM
                );

        $this->setIfExists('gr2o_email',       'label', $this->_('E-Mail'),
                'tab', $this->_('Contact information'));
        $this->setIfExists('gr2o_mailable',   'label', $this->_('May be mailed'),
                'elementClass', 'radio',
                'separator', ' ',
                'multiOptions', $translated->getYesNo()
                );

        $this->setIfExists('gr2o_treatment',  'label', $this->_('Treatment'));
        $this->setIfExists('gr2o_comments',   'label', $this->_('Comments'));

        $this->setIfExists('grs_address_1',   'label', $this->_('Street'));
        $this->setIfExists('grs_address_2',   'label', ' ');

        // \MUtil_Echo::track($this->getItemsOrdered(), $this->getOrder('gr2o_email'));

        $this->setIfExists('grs_zipcode',     'label', $this->_('Zipcode'));
        $this->setIfExists('grs_city',        'label', $this->_('City'));
        $this->setIfExists('grs_iso_country', 'label', $this->_('Country'),
                'multiOptions', $localized->getCountries());

        $this->setIfExists('grs_phone_1',     'label', $this->_('Phone'));
        $this->setIfExists('grs_phone_2',     'label', $this->_('Phone 2'));
        $this->setIfExists('grs_phone_3',     'label', $this->_('Phone 3'));
        $this->setIfExists('grs_phone_4',     'label', $this->_('Phone 4'));

        $this->setIfExists('grs_iso_lang',    'label', $this->_('Language'),
                'multiOptions', $localized->getLanguages(),
                'tab', $this->_('Settings'), 'default', $this->project->getLocaleDefault());

        $this->setIfExists('gr2o_consent',    'label', $this->_('Consent'),
                'default', $this->util->getDefaultConsent(),
                'description', $this->_('Has the respondent signed the informed consent letter?'),
                'multiOptions', $dbLookup->getUserConsents()
                );

        $changers = $this->getChangersList();

        $this->setIfExists('gr2o_opened',     'label', $this->_('Opened'),
                'dateFormat', \Zend_Date::DATE_MEDIUM,
                'default', '',
                'elementClass', 'None',  // Has little use to show: is usually editor
                'formatFunction', array($translated, 'formatDateTime')
                );
        $this->setIfExists('gr2o_opened_by',  'label', $this->_('Opened'),
                'elementClass', 'None',  // Has little use to show: is usually editor
                'multiOptions', $changers
                );
        $this->setIfExists('gr2o_changed',    'label', $this->_('Changed on'),
                'dateFormat', \Zend_Date::DATE_MEDIUM,
                'default', '',
                'formatFunction', array($translated, 'formatDateTime')
                );
        $this->setIfExists('gr2o_changed_by', 'label', $this->_('Changed by'),
                'multiOptions', $changers
                );
        $this->setIfExists('gr2o_created',    'label', $this->_('Creation date'),
                'dateFormat', \Zend_Date::DATE_MEDIUM,
                'default', '',
                'formatFunction', array($translated, 'formatDateTime')
                );
        $this->setIfExists('gr2o_created_by', 'label', $this->_('Creation by'),
                'multiOptions', $changers
                );

        return $this;
    }
252744
public function evaluateDuplicate()
    {
        $duplicate = $this->getRepository()->findDuplicate(
            $this->contact,
            $this->contactClient,
            $this->getDuplicateRules(),
            $this->getUtmSource(),
            $this->getTimezone(),
            $this->dateSend
        );
        if ($duplicate) {
            throw new ContactClientException(
                'Skipping duplicate Contact.',
                Codes::HTTP_CONFLICT,
                null,
                Stat::TYPE_DUPLICATE,
                false,
                null,
                $duplicate
            );
        }
    }
1216264
public function evaluateDay($returnHours = false, $date = null)
    {
        $hours = $this->getScheduleHours();

        if (!$date) {
            $date = clone $this->now;
        }
        if ($hours) {
            $day = intval($date->format('N')) - 1;
            if (isset($hours[$day])) {
                if (
                    isset($hours[$day]->isActive)
                    && !$hours[$day]->isActive
                ) {
                    throw new ContactClientException(
                        'This contact client does not allow contacts on a '.$date->format('l').'.',
                        0,
                        null,
                        Stat::TYPE_SCHEDULE,
                        false
                    );
                } elseif ($returnHours) {
                    return $hours[$day];
                }
            }
        }

        return $this;
    }
343284
public function updateContact(Contact $contact): Contact
    {
        @trigger_error(sprintf('The %s() method is deprecated since version 0.8. Use update() instead.', __METHOD__), E_USER_DEPRECATED);

        return $this->update($contact);
    }
476519
public function setContact(\WobbleCode\UserBundle\Document\Contact $contact)
    {
        $this->contact = $contact;

        return $this;
    }
1142591
public function setPhone(?string $value) : Contact
    {

        if ($this->data['phone'] !== $value) {
            $this->data['phone'] = $value;
            $this->setModified('phone');
        }

        return $this;
    }
1171629
public function setAddress($value) : Contact
    {
        $this->validateJson($value);

        if ($this->data['address'] !== $value) {
            $this->data['address'] = $value;
            $this->setModified('address');
        }

        return $this;
    }
309934
public function addContacts(array $contacts): SecurityTxt
    {
        if (!$this->validContacts($contacts)) {
            throw new Exception('Contacts must be well-formed e-mails and/or URLs.');
        }

        foreach ($contacts as $contact) {
            $this->contacts[$contact] = true;
        }

        return $this;
    }