Pimcore\Console\Command\InternalNewsletterDocumentSendCommand::doSendMailInSingleMode PHP Метод

doSendMailInSingleMode() защищенный Метод

protected doSendMailInSingleMode ( Newsletter $document, Pimcore\Document\Newsletter\AddressSourceAdapterInterface $addressAdapter, $sendingId )
$document Pimcore\Model\Document\Newsletter
$addressAdapter Pimcore\Document\Newsletter\AddressSourceAdapterInterface
    protected function doSendMailInSingleMode(Model\Document\Newsletter $document, AddressSourceAdapterInterface $addressAdapter, $sendingId)
    {
        $totalCount = $addressAdapter->getTotalRecordCount();
        //calculate page size based on total item count - with min page size 3 and max page size 10
        $fifth = $totalCount / 5;
        $limit = $fifth > 10 ? 10 : ($fifth < 3 ? 3 : intval($fifth));
        $offset = 0;
        $hasElements = true;
        while ($hasElements) {
            $tmpStore = Model\Tool\TmpStore::get($sendingId);
            $data = $tmpStore->getData();
            Logger::info("Sending newsletter " . $hasElements . " / " . $totalCount . " [" . $document->getId() . "]");
            $data['progress'] = round($offset / $totalCount * 100, 2);
            $tmpStore->setData($data);
            $tmpStore->update();
            $sendingParamContainers = $addressAdapter->getParamsForSingleSending($limit, $offset);
            foreach ($sendingParamContainers as $sendingParamContainer) {
                $mail = \Pimcore\Tool\Newsletter::prepareMail($document, $sendingParamContainer);
                \Pimcore\Tool\Newsletter::sendNewsletterDocumentBasedMail($mail, $sendingParamContainer);
                if (empty($tmpStore)) {
                    Logger::warn("Sending configuration for sending ID {$sendingId} was deleted. Cancelling sending process.");
                    exit;
                }
            }
            $offset += $limit;
            $hasElements = count($sendingParamContainers);
            \Pimcore::collectGarbage();
        }
    }