1 | <?php |
||
2 | |||
3 | namespace Dynamic\ManageableDataObject\Extensions; |
||
4 | |||
5 | use SilverStripe\Control\Controller; |
||
6 | use SilverStripe\ORM\DataExtension; |
||
7 | use SilverStripe\Security\Security; |
||
8 | |||
9 | /** |
||
10 | * Class ManageableObjectExtension |
||
11 | * |
||
12 | * @property \Dynamic\ManageableDataObject\Extensions\ManageableObjectExtension|\SilverStripe\ORM\DataObject $owner |
||
13 | */ |
||
14 | class ManageableObjectExtension extends DataExtension |
||
15 | { |
||
16 | |||
17 | /** |
||
18 | * Get the listing page to view this Event on (used in Link functions below) |
||
19 | * |
||
20 | * @return mixed |
||
21 | */ |
||
22 | 4 | public function getListingPage() |
|
23 | { |
||
24 | |||
25 | 4 | $listingClass = $this->owner->config()->get('listing_page_class'); |
|
0 ignored issues
–
show
|
|||
26 | |||
27 | 4 | if ($listingPage = $listingClass::get()->first()) { |
|
28 | 4 | return $listingPage; |
|
29 | } |
||
30 | |||
31 | return false; |
||
32 | } |
||
33 | |||
34 | /** |
||
35 | * @return bool |
||
36 | */ |
||
37 | 1 | public function getAddLink() |
|
38 | { |
||
39 | 1 | if ($this->owner->getListingPage()->hasMethod('Link') && $this->owner->canCreate(Security::getCurrentUser())) { |
|
40 | 1 | return $this->owner->getListingPage()->Link('add'); |
|
41 | } |
||
42 | |||
43 | 1 | return false; |
|
44 | } |
||
45 | |||
46 | /** |
||
47 | * @return bool|String |
||
48 | */ |
||
49 | 1 | public function getEditLink() |
|
50 | { |
||
51 | 1 | if ($this->owner->getListingPage()->hasMethod('Link') && $this->owner->canEdit(Security::getCurrentUser())) { |
|
52 | 1 | $field = ($this->owner->config()->get('query_field')) |
|
53 | ? $this->owner->config()->get('query_field') |
||
54 | 1 | : 'ID'; |
|
55 | |||
56 | 1 | return Controller::join_links($this->owner->getListingPage()->Link('edit'), $this->owner->$field); |
|
57 | } |
||
58 | |||
59 | 1 | return false; |
|
60 | } |
||
61 | |||
62 | /** |
||
63 | * @return bool|String |
||
64 | */ |
||
65 | 1 | public function getDeleteLink() |
|
66 | { |
||
67 | 1 | if ($this->owner->getListingPage()->hasMethod('Link') && $this->owner->canDelete(Security::getCurrentUser())) { |
|
68 | 1 | $field = ($this->owner->config()->get('query_field')) |
|
69 | ? $this->owner->config()->get('query_field') |
||
70 | 1 | : 'ID'; |
|
71 | |||
72 | 1 | return Controller::join_links($this->owner->getListingPage()->Link('delete'), $this->owner->$field); |
|
73 | } |
||
74 | |||
75 | 1 | return false; |
|
76 | } |
||
77 | |||
78 | } |
||
79 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.