Files
aux-bieaux-legumes/local/modules/CadeauBienvenue/CadeauBienvenue.php

54 lines
2.2 KiB
PHP

<?php
/*************************************************************************************/
/* This file is part of the Thelia package. */
/* */
/* Copyright (c) OpenStudio */
/* email : dev@thelia.net */
/* web : http://www.thelia.net */
/* */
/* For the full copyright and license information, please view the LICENSE.txt */
/* file that was distributed with this source code. */
/*************************************************************************************/
namespace CadeauBienvenue;
use Thelia\Log\Tlog;
use Thelia\Module\BaseModule;
use Propel\Runtime\Connection\ConnectionInterface;
use Propel\Runtime\Exception\PropelException;
use Thelia\Model\Message;
use Thelia\Model\MessageQuery;
class CadeauBienvenue extends BaseModule
{
/** @var string */
const DOMAIN_NAME = 'cadeaubienvenue';
/** @var string */
const VARIABLE_MONTANT_CODE_PROMO = 'cadeau_bienvenue.montant_coupon';
/** @var string */
const MESSAGE_MAIL_CLIENT = 'code_promo_nouveau_client';
public function postActivation(ConnectionInterface $con = null)
{
if (null === MessageQuery::create()->findOneByName(self::MESSAGE_MAIL_CLIENT)) {
$message = new Message();
try {
$message
->setName(self::MESSAGE_MAIL_CLIENT)
->setHtmlTemplateFileName('code-promo-bienvenue.html')
->setTextTemplateFileName('code-promo-bienvenue.txt')
->setSecured(0)
->setLocale('fr_FR')
->setTitle('Mail envoyé à tout nouveau client, avec un code promo')
->setSubject('Bienvenue chez AuxBieauxLegumes.fr - Code promo')
->save();
} catch (PropelException $e) {
Tlog::getInstance()->error($e->getMessage());
}
}
}
}