1 | <?php |
||
2 | |||
3 | namespace SilverStripe\CampaignAdmin; |
||
4 | |||
5 | use SilverStripe\Forms\FieldList; |
||
6 | use SilverStripe\Forms\Tab; |
||
7 | use SilverStripe\ORM\DataExtension; |
||
8 | use SilverStripe\Security\Permission; |
||
9 | |||
10 | /** |
||
11 | * Handles adding the "Add to Campaign" button to a page's secondary actions menu |
||
12 | */ |
||
13 | class SiteTreeExtension extends DataExtension |
||
14 | { |
||
15 | public function updateCMSActions(FieldList $actions) |
||
16 | { |
||
17 | // Add to campaign option if not-archived and has publish permission |
||
18 | if ((!$this->owner->isPublished() && !$this->owner->isOnDraft()) |
||
19 | || !$this->owner->canPublish() |
||
20 | || !Permission::check('CMS_ACCESS_CampaignAdmin') |
||
21 | ) { |
||
22 | return; |
||
23 | } |
||
24 | |||
25 | /** @var Tab $moreOptions */ |
||
26 | $moreOptions = $actions->fieldByName('ActionMenus.MoreOptions'); |
||
0 ignored issues
–
show
|
|||
27 | if (!$moreOptions) { |
||
0 ignored issues
–
show
|
|||
28 | return; |
||
29 | } |
||
30 | |||
31 | $moreOptions->insertAfter( |
||
32 | 'Information', |
||
33 | AddToCampaignHandler_FormAction::create() |
||
34 | ->removeExtraClass('btn-primary') |
||
35 | ->addExtraClass('btn-secondary') |
||
36 | ); |
||
37 | } |
||
38 | } |
||
39 |
This check looks for function or method calls that always return null and whose return value is assigned to a variable.
The method
getObject()
can return nothing but null, so it makes no sense to assign that value to a variable.The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.