DraftNotifications_EventCallbackService   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 6
c 1
b 0
f 0
lcom 0
cbo 0
dl 0
loc 41
ccs 14
cts 14
cp 1
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A deleteDraftCallback() 0 4 1
A deleteEntryCallback() 0 4 1
A saveDraftCallBack() 0 5 2
A saveEntryCallback() 0 5 2
1
<?php
2
3
namespace Craft;
4
5
/**
6
 * Class DraftNotifications_EventsService
7
 */
8
class DraftNotifications_EventCallbackService extends BaseApplicationComponent
9
{
10
    const STATUS_NEW_DRAFT = 'savedNewDraft';
11
    const STATUS_EXISTING_DRAFT = 'savedExistingDraft';
12
    const STATUS_DELETED_DRAFT = 'deletedDraft';
13
14
15
    /**
16
     * @param Event $event
17
     */
18 2
    public static function saveDraftCallBack(Event $event)
19
    {
20 2
        $status = $event->params['isNewDraft'] ? self::STATUS_NEW_DRAFT : self::STATUS_EXISTING_DRAFT;
21 2
        craft()->draftNotifications->sendNotifications($event->params['draft'], $status);
22 2
    }
23
24
    /**
25
     * @param Event $event
26
     */
27 1
    public function deleteDraftCallback(Event $event)
28
    {
29 1
        craft()->draftNotifications->sendNotifications($event->params['draft'], self::STATUS_DELETED_DRAFT);
30 1
    }
31
32
    /**
33
     * @param Event $event
34
     */
35 2
    public function saveEntryCallback(Event $event)
36
    {
37 2
        $status = $event->params['isNewEntry'] ? self::STATUS_NEW_DRAFT : self::STATUS_EXISTING_DRAFT;
38 2
        craft()->draftNotifications->sendNotifications($event->params['entry'], $status);
39 2
    }
40
41
    /**
42
     * @param Event $event
43
     */
44 1
    public function deleteEntryCallback(Event $event)
45
    {
46 1
        craft()->draftNotifications->sendNotifications($event->params['entry'], self::STATUS_DELETED_DRAFT);
47
    }
48
}