Passed
Push — master ( ad860d...af1517 )
by Sam
07:39
created
tests/Model/CommentNotifiableTestDataObject.php 1 patch
Indentation   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -11,36 +11,36 @@
 block discarded – undo
11 11
 
12 12
 class CommentNotifiableTestDataObject extends DataObject implements TestOnly
13 13
 {
14
-    private static $db = [
15
-        "Title" => "Varchar(255)",
16
-        "URLSegment" => "Varchar(255)",
17
-    ];
18
-
19
-    private static $has_one = [
20
-        'Author' => 'SilverStripe\Security\Member'
21
-    ];
22
-
23
-    private static $extensions = [
24
-        CommentNotifiable::class,
25
-        CommentsExtension::class
26
-    ];
27
-
28
-    private static $table_name = 'CommentNotifiableTestDataObject';
29
-
30
-    public function updateNotificationRecipients(&$list, $comment)
31
-    {
32
-        $author = $this->Author();
33
-
34
-        if ($author && $author->exists()) {
35
-            $list[] = $author->Email;
36
-        }
37
-    }
38
-
39
-    public function Link($action = false)
40
-    {
41
-        return Controller::join_links(
42
-            Director::baseURL(),
43
-            $this->URLSegment
44
-        );
45
-    }
14
+	private static $db = [
15
+		"Title" => "Varchar(255)",
16
+		"URLSegment" => "Varchar(255)",
17
+	];
18
+
19
+	private static $has_one = [
20
+		'Author' => 'SilverStripe\Security\Member'
21
+	];
22
+
23
+	private static $extensions = [
24
+		CommentNotifiable::class,
25
+		CommentsExtension::class
26
+	];
27
+
28
+	private static $table_name = 'CommentNotifiableTestDataObject';
29
+
30
+	public function updateNotificationRecipients(&$list, $comment)
31
+	{
32
+		$author = $this->Author();
33
+
34
+		if ($author && $author->exists()) {
35
+			$list[] = $author->Email;
36
+		}
37
+	}
38
+
39
+	public function Link($action = false)
40
+	{
41
+		return Controller::join_links(
42
+			Director::baseURL(),
43
+			$this->URLSegment
44
+		);
45
+	}
46 46
 }
Please login to merge, or discard this patch.
tests/CommentNotifierTest.php 1 patch
Indentation   +71 added lines, -71 removed lines patch added patch discarded remove patch
@@ -12,102 +12,102 @@
 block discarded – undo
12 12
 
13 13
 class CommentNotifierTest extends SapphireTest
14 14
 {
15
-    protected static $fixture_file = 'CommentNotifications.yml';
15
+	protected static $fixture_file = 'CommentNotifications.yml';
16 16
 
17
-    protected $oldhost = null;
17
+	protected $oldhost = null;
18 18
 
19
-    protected static $extra_dataobjects = [
20
-        CommentNotifiableTestDataObject::class
21
-    ];
19
+	protected static $extra_dataobjects = [
20
+		CommentNotifiableTestDataObject::class
21
+	];
22 22
 
23
-    protected static $extra_controllers = [
24
-        CommentNotifierTestController::class
25
-    ];
23
+	protected static $extra_controllers = [
24
+		CommentNotifierTestController::class
25
+	];
26 26
 
27
-    protected function setUp()
28
-    {
29
-        parent::setUp();
27
+	protected function setUp()
28
+	{
29
+		parent::setUp();
30 30
 
31
-        Config::modify()->set('Email', 'admin_email', '[email protected]');
32
-        $this->oldhost = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : null;
33
-        $_SERVER['HTTP_HOST'] = 'www.mysite.com';
34
-    }
31
+		Config::modify()->set('Email', 'admin_email', '[email protected]');
32
+		$this->oldhost = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : null;
33
+		$_SERVER['HTTP_HOST'] = 'www.mysite.com';
34
+	}
35 35
 
36
-    protected function tearDown()
37
-    {
38
-        $_SERVER['HTTP_HOST'] = $this->oldhost;
36
+	protected function tearDown()
37
+	{
38
+		$_SERVER['HTTP_HOST'] = $this->oldhost;
39 39
 
40
-        parent::tearDown();
41
-    }
40
+		parent::tearDown();
41
+	}
42 42
 
43
-    public function testSendEmail()
44
-    {
45
-        $author = $this->objFromFixture(Member::class, 'author');
46
-        $item1 = $this->objFromFixture(CommentNotifiableTestDataObject::class, 'item1');
47
-        $item2 = $this->objFromFixture(CommentNotifiableTestDataObject::class, 'item2');
48
-        $comment1 = $this->objFromFixture(Comment::class, 'comment1');
49
-        $comment2 = $this->objFromFixture(Comment::class, 'comment2');
50
-        $comment3 = $this->objFromFixture(Comment::class, 'comment3');
51
-        $controller = new CommentNotifierTestController();
43
+	public function testSendEmail()
44
+	{
45
+		$author = $this->objFromFixture(Member::class, 'author');
46
+		$item1 = $this->objFromFixture(CommentNotifiableTestDataObject::class, 'item1');
47
+		$item2 = $this->objFromFixture(CommentNotifiableTestDataObject::class, 'item2');
48
+		$comment1 = $this->objFromFixture(Comment::class, 'comment1');
49
+		$comment2 = $this->objFromFixture(Comment::class, 'comment2');
50
+		$comment3 = $this->objFromFixture(Comment::class, 'comment3');
51
+		$controller = new CommentNotifierTestController();
52 52
 
53
-        // Comment 1
54
-        $result = $controller->notifyCommentRecipient($comment1, $item1, $author);
55
-        $this->assertEmailSent('[email protected]', '[email protected]', 'A new comment has been posted');
53
+		// Comment 1
54
+		$result = $controller->notifyCommentRecipient($comment1, $item1, $author);
55
+		$this->assertEmailSent('[email protected]', '[email protected]', 'A new comment has been posted');
56 56
 
57
-        $email = $this->findEmail('[email protected]', '[email protected]', 'A new comment has been posted');
57
+		$email = $this->findEmail('[email protected]', '[email protected]', 'A new comment has been posted');
58 58
 
59
-        $this->assertContains('<li>Bob Bobberson</li>', $email['Content']);
60
-        $this->assertContains('<li>[email protected]</li>', $email['Content']);
61
-        $this->assertContains('<blockquote>Hey what a lovely comment</blockquote>', $email['Content']);
59
+		$this->assertContains('<li>Bob Bobberson</li>', $email['Content']);
60
+		$this->assertContains('<li>[email protected]</li>', $email['Content']);
61
+		$this->assertContains('<blockquote>Hey what a lovely comment</blockquote>', $email['Content']);
62 62
 
63
-        $this->clearEmails();
63
+		$this->clearEmails();
64 64
 
65
-        // Comment 2
66
-        $result = $controller->notifyCommentRecipient($comment2, $item2, $author);
67
-        $this->assertEmailSent('[email protected]', '[email protected]', 'A new comment has been posted');
65
+		// Comment 2
66
+		$result = $controller->notifyCommentRecipient($comment2, $item2, $author);
67
+		$this->assertEmailSent('[email protected]', '[email protected]', 'A new comment has been posted');
68 68
 
69
-        $email = $this->findEmail('[email protected]', '[email protected]', 'A new comment has been posted');
70
-        $this->assertContains('<li>Secret</li>', $email['Content']);
71
-        $this->assertContains('<li>[email protected]</li>', $email['Content']);
72
-        $this->assertContains('<blockquote>I don&#039;t want to disclose my details</blockquote>', $email['Content']);
69
+		$email = $this->findEmail('[email protected]', '[email protected]', 'A new comment has been posted');
70
+		$this->assertContains('<li>Secret</li>', $email['Content']);
71
+		$this->assertContains('<li>[email protected]</li>', $email['Content']);
72
+		$this->assertContains('<blockquote>I don&#039;t want to disclose my details</blockquote>', $email['Content']);
73 73
 
74
-        $this->clearEmails();
74
+		$this->clearEmails();
75 75
 
76
-        // Comment 3
77
-        $result = $controller->notifyCommentRecipient($comment3, $item1, $author);
78
-        $this->assertEmailSent('[email protected]', '[email protected]', 'A new comment has been posted');
76
+		// Comment 3
77
+		$result = $controller->notifyCommentRecipient($comment3, $item1, $author);
78
+		$this->assertEmailSent('[email protected]', '[email protected]', 'A new comment has been posted');
79 79
 
80
-        $email = $this->findEmail('[email protected]', '[email protected]', 'A new comment has been posted');
80
+		$email = $this->findEmail('[email protected]', '[email protected]', 'A new comment has been posted');
81 81
 
82
-        $this->assertContains('<li>Anonymous</li>', $email['Content']);
83
-        $this->assertContains('<li>[email protected]</li>', $email['Content']);
84
-        $this->assertContains('<blockquote>I didn&#039;t log in</blockquote>', $email['Content']);
82
+		$this->assertContains('<li>Anonymous</li>', $email['Content']);
83
+		$this->assertContains('<li>[email protected]</li>', $email['Content']);
84
+		$this->assertContains('<blockquote>I didn&#039;t log in</blockquote>', $email['Content']);
85 85
 
86
-        $this->clearEmails();
86
+		$this->clearEmails();
87 87
 
88
-        // Comment 3 without an author
89
-        $result = $controller->notifyCommentRecipient($comment3, $item1, '[email protected]');
90
-        $this->assertEmailSent('[email protected]', '[email protected]', 'A new comment has been posted');
88
+		// Comment 3 without an author
89
+		$result = $controller->notifyCommentRecipient($comment3, $item1, '[email protected]');
90
+		$this->assertEmailSent('[email protected]', '[email protected]', 'A new comment has been posted');
91 91
 
92
-        $this->clearEmails();
92
+		$this->clearEmails();
93 93
 
94
-        // Comment 3 without a valid email
95
-        $result = $controller->notifyCommentRecipient($comment3, $item1, '<foobar1>');
96
-        $noEmail = (bool) $this->findEmail('<foobar1>', '[email protected]', 'A new comment has been posted');
94
+		// Comment 3 without a valid email
95
+		$result = $controller->notifyCommentRecipient($comment3, $item1, '<foobar1>');
96
+		$noEmail = (bool) $this->findEmail('<foobar1>', '[email protected]', 'A new comment has been posted');
97 97
 
98
-        $this->assertFalse($noEmail);
99
-    }
98
+		$this->assertFalse($noEmail);
99
+	}
100 100
 
101
-    public function testOnAfterPostComment()
102
-    {
103
-        $this->clearEmails();
101
+	public function testOnAfterPostComment()
102
+	{
103
+		$this->clearEmails();
104 104
 
105
-        $comment1 = $this->objFromFixture(Comment::class, 'comment1');
105
+		$comment1 = $this->objFromFixture(Comment::class, 'comment1');
106 106
 
107
-        $controller = new CommentNotifierTestController();
108
-        $controller->invokeWithExtensions('onAfterPostComment', $comment1);
107
+		$controller = new CommentNotifierTestController();
108
+		$controller->invokeWithExtensions('onAfterPostComment', $comment1);
109 109
 
110
-        // test that after posting a comment the notifications are sent.
111
-        $this->assertEmailSent('[email protected]', '[email protected]', 'A new comment has been posted');
112
-    }
110
+		// test that after posting a comment the notifications are sent.
111
+		$this->assertEmailSent('[email protected]', '[email protected]', 'A new comment has been posted');
112
+	}
113 113
 }
Please login to merge, or discard this patch.
tests/Control/CommentNotifierTestController.php 1 patch
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -8,9 +8,9 @@
 block discarded – undo
8 8
 
9 9
 class CommentNotifierTestController extends Controller implements TestOnly
10 10
 {
11
-    private static $extensions = array(
12
-        CommentNotifier::class
13
-    );
11
+	private static $extensions = array(
12
+		CommentNotifier::class
13
+	);
14 14
 
15
-    private static $url_segment = 'commentnotifiertest';
15
+	private static $url_segment = 'commentnotifiertest';
16 16
 }
Please login to merge, or discard this patch.
tests/CommentNotifiableTest.php 1 patch
Indentation   +56 added lines, -56 removed lines patch added patch discarded remove patch
@@ -11,60 +11,60 @@
 block discarded – undo
11 11
 
12 12
 class CommentNotifiableTest extends SapphireTest
13 13
 {
14
-    protected static $fixture_file = 'CommentNotifications.yml';
15
-
16
-    protected $oldhost = null;
17
-
18
-    protected static $extra_dataobjects = [
19
-        CommentNotifiableTestDataObject::class
20
-    ];
21
-
22
-    protected function setUp()
23
-    {
24
-        parent::setUp();
25
-
26
-        Config::modify()->set(Email::class, 'admin_email', '[email protected]');
27
-
28
-        $this->oldhost = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : null;
29
-        $_SERVER['HTTP_HOST'] = 'www.mysite.com';
30
-    }
31
-
32
-    protected function tearDown()
33
-    {
34
-        $_SERVER['HTTP_HOST'] = $this->oldhost;
35
-
36
-        parent::tearDown();
37
-    }
38
-
39
-    public function testGetRecipients()
40
-    {
41
-        $comment1 = $this->objFromFixture(Comment::class, 'comment1');
42
-        $comment2 = $this->objFromFixture(Comment::class, 'comment2');
43
-        $item1 = $this->objFromFixture(CommentNotifiableTestDataObject::class, 'item1');
44
-        $item2 = $this->objFromFixture(CommentNotifiableTestDataObject::class, 'item2');
45
-
46
-        $this->assertEquals(['[email protected]', '[email protected]'], $item1->notificationRecipients($comment1));
47
-        $this->assertEquals(['[email protected]'], $item2->notificationRecipients($comment2));
48
-    }
49
-
50
-    public function testNotificationSubject()
51
-    {
52
-        $recipient = $this->objFromFixture(Member::class, 'author');
53
-        $comment1 = $this->objFromFixture(Comment::class, 'comment1');
54
-        $comment2 = $this->objFromFixture(Comment::class, 'comment2');
55
-        $item1 = $this->objFromFixture(CommentNotifiableTestDataObject::class, 'item1');
56
-        $item2 = $this->objFromFixture(CommentNotifiableTestDataObject::class, 'item2');
57
-
58
-        $this->assertEquals('A new comment has been posted', $item1->notificationSubject($comment1, $recipient));
59
-        $this->assertEquals('A new comment has been posted', $item2->notificationSubject($comment2, $recipient));
60
-    }
61
-
62
-    public function testNotificationSender()
63
-    {
64
-        $comment1 = $this->objFromFixture(Comment::class, 'comment1');
65
-        $author = $this->objFromFixture(Member::class, 'author');
66
-        $item1 = $this->objFromFixture(CommentNotifiableTestDataObject::class, 'item1');
67
-
68
-        $this->assertEquals('[email protected]', $item1->notificationSender($comment1, $author));
69
-    }
14
+	protected static $fixture_file = 'CommentNotifications.yml';
15
+
16
+	protected $oldhost = null;
17
+
18
+	protected static $extra_dataobjects = [
19
+		CommentNotifiableTestDataObject::class
20
+	];
21
+
22
+	protected function setUp()
23
+	{
24
+		parent::setUp();
25
+
26
+		Config::modify()->set(Email::class, 'admin_email', '[email protected]');
27
+
28
+		$this->oldhost = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : null;
29
+		$_SERVER['HTTP_HOST'] = 'www.mysite.com';
30
+	}
31
+
32
+	protected function tearDown()
33
+	{
34
+		$_SERVER['HTTP_HOST'] = $this->oldhost;
35
+
36
+		parent::tearDown();
37
+	}
38
+
39
+	public function testGetRecipients()
40
+	{
41
+		$comment1 = $this->objFromFixture(Comment::class, 'comment1');
42
+		$comment2 = $this->objFromFixture(Comment::class, 'comment2');
43
+		$item1 = $this->objFromFixture(CommentNotifiableTestDataObject::class, 'item1');
44
+		$item2 = $this->objFromFixture(CommentNotifiableTestDataObject::class, 'item2');
45
+
46
+		$this->assertEquals(['[email protected]', '[email protected]'], $item1->notificationRecipients($comment1));
47
+		$this->assertEquals(['[email protected]'], $item2->notificationRecipients($comment2));
48
+	}
49
+
50
+	public function testNotificationSubject()
51
+	{
52
+		$recipient = $this->objFromFixture(Member::class, 'author');
53
+		$comment1 = $this->objFromFixture(Comment::class, 'comment1');
54
+		$comment2 = $this->objFromFixture(Comment::class, 'comment2');
55
+		$item1 = $this->objFromFixture(CommentNotifiableTestDataObject::class, 'item1');
56
+		$item2 = $this->objFromFixture(CommentNotifiableTestDataObject::class, 'item2');
57
+
58
+		$this->assertEquals('A new comment has been posted', $item1->notificationSubject($comment1, $recipient));
59
+		$this->assertEquals('A new comment has been posted', $item2->notificationSubject($comment2, $recipient));
60
+	}
61
+
62
+	public function testNotificationSender()
63
+	{
64
+		$comment1 = $this->objFromFixture(Comment::class, 'comment1');
65
+		$author = $this->objFromFixture(Member::class, 'author');
66
+		$item1 = $this->objFromFixture(CommentNotifiableTestDataObject::class, 'item1');
67
+
68
+		$this->assertEquals('[email protected]', $item1->notificationSender($comment1, $author));
69
+	}
70 70
 }
Please login to merge, or discard this patch.
src/Extensions/CommentNotifiable.php 1 patch
Indentation   +108 added lines, -108 removed lines patch added patch discarded remove patch
@@ -11,112 +11,112 @@
 block discarded – undo
11 11
 class CommentNotifiable extends DataExtension
12 12
 {
13 13
 
14
-    /**
15
-     * Default subject line if the owner doesn't override it
16
-     *
17
-     * @config
18
-     * @var string
19
-     */
20
-    private static $default_notification_subject = 'A new comment has been posted';
21
-
22
-    /**
23
-     * Default sender
24
-     *
25
-     * @config
26
-     * @var string
27
-     */
28
-    private static $default_notification_sender = 'noreply@{host}';
29
-
30
-    /**
31
-     * Default template to use for comment notifications
32
-     *
33
-     * @config
34
-     * @var string
35
-     */
36
-    private static $default_notification_template = 'SilverStripe\\CommentNotifications\\CommentEmail';
37
-
38
-    /**
39
-     * Return the list of members or emails to send comment notifications to
40
-     *
41
-     * @param Comment $comment
42
-     * @return array|Traversable
43
-     */
44
-    public function notificationRecipients($comment)
45
-    {
46
-        $list = [];
47
-
48
-        if ($adminEmail = Email::config()->admin_email) {
49
-            $list[] = $adminEmail;
50
-        }
51
-
52
-        $this->owner->invokeWithExtensions('updateNotificationRecipients', $list, $comment);
53
-
54
-        return $list;
55
-    }
56
-
57
-    /**
58
-     * Gets the email subject line for comment notifications
59
-     *
60
-     * @param Comment $comment Comment
61
-     * @param Member|string $recipient
62
-     * @return string
63
-     */
64
-    public function notificationSubject($comment, $recipient)
65
-    {
66
-        $subject = $this->owner->config()->default_notification_subject;
67
-
68
-        $this->owner->invokeWithExtensions('updateNotificationSubject', $subject, $comment, $recipient);
69
-
70
-        return $subject;
71
-    }
72
-
73
-    /**
74
-     * Get the sender email address to use for email notifications
75
-     *
76
-     * @param Comment $comment
77
-     * @param Member|string $recipient
78
-     * @return string
79
-     */
80
-    public function notificationSender($comment, $recipient)
81
-    {
82
-        $sender = $this->owner->config()->default_notification_sender;
83
-
84
-        // Do hostname substitution
85
-        $host = isset($_SERVER['HTTP_HOST'])
86
-            ? preg_replace('/^www\./i', '', $_SERVER['HTTP_HOST'])
87
-            : 'localhost';
88
-        $sender = preg_replace('/{host}/', $host, $sender);
89
-
90
-        $this->owner->invokeWithExtensions('updateNotificationSender', $sender, $comment, $recipient);
91
-
92
-        return $sender;
93
-    }
94
-
95
-    /**
96
-     * Determine the template to use for this email
97
-     *
98
-     * @param Comment $comment
99
-     * @param Member|string $recipient
100
-     * @return string Template name (excluding .ss extension)
101
-     */
102
-    public function notificationTemplate($comment, $recipient)
103
-    {
104
-        $template = $this->owner->config()->default_notification_template;
105
-
106
-        $this->owner->invokeWithExtensions('updateNotificationTemplate', $template, $comment, $recipient);
107
-
108
-        return $template;
109
-    }
110
-
111
-    /**
112
-     * Update the notification email
113
-     *
114
-     * @param Email $email
115
-     * @param Comment $comment
116
-     * @param Member|string $recipient
117
-     */
118
-    public function updateCommentNotification($email, $comment, $recipient)
119
-    {
120
-        //
121
-    }
14
+	/**
15
+	 * Default subject line if the owner doesn't override it
16
+	 *
17
+	 * @config
18
+	 * @var string
19
+	 */
20
+	private static $default_notification_subject = 'A new comment has been posted';
21
+
22
+	/**
23
+	 * Default sender
24
+	 *
25
+	 * @config
26
+	 * @var string
27
+	 */
28
+	private static $default_notification_sender = 'noreply@{host}';
29
+
30
+	/**
31
+	 * Default template to use for comment notifications
32
+	 *
33
+	 * @config
34
+	 * @var string
35
+	 */
36
+	private static $default_notification_template = 'SilverStripe\\CommentNotifications\\CommentEmail';
37
+
38
+	/**
39
+	 * Return the list of members or emails to send comment notifications to
40
+	 *
41
+	 * @param Comment $comment
42
+	 * @return array|Traversable
43
+	 */
44
+	public function notificationRecipients($comment)
45
+	{
46
+		$list = [];
47
+
48
+		if ($adminEmail = Email::config()->admin_email) {
49
+			$list[] = $adminEmail;
50
+		}
51
+
52
+		$this->owner->invokeWithExtensions('updateNotificationRecipients', $list, $comment);
53
+
54
+		return $list;
55
+	}
56
+
57
+	/**
58
+	 * Gets the email subject line for comment notifications
59
+	 *
60
+	 * @param Comment $comment Comment
61
+	 * @param Member|string $recipient
62
+	 * @return string
63
+	 */
64
+	public function notificationSubject($comment, $recipient)
65
+	{
66
+		$subject = $this->owner->config()->default_notification_subject;
67
+
68
+		$this->owner->invokeWithExtensions('updateNotificationSubject', $subject, $comment, $recipient);
69
+
70
+		return $subject;
71
+	}
72
+
73
+	/**
74
+	 * Get the sender email address to use for email notifications
75
+	 *
76
+	 * @param Comment $comment
77
+	 * @param Member|string $recipient
78
+	 * @return string
79
+	 */
80
+	public function notificationSender($comment, $recipient)
81
+	{
82
+		$sender = $this->owner->config()->default_notification_sender;
83
+
84
+		// Do hostname substitution
85
+		$host = isset($_SERVER['HTTP_HOST'])
86
+			? preg_replace('/^www\./i', '', $_SERVER['HTTP_HOST'])
87
+			: 'localhost';
88
+		$sender = preg_replace('/{host}/', $host, $sender);
89
+
90
+		$this->owner->invokeWithExtensions('updateNotificationSender', $sender, $comment, $recipient);
91
+
92
+		return $sender;
93
+	}
94
+
95
+	/**
96
+	 * Determine the template to use for this email
97
+	 *
98
+	 * @param Comment $comment
99
+	 * @param Member|string $recipient
100
+	 * @return string Template name (excluding .ss extension)
101
+	 */
102
+	public function notificationTemplate($comment, $recipient)
103
+	{
104
+		$template = $this->owner->config()->default_notification_template;
105
+
106
+		$this->owner->invokeWithExtensions('updateNotificationTemplate', $template, $comment, $recipient);
107
+
108
+		return $template;
109
+	}
110
+
111
+	/**
112
+	 * Update the notification email
113
+	 *
114
+	 * @param Email $email
115
+	 * @param Comment $comment
116
+	 * @param Member|string $recipient
117
+	 */
118
+	public function updateCommentNotification($email, $comment, $recipient)
119
+	{
120
+		//
121
+	}
122 122
 }
Please login to merge, or discard this patch.
src/Extensions/CommentNotifier.php 1 patch
Indentation   +65 added lines, -65 removed lines patch added patch discarded remove patch
@@ -15,79 +15,79 @@
 block discarded – undo
15 15
 class CommentNotifier extends Extension
16 16
 {
17 17
 
18
-    /**
19
-     * Notify Members of the post there is a new comment.
20
-     *
21
-     * @param Comment $comment
22
-     */
23
-    public function onAfterPostComment(Comment $comment)
24
-    {
25
-        $parent = $comment->Parent();
18
+	/**
19
+	 * Notify Members of the post there is a new comment.
20
+	 *
21
+	 * @param Comment $comment
22
+	 */
23
+	public function onAfterPostComment(Comment $comment)
24
+	{
25
+		$parent = $comment->Parent();
26 26
 
27
-        if (!$parent || !$parent->hasMethod('notificationRecipients')) {
28
-            return;
29
-        }
27
+		if (!$parent || !$parent->hasMethod('notificationRecipients')) {
28
+			return;
29
+		}
30 30
 
31
-        // Ask parent to submit all recipients
32
-        $recipients = $parent->notificationRecipients($comment);
31
+		// Ask parent to submit all recipients
32
+		$recipients = $parent->notificationRecipients($comment);
33 33
 
34
-        foreach ($recipients as $recipient) {
35
-            $this->notifyCommentRecipient($comment, $parent, $recipient);
36
-        }
37
-    }
34
+		foreach ($recipients as $recipient) {
35
+			$this->notifyCommentRecipient($comment, $parent, $recipient);
36
+		}
37
+	}
38 38
 
39
-    /**
40
-     * Send comment notification to a given recipient
41
-     *
42
-     * @param Comment $comment
43
-     * @param DataObject $parent Object with the {@see CommentNotifiable} extension applied
44
-     * @param Member|string $recipient Either a member object or an email address to which notifications should be sent
45
-     */
46
-    public function notifyCommentRecipient($comment, $parent, $recipient)
47
-    {
48
-        $subject = $parent->notificationSubject($comment, $recipient);
49
-        $sender = $parent->notificationSender($comment, $recipient);
50
-        $template = $parent->notificationTemplate($comment, $recipient);
39
+	/**
40
+	 * Send comment notification to a given recipient
41
+	 *
42
+	 * @param Comment $comment
43
+	 * @param DataObject $parent Object with the {@see CommentNotifiable} extension applied
44
+	 * @param Member|string $recipient Either a member object or an email address to which notifications should be sent
45
+	 */
46
+	public function notifyCommentRecipient($comment, $parent, $recipient)
47
+	{
48
+		$subject = $parent->notificationSubject($comment, $recipient);
49
+		$sender = $parent->notificationSender($comment, $recipient);
50
+		$template = $parent->notificationTemplate($comment, $recipient);
51 51
 
52
-        // Validate email
53
-        // Important in case of the owner being a default-admin or a username with no contact email
54
-        $to = ($recipient instanceof Member) ? $recipient->Email : $recipient;
52
+		// Validate email
53
+		// Important in case of the owner being a default-admin or a username with no contact email
54
+		$to = ($recipient instanceof Member) ? $recipient->Email : $recipient;
55 55
 
56
-        if (!Email::is_valid_address($to)) {
57
-            return;
58
-        }
56
+		if (!Email::is_valid_address($to)) {
57
+			return;
58
+		}
59 59
 
60
-        // Prepare the email
61
-        $email = Email::create();
62
-        $email->setSubject($subject);
63
-        $email->setFrom($sender);
64
-        $email->setTo($to);
65
-        $email->setHTMLTemplate($template);
60
+		// Prepare the email
61
+		$email = Email::create();
62
+		$email->setSubject($subject);
63
+		$email->setFrom($sender);
64
+		$email->setTo($to);
65
+		$email->setHTMLTemplate($template);
66 66
 
67
-        if ($recipient instanceof Member) {
68
-            $email->setData([
69
-                'Parent' => $parent,
70
-                'Comment' => $comment,
71
-                'Recipient' => $recipient,
72
-                'ApproveLink' => $comment->ApproveLink($recipient),
73
-                'HamLink' => $comment->HamLink($recipient),
74
-                'SpamLink' => $comment->SpamLink($recipient),
75
-                'DeleteLink' => $comment->DeleteLink($recipient),
76
-            ]);
77
-        } else {
78
-            $email->setData([
79
-                'Parent' => $parent,
80
-                'Comment' => $comment,
81
-                'ApproveLink' => false,
82
-                'SpamLink' => false,
83
-                'DeleteLink' => false,
84
-                'HamLink' => false,
85
-                'Recipient' => $recipient
86
-            ]);
87
-        }
67
+		if ($recipient instanceof Member) {
68
+			$email->setData([
69
+				'Parent' => $parent,
70
+				'Comment' => $comment,
71
+				'Recipient' => $recipient,
72
+				'ApproveLink' => $comment->ApproveLink($recipient),
73
+				'HamLink' => $comment->HamLink($recipient),
74
+				'SpamLink' => $comment->SpamLink($recipient),
75
+				'DeleteLink' => $comment->DeleteLink($recipient),
76
+			]);
77
+		} else {
78
+			$email->setData([
79
+				'Parent' => $parent,
80
+				'Comment' => $comment,
81
+				'ApproveLink' => false,
82
+				'SpamLink' => false,
83
+				'DeleteLink' => false,
84
+				'HamLink' => false,
85
+				'Recipient' => $recipient
86
+			]);
87
+		}
88 88
 
89
-        $this->owner->invokeWithExtensions('updateCommentNotification', $email, $comment, $recipient);
89
+		$this->owner->invokeWithExtensions('updateCommentNotification', $email, $comment, $recipient);
90 90
 
91
-        return $email->send();
92
-    }
91
+		return $email->send();
92
+	}
93 93
 }
Please login to merge, or discard this patch.