-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathModule.php
59 lines (47 loc) · 1.44 KB
/
Module.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<?php
namespace daxslab\contactform;
use yii\i18n\PhpMessageSource;
use Yii;
/**
* Class Module
* @package daxslab\contactform
*/
class Module extends \yii\base\Module
{
/**
* @var string email to send and receive email.
*/
public $email = null;
/**
* @var string message to show to set on flash when sending email.
*/
public $successMessage = null;
/**
* @var string message to show to set on flash if failed when sending email.
*/
public $errorMessage = null;
/**
* {@inheritdoc}
*/
public function init()
{
parent::init();
$app = Yii::$app;
if (!isset($app->get('i18n')->translations['contact*'])) {
$app->get('i18n')->translations['contact*'] = [
'class' => PhpMessageSource::className(),
'basePath' => __DIR__ . '/messages',
'sourceLanguage' => 'en-US'
];
}
$this->email = isset($this->email)
? $this->email
: Yii::$app->params['adminEmail'];
$this->successMessage= isset($this->successMessage)
? $this->successMessage
: Yii::t('contact', 'Thank you for contacting us. We will respond to you as soon as possible.');
$this->errorMessage = isset($this->errorMessage)
? $this->errorMessage
: Yii::t('contact', 'There was an error sending email. Please, try again later.');
}
}