GridFieldEditButtonOriginalPage   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 4
dl 0
loc 25
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A getColumnContent() 0 13 2
1
<?php
2
3
/**
4
 * Provides the entry point to editing a single record presented by the
5
 * {@link GridField}.
6
 *
7
 * Doesn't show an edit view on its own or modifies the record, but rather
8
 * relies on routing conventions established in {@link getColumnContent()}.
9
 *
10
 * The default routing applies to the {@link GridFieldDetailForm} component,
11
 * which has to be added separately to the {@link GridField} configuration.
12
 *
13
 * @package forms
14
 * @subpackage fields-gridfield
15
 */
16
class GridFieldEditButtonOriginalPage extends GridFieldEditButton implements GridField_ColumnProvider
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
17
{
18
19
20
    /**
21
     * @param GridField $gridField
22
     * @param DataObject $record
23
     * @param string $columnName
24
     *
25
     * @return string - the HTML for the column
0 ignored issues
show
Documentation introduced by
Should the return type not be HTMLText?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
26
     */
27
    public function getColumnContent($gridField, $record, $columnName)
28
    {
29
        // No permission checks, handled through GridFieldDetailForm,
30
        // which can make the form readonly if no edit permissions are available.
31
        if ($record->hasMethod("CMSEditLink")) {
32
            $data = new ArrayData(array(
33
                'Link' => Controller::join_links($record->CMSEditLink())
34
            ));
35
            return $data->renderWith('GridFieldEditButtonInSiteTree');
36
        } else {
37
            return parent::getColumnContent($gridField, $record, $columnName);
38
        }
39
    }
40
}
41