Completed
Push — master ( f3b14d...1fe4c3 )
by Damian
10s
created

TestWidgetController::Form()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 15
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 15
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 9
nc 1
nop 0
1
<?php
2
3
namespace SilverStripe\Widgets\Tests\WidgetControllerTest;
4
5
use SilverStripe\Dev\TestOnly;
6
use SilverStripe\Forms\FieldList;
7
use SilverStripe\Forms\Form;
8
use SilverStripe\Forms\FormAction;
9
use SilverStripe\Forms\TextField;
10
use SilverStripe\Widgets\Controllers\WidgetController;
11
12
/**
13
 * @package widgets
14
 * @subpackage tests
15
 */
16
class TestWidgetController extends WidgetController implements TestOnly
17
{
18
    private static $allowed_actions = array(
0 ignored issues
show
Comprehensibility introduced by
Consider using a different property name as you override a private property of the parent class.
Loading history...
Unused Code introduced by
The property $allowed_actions is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
19
        'Form'
20
    );
21
22
    public function Form()
23
    {
24
        $widgetform = new Form(
25
            $this,
26
            'Form',
27
            new FieldList(
28
                new TextField('TestValue')
29
            ),
30
            new FieldList(
31
                new FormAction('doAction')
32
            )
33
        );
34
35
        return $widgetform;
36
    }
37
38
    public function doAction($data, $form)
0 ignored issues
show
Unused Code introduced by
The parameter $form is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
39
    {
40
        return sprintf(
41
            'TestValue: %s\nWidget ID: %d',
42
            $data['TestValue'],
43
            $this->widget->ID
44
        );
45
    }
46
}
47