BuilderFactory.php 3.75 KB
Newer Older
Marcello Pivanti's avatar
Marcello Pivanti committed
1
<?php
Aster's avatar
Aster committed
2

Marcello Pivanti's avatar
Marcello Pivanti committed
3
/**
Aster's avatar
Aster committed
4
5
 * Lombardia Informatica S.p.A.
 * OPEN 2.0
Marcello Pivanti's avatar
Marcello Pivanti committed
6
 *
Aster's avatar
Aster committed
7
 * @see http://example.com Developers'community
8
9
 * @license GPLv3
 * @license https://opensource.org/licenses/gpl-3.0.html GNU General Public License version 3
Marcello Pivanti's avatar
Marcello Pivanti committed
10
 *
Aster's avatar
Aster committed
11
 * @package    elitedivision\amos\notificationmanager\base
Marcello Pivanti's avatar
Marcello Pivanti committed
12
 * @category   CategoryName
Aster's avatar
Aster committed
13
 * @author     Lombardia Informatica S.p.A.
Marcello Pivanti's avatar
Marcello Pivanti committed
14
15
 */

Aster's avatar
Aster committed
16
namespace elitedivision\amos\notificationmanager\base;
Marcello Pivanti's avatar
Marcello Pivanti committed
17

Aster's avatar
Aster committed
18
19
20
21
22
23
24
25
26
27
28
29
use elitedivision\amos\notificationmanager\base\builder\ContactAcceptedMailBuilder;
use elitedivision\amos\notificationmanager\base\builder\ContentImmediateMailBuilder;
use elitedivision\amos\notificationmanager\base\builder\ContentMailBuilder;
use elitedivision\amos\notificationmanager\base\builder\CustomMailBuilder;
use elitedivision\amos\notificationmanager\base\builder\NewsletterBuilder;
use elitedivision\amos\notificationmanager\base\builder\SleepingUserMailBuilder;
use elitedivision\amos\notificationmanager\base\builder\SuccessfulContentMailBuilder;
use elitedivision\amos\notificationmanager\base\builder\SuccessfulUserMailBuilder;
use elitedivision\amos\notificationmanager\base\builder\SuggestedLinkMailBuilder;
use elitedivision\amos\notificationmanager\base\builder\ValidatedMailBuilder;
use elitedivision\amos\notificationmanager\base\builder\ValidatorsMailBuilder;
use elitedivision\amos\notificationmanager\models\ChangeStatusEmail;
Marcello Pivanti's avatar
Marcello Pivanti committed
30
31
use yii\base\BaseObject;

Aster's avatar
Aster committed
32
33
/**
 * Class BuilderFactory
Aster's avatar
Aster committed
34
 * @package elitedivision\amos\notificationmanager\base
Aster's avatar
Aster committed
35
36
37
 */
class BuilderFactory extends BaseObject
{
Marcello Pivanti's avatar
Marcello Pivanti committed
38
39
40
41
42
    const CONTENT_MAIL_BUILDER = 1;
    const VALIDATORS_MAIL_BUILDER = 2;
    const VALIDATED_MAIL_BUILDER = 3;
    const CUSTOM_MAIL_BUILDER = 4;
    const CONTENT_IMMEDIATE_MAIL_BUILDER = 5;
Aster's avatar
Aster committed
43
44
45
46
47
48
49
    const CONTENT_SLEEPING_USER_BUILDER = 6;
    const CONTENT_SUCCESSFUL_CONTENT_BUILDER = 7;
    const CONTENT_SUCCESSFUL_USER_BUILDER = 8;
    const CONTENT_SUGGESTED_LINK_BUILDER = 9;
    const CONTENT_CONTACT_ACCEPTED_BUILDER = 10;
    const NEWSLETTER_BUILDER = 11;
    
Marcello Pivanti's avatar
Marcello Pivanti committed
50
    /**
Aster's avatar
Aster committed
51
     * @param int $type
Marcello Pivanti's avatar
Marcello Pivanti committed
52
53
54
55
     * @param ChangeStatusEmail|null $email
     * @param string|null $endStatus
     * @return ContentMailBuilder|CustomMailBuilder|ValidatedMailBuilder|ValidatorsMailBuilder|null
     */
Aster's avatar
Aster committed
56
57
    public function create($type, $email = null, $endStatus = null)
    {
Marcello Pivanti's avatar
Marcello Pivanti committed
58
        $obj = null;
Aster's avatar
Aster committed
59
60
        
        switch ($type) {
Marcello Pivanti's avatar
Marcello Pivanti committed
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
            case self::CONTENT_MAIL_BUILDER:
                $obj = new ContentMailBuilder();
                break;
            case self::CONTENT_IMMEDIATE_MAIL_BUILDER:
                $obj = new ContentImmediateMailBuilder();
                break;
            case self::VALIDATORS_MAIL_BUILDER:
                $obj = new ValidatorsMailBuilder();
                break;
            case self::VALIDATED_MAIL_BUILDER:
                $obj = new ValidatedMailBuilder();
                break;
            case self::CUSTOM_MAIL_BUILDER:
                $obj = new CustomMailBuilder(['emailConf' => $email, 'endStatus' => $endStatus]);
                break;
Aster's avatar
Aster committed
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
            case self::CONTENT_SLEEPING_USER_BUILDER:
                $obj = new SleepingUserMailBuilder();
                break;
            case self::CONTENT_SUCCESSFUL_CONTENT_BUILDER:
                $obj = new SuccessfulContentMailBuilder();
                break;
            case self::CONTENT_SUCCESSFUL_USER_BUILDER:
                $obj = new SuccessfulUserMailBuilder();
                break;
            case self::CONTENT_SUGGESTED_LINK_BUILDER:
                $obj = new SuggestedLinkMailBuilder();
                break;
            case self::CONTENT_CONTACT_ACCEPTED_BUILDER:
                $obj = new ContactAcceptedMailBuilder();
                break;
            case self::NEWSLETTER_BUILDER:
                $obj = new NewsletterBuilder();
                break;
Marcello Pivanti's avatar
Marcello Pivanti committed
94
        }
Aster's avatar
Aster committed
95
        
Marcello Pivanti's avatar
Marcello Pivanti committed
96
97
98
        return $obj;
    }
}