Completed
Push — master ( b444db...de0e8e )
by Robbie
11s
created

src/Model/BlogPostNotifications.php (2 issues)

Severity

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
namespace SilverStripe\Blog\Model;
4
5
use SilverStripe\ORM\DataExtension;
6
7
/**
8
 * Customise blog post to support comment notifications.
9
 *
10
 * Extends {@see BlogPost} with extensions to {@see CommentNotifiable}.
11
 */
12
class BlogPostNotifications extends DataExtension
13
{
14
    /**
15
     * Configure whether to send notifications even for spam comments
16
     * @config
17
     */
18
    private static $notification_on_spam = true;
19
20
    /**
21
     * Notify all authors of notifications.
22
     *
23
     * @param SS_List $list
24
     * @param mixed $comment
25
     */
26
    public function updateNotificationRecipients(&$list, &$comment)
27
    {
28
        //default is notification is on regardless of spam status
29
        $list = $this->owner->Authors();
30
31
        // If comment is spam and notification are set to not send on spam clear the recipient list
32
        if (Config::inst()->get(__CLASS__, 'notification_on_spam') == false && $comment->IsSpam) {
33
            $list = [];
34
        }
35
    }
36
37
    /**
38
     * Update comment to include the page title.
39
     *
40
     * @param string $subject
41
     * @param Comment $comment
42
     * @param Member|string $recipient
43
     */
44
    public function updateNotificationSubject(&$subject, &$comment, &$recipient)
0 ignored issues
show
The parameter $comment is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
The parameter $recipient is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
45
    {
46
        $subject = sprintf('A new comment has been posted on %s', $this->owner->Title);
47
    }
48
}
49