forked from craftcms/contact-form
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPlugin.php
60 lines (52 loc) · 1.21 KB
/
Plugin.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
60
<?php
/**
* @link https://craftcms.com/
* @copyright Copyright (c) Pixel & Tonic, Inc.
* @license MIT
*/
namespace craft\contactform;
use Craft;
use craft\contactform\models\Settings;
/**
* Class Plugin
*
* @property Settings $settings
* @property Mailer $mailer
* @method Settings getSettings()
*/
class Plugin extends \craft\base\Plugin
{
/**
* @inheritdoc
*/
public $hasCpSettings = true;
/**
* @return Mailer
*/
public function getMailer(): Mailer
{
return $this->get('mailer');
}
/**
* @inheritdoc
*/
protected function createSettingsModel(): Settings
{
return new Settings();
}
/**
* @inheritdoc
*/
protected function settingsHtml(): string
{
// Get and pre-validate the settings
$settings = $this->getSettings();
$settings->validate();
// Get the settings that are being defined by the config file
$overrides = Craft::$app->getConfig()->getConfigFromFile(strtolower($this->handle));
return Craft::$app->view->renderTemplate('contact-form/_settings', [
'settings' => $settings,
'overrides' => array_keys($overrides),
]);
}
}