Pimcore\Console\Command\InternalNewsletterDocumentSendCommand::execute PHP Method

execute() protected method

protected execute ( Symfony\Component\Console\Input\InputInterface $input, Symfony\Component\Console\Output\OutputInterface $output )
$input Symfony\Component\Console\Input\InputInterface
$output Symfony\Component\Console\Output\OutputInterface
    protected function execute(InputInterface $input, OutputInterface $output)
    {
        $sendingId = $input->getArgument("sendingId");
        $tmpStore = Model\Tool\TmpStore::get($sendingId);
        if (empty($tmpStore)) {
            Logger::alert("No sending configuration for {$sendingId} found. Cannot send newsletter.");
            exit;
        }
        $data = $tmpStore->getData();
        if ($data['inProgress']) {
            Logger::alert("Cannot send newsletters because there's already one active sending process.");
            exit;
        }
        $data['inProgress'] = 1;
        $tmpStore->setData($data);
        $tmpStore->update();
        $document = Model\Document\Newsletter::getById($data['documentId']);
        $addressSourceAdapterName = $data['addressSourceAdapterName'];
        $adapterParams = $data['adapterParams'];
        $adapterClass = "\\Pimcore\\Document\\Newsletter\\AddressSourceAdapter\\" . ucfirst($addressSourceAdapterName);
        /**
         * @var $addressAdapter \Pimcore\Document\Newsletter\AddressSourceAdapterInterface
         */
        $addressAdapter = new $adapterClass($adapterParams);
        if ($document->getSendingMode() == Newsletter::SENDING_MODE_BATCH) {
            $this->doSendMailInBatchMode($document, $addressAdapter, $sendingId);
        } else {
            $this->doSendMailInSingleMode($document, $addressAdapter, $sendingId);
        }
        Model\Tool\TmpStore::delete($sendingId);
    }