GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

GridFieldExportAction::handleAction()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 4
1
<?php
2
3
namespace Symbiote\AdvancedWorkflow\Forms\GridField;
4
5
use SilverStripe\Control\Controller;
6
use SilverStripe\Control\Director;
7
use SilverStripe\Core\Config\Config;
8
use SilverStripe\Forms\GridField\GridField;
9
use SilverStripe\Forms\GridField\GridField_ActionProvider;
10
use SilverStripe\Forms\GridField\GridField_ColumnProvider;
11
use SilverStripe\Forms\GridField\GridField_FormAction;
12
use SilverStripe\ORM\DataObject;
13
use SilverStripe\Security\Permission;
14
use SilverStripe\View\ArrayData;
15
use SilverStripe\View\SSViewer;
16
use Symbiote\AdvancedWorkflow\Admin\AdvancedWorkflowAdmin;
17
18
/**
19
 * This class is a {@link GridField} component that adds an export action for
20
 * WorkflowDefinition objects shown in GridFields.
21
 *
22
 * @license BSD License (http://silverstripe.org/bsd-license/)
23
 * @package advancedworkflow
24
 */
25
class GridFieldExportAction implements GridField_ColumnProvider, GridField_ActionProvider
26
{
27
    /**
28
     * Add a column 'Delete'
29
     *
30
     * @param GridField $gridField
31
     * @param array $columns
32
     */
33
    public function augmentColumns($gridField, &$columns)
34
    {
35
        if (!in_array('Actions', $columns)) {
36
            $columns[] = 'Actions';
37
        }
38
    }
39
40
    /**
41
     * Return any special attributes that will be used for FormField::create_tag()
42
     *
43
     * @param GridField $gridField
44
     * @param DataObject $record
45
     * @param string $columnName
46
     * @return array
47
     */
48
    public function getColumnAttributes($gridField, $record, $columnName)
49
    {
50
        return array('class' => 'grid-field__col-compact');
51
    }
52
53
    /**
54
     * Add the title
55
     *
56
     * @param GridField $gridField
57
     * @param string $columnName
58
     * @return array
59
     */
60
    public function getColumnMetadata($gridField, $columnName)
61
    {
62
        if ($columnName == 'Actions') {
63
            return array('title' => '');
64
        }
65
    }
66
67
    /**
68
     * Which columns are handled by this component
69
     *
70
     * @param type $gridField
71
     * @return type
72
     */
73
    public function getColumnsHandled($gridField)
74
    {
75
        return array('Actions');
76
    }
77
78
    /**
79
     * Which GridField actions are this component handling
80
     *
81
     * @param GridField $gridField
82
     * @return array
83
     */
84
    public function getActions($gridField)
85
    {
86
        return array('exportrecord');
87
    }
88
89
    /**
90
     *
91
     * @param GridField $gridField
92
     * @param DataObject $record
93
     * @param string $columnName
94
     * @return string - the HTML for the column
95
     */
96
    public function getColumnContent($gridField, $record, $columnName)
97
    {
98
        // Disable the export icon if current user doesn't have access to view CMS Security settings
99
        if (!Permission::check('CMS_ACCESS_SecurityAdmin')) {
100
            return '';
101
        }
102
103
        $field = GridField_FormAction::create(
104
            $gridField,
105
            'ExportRecord' . $record->ID,
106
            false,
107
            "exportrecord",
108
            array('RecordID' => $record->ID)
109
        )
110
            ->addExtraClass('btn btn--no-text btn--icon-md font-icon-export');
111
112
        $segment1 = Director::baseURL();
113
        $segment2 = Config::inst()->get(AdvancedWorkflowAdmin::class, 'url_segment');
114
        $segment3 = str_replace('\\', '-', $record->getClassName());
115
        $data = new ArrayData(array(
116
            'Link' => Controller::join_links($segment1, 'admin', $segment2, $segment3, 'export', $record->ID),
117
            'ExtraClass' => $field->extraClass(),
118
        ));
119
120
        $template = SSViewer::get_templates_by_class($this, '', __CLASS__);
121
        return $data->renderWith($template);
122
    }
123
124
    /**
125
     * Handle the actions and apply any changes to the GridField
126
     *
127
     * @param GridField $gridField
128
     * @param string $actionName
129
     * @param mixed $arguments
130
     * @param array $data - form data
131
     * @return void
132
     */
133
    public function handleAction(GridField $gridField, $actionName, $arguments, $data)
134
    {
135
    }
136
}
137