Passed
Push — master ( 36d94c...6f4de6 )
by Sathish
01:39
created

UserRegistrationPageController   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 14
dl 0
loc 29
rs 10
c 0
b 0
f 0
wmc 6

2 Methods

Rating   Name   Duplication   Size   Complexity  
A init() 0 8 4
A SignUpForm() 0 8 2
1
<?php
2
namespace UserManagement\Page;
3
4
use PageController;
0 ignored issues
show
Bug introduced by
The type PageController was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
5
use SilverStripe\Security\Member;
6
use UserManagement\Forms\SignUpForm;
7
use SilverStripe\SiteConfig\SiteConfig;
8
9
/**
10
 * Class UserRegistrationPageController
11
 *
12
 * @package user-management
13
 */
14
class UserRegistrationPageController extends PageController
15
{
16
    private static $url_segment = 'user-registration';
0 ignored issues
show
introduced by
The private property $url_segment is not used, and could be removed.
Loading history...
17
18
    private static $allowed_actions = array('SignUpForm');
0 ignored issues
show
introduced by
The private property $allowed_actions is not used, and could be removed.
Loading history...
19
20
    public function init()
21
    {
22
        parent::init();
23
        $member = Member::currentUser();
0 ignored issues
show
Deprecated Code introduced by
The function SilverStripe\Security\Member::currentUser() has been deprecated: 5.0.0 use Security::getCurrentUser() ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

23
        $member = /** @scrutinizer ignore-deprecated */ Member::currentUser();

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
24
        if ($member && $member->exists()) {
25
            $config = SiteConfig::current_site_config();
26
            if ($config->LoginCallBackUrl()->URLSegment) {
27
                return $this->redirect($config->LoginCallBackUrl()->URLSegment);
28
            }
29
        }
30
    }
31
32
    /**
33
     * @return object
34
     */
35
    public function SignUpForm()
36
    {
37
        $form = new SignUpForm($this, 'SignUpForm');
38
        $config = SiteConfig::current_site_config();
39
        if ($config->EnableSpamProtection) {
40
            $form->enableSpamProtection();
0 ignored issues
show
Bug introduced by
The method enableSpamProtection() does not exist on UserManagement\Forms\SignUpForm. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

40
            $form->/** @scrutinizer ignore-call */ 
41
                   enableSpamProtection();
Loading history...
41
        }
42
        return $form;
43
    }
44
}
45