/
Mailer.php
51 lines (32 loc) · 1.35 KB
/
Mailer.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
<?php
class Engine_Mailer_Mailer {
private static $_instance = null;
///Condition 2 - Locked down the constructor
private function __construct() {
}
//Prevent any oustide instantiation of this class
///Condition 3 - Prevent any object or instance of that class to be cloned
private function __clone() {
}
//Prevent any copy of this object
///Condition 4 - Have a single globally accessible static method
public static function getInstance() {
if (!is_object(self::$_instance)){ //or if( is_null(self::$_instance) ) or if( self::$_instance == null )
$objCore = Engine_Core_Core::getInstance();
$appSetting = $objCore->getAppSetting();
switch ($appSetting->mailSelector) {
case 'Mandrill':
self::$_instance = Engine_Mailer_MandrillApp_Mailer::getInstance();
break;
case 'SendGrid':
self::$_instance = Engine_Mailer_SendGrid_Mailer::getInstance();
break;
default:
throw new Zend_Controller_Action_Exception('Invalid Mail selector Passed', 500);
break;
}
}
return self::$_instance;
}
}
?>