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.

AdvancedWorkflowActionController   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Importance

Changes 0
Metric Value
wmc 8
lcom 1
cbo 5
dl 0
loc 49
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
B transition() 0 46 8
1
<?php
2
3
namespace Symbiote\AdvancedWorkflow\Controllers;
4
5
use SilverStripe\Control\Controller;
6
use SilverStripe\Control\Director;
7
use SilverStripe\Core\Convert;
8
use SilverStripe\ORM\DataObject;
9
use SilverStripe\Security\Security;
10
use Symbiote\AdvancedWorkflow\DataObjects\WorkflowInstance;
11
use Symbiote\AdvancedWorkflow\DataObjects\WorkflowTransition;
12
use Symbiote\AdvancedWorkflow\Services\WorkflowService;
13
14
/**
15
 * Handles actions triggered from external sources, eg emails or web frontend
16
 *
17
 * @author [email protected]
18
 * @license BSD License http://silverstripe.org/bsd-license/
19
 */
20
class AdvancedWorkflowActionController extends Controller
21
{
22
    public function transition($request)
0 ignored issues
show
Unused Code introduced by
The parameter $request 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...
23
    {
24
        if (!Security::getCurrentUser()) {
25
            return Security::permissionFailure(
26
                $this,
27
                _t(
28
                    'AdvancedWorkflowActionController.ACTION_ERROR',
29
                    "You must be logged in"
30
                )
31
            );
32
        }
33
34
        $id = $this->request->requestVar('id');
35
        $transition = $this->request->requestVar('transition');
36
37
        $instance = DataObject::get_by_id(WorkflowInstance::class, (int) $id);
38
        if ($instance && $instance->canEdit()) {
39
            $transition = DataObject::get_by_id(WorkflowTransition::class, (int) $transition);
40
            if ($transition) {
41
                if ($this->request->requestVar('comments')) {
42
                    $action = $instance->CurrentAction();
43
                    $action->Comment = $this->request->requestVar('comments');
44
                    $action->write();
45
                }
46
47
                singleton(WorkflowService::class)->executeTransition($instance->getTarget(), $transition->ID);
48
                $result = array(
49
                    'success' => true,
50
                    'link'    => $instance->getTarget()->AbsoluteLink()
51
                );
52
                if (Director::is_ajax()) {
53
                    return json_encode($result);
54
                }
55
                return $this->redirect($instance->getTarget()->Link());
56
            }
57
        }
58
59
        if (Director::is_ajax()) {
60
            $result = array(
61
                'success' => false,
62
            );
63
            return json_encode($result);
64
        }
65
66
        return $this->redirect($instance->getTarget()->Link());
67
    }
68
}
69