Completed
Pull Request — master (#7)
by
unknown
63:17
created

MyTwitterData::forTemplate()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace SunnySideUp\ShareThis;
4
5
use SilverStripe\Core\Config\Config;
6
use SilverStripe\Security\Permission;
7
use SilverStripe\ORM\DataObject;
8
9
/**
10
 * MyTwitterData
11
 */
12
class MyTwitterData extends DataObject
13
{
14
    private static $username = "";
15
16
    private static $db = array(
17
        "Date" => "SS_Datetime",
18
        "TwitterID" => "Varchar(64)",
19
        "Title" => "HTMLText",
20
        "Hide" => "Boolean"
21
    );
22
23
    private static $summary_fields = array(
24
        "Date" => "Date",
25
        "Title" => "Title",
26
        "HideNice" => "Hide"
27
    );
28
29
    private static $indexes = array(
30
        "TwitterID" => true
31
    );
32
33
    private static $casting = array(
34
        "Link" => "Varchar",
35
        "HideNice" => "Varchar"
36
    );
37
38
    private static $default_sort = "\"Date\" DESC";
39
40
    public function forTemplate()
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
41
    {
42
        return $this->Title;
43
    }
44
45
    public function Link()
46
    {
47
        return "https://twitter.com/".Config::inst()->get(MyTwitterData::class, "username")."/status/".$this->TwitterID;
48
    }
49
50
51
    public function canView($member = null)
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
52
    {
53
        return Permission::checkMember($member, 'SOCIAL_MEDIA');
54
    }
55
56
    public function canCreate($member = null, $context = [])
57
    {
58
        return false;
59
    }
60
61
    public function canEdit($member = null)
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
62
    {
63
        return Permission::checkMember($member, 'SOCIAL_MEDIA');
64
    }
65
66
    public function canDelete($member = null)
67
    {
68
        return false;
69
    }
70
71
    public function HideNice()
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
72
    {
73
        return $this->dbObject('Hide')->Nice();
74
    }
75
}
76