Commit f6050b25 authored by Stephane Bouvry's avatar Stephane Bouvry
Browse files

Migration de la commande de notification par email

parent 05b42f7b
Loading
Loading
Loading
Loading
Loading
+39 −0
Changes for module/Oscar/src/Oscar/Command/OscarNotificationsMailsPersonsCommand.php: 39 added lines, 0 removed lines.
Original line number Diff line number Diff line
<?php


namespace Oscar\Command;


use Oscar\Service\OscarUserContext;
use Oscar\Service\PersonService;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;

class OscarNotificationsMailsPersonsCommand extends OscarCommandAbstract
{
    protected static $defaultName = 'notifications:mails-persons';

    protected function configure()
    {
        $this
            ->setDescription("Déclenche la procédure d'envoi des notifications par mail")
        ;
    }

    protected function execute(InputInterface $input, OutputInterface $output)
    {
        $this->addOutputStyle($output);

        /** @var OscarUserContext $oscaruserContext */
        $oscaruserContext = $this->getServicemanager()->get(OscarUserContext::class);

        $io = new SymfonyStyle($input, $output);

        /** @var PersonService $oscarConfig */
        $personService = $this->getServicemanager()->get(PersonService::class);

        $personService->mailPersonsWithUnreadNotification();
    }
}
 No newline at end of file
+3 −6
Changes for module/Oscar/src/Oscar/Service/MailingService.php: 3 added lines, 6 removed lines.
Original line number Diff line number Diff line
@@ -77,9 +77,7 @@ class MailingService implements UseEntityManager, UseOscarConfigurationService,
                        $this->getOscarConfigurationService()->getConfiguration('mailer.transport.port'),
                        $this->getOscarConfigurationService()->getConfiguration('mailer.transport.security')))
                        ->setUsername($this->getOscarConfigurationService()->getConfiguration('mailer.transport.username'))
                        ->setPassword($this->getOscarConfigurationService()->getConfiguration('mailer.transport.password'))
                    ;

                        ->setPassword($this->getOscarConfigurationService()->getConfiguration('mailer.transport.password'));
                    break;

                case 'sendmail':
@@ -89,7 +87,6 @@ class MailingService implements UseEntityManager, UseOscarConfigurationService,
                case 'file':
                    return new SwiftTransportFileOutput($this->getOscarConfigurationService()->getConfiguration('mailer.transport.path', '/tmp'));


                default:
                    throw new OscarException("Le système de mailing n'est pas configuré.");
            }
@@ -107,8 +104,8 @@ class MailingService implements UseEntityManager, UseOscarConfigurationService,
    public function newMessage( $subject = "", $content = []){
        $msg = new \Swift_Message();
        $msg->setFrom($this->getOscarConfigurationService()->getConfiguration('mailer.from'))
            ->setSubject($this->getOscarConfigurationService()->getConfiguration('mailer.subjectPrefix') . $subject)
        ;
            ->setSubject($this->getOscarConfigurationService()->getConfiguration('mailer.subjectPrefix') . $subject);

        if( $content && is_array($content) && array_key_exists('body', $content) ){
            $body = $content['body'];
            $title = array_key_exists('title', $content) ? $content['title'] : $subject;