DownloadAttachmentEvent   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 2
dl 0
loc 46
ccs 0
cts 7
cp 0
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A init() 0 8 2
1
<?php
2
3
/**
4
 * @copyright  Copyright (c) Flipbox Digital Limited
5
 * @license    https://flipboxfactory.com/software/force/license
6
 * @link       https://www.flipboxfactory.com/software/force/
7
 */
8
9
namespace flipbox\craft\salesforce\events;
10
11
use Craft;
12
use yii\base\Event;
13
14
/**
15
 * @author Flipbox Factory <[email protected]>
16
 * @since 1.2.0
17
 */
18
class DownloadAttachmentEvent extends Event
19
{
20
    /**
21
     * The 'Content Version' Salesforce Object which contained the file.
22
     *
23
     * Ref: https://developer.salesforce.com/docs/atlas.en-us.object_reference.meta/object_reference/sforce_api_objects_contentversion.htm
24
     * @var array
25
     */
26
    public $object;
27
28
    /**
29
     * The file name.
30
     *
31
     * @var string
32
     */
33
    public $fileName;
34
35
    /**
36
     * The raw file contents.
37
     *
38
     * @var string
39
     */
40
    public $fileContents;
41
42
    /**
43
     * @var bool whether the document can be downloaded. Defaults to true.
44
     */
45
    public $canDownload;
46
47
    /**
48
     * @var bool whether the document can be downloaded. Defaults to true.
49
     */
50
    public $unauthorizedMessage = "Unauthorized";
51
52
    /**
53
     * Allow ONLY admins to download everything by default
54
     */
55
    public function init()
56
    {
57
        if (null === $this->canDownload) {
58
            $this->canDownload = Craft::$app->getUser()->getIsAdmin();
59
        }
60
61
        parent::init();
62
    }
63
}
64