Issues (31)

src/Page/UserRegistrationPageController.php (4 issues)

Labels
1
<?php
2
namespace UserManagement\Page;
3
4
use PageController;
0 ignored issues
show
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 UserManagement\Forms\SignUpForm;
6
use SilverStripe\SiteConfig\SiteConfig;
7
use SilverStripe\Security\Security;
8
9
/**
10
 * Class UserRegistrationPageController
11
 *
12
 * @package user-management
13
 */
14
class UserRegistrationPageController extends PageController
15
{
16
    /**
17
     * @var string
18
     */
19
    private static $url_segment = 'user-registration';
0 ignored issues
show
The private property $url_segment is not used, and could be removed.
Loading history...
20
21
    /**
22
     * @var array
23
     */
24
    private static $allowed_actions = array('SignUpForm');
0 ignored issues
show
The private property $allowed_actions is not used, and could be removed.
Loading history...
25
26 2
    public function init()
27
    {
28 2
        parent::init();
29 2
        $member = Security::getCurrentUser();
30 2
        if ($member && $member->exists()) {
31
            $config = SiteConfig::current_site_config();
32
            if ($config->LoginCallBackUrl()->URLSegment) {
33
                return $this->redirect($config->LoginCallBackUrl()->URLSegment);
34
            }
35
        }
36
    }
37
38
    /**
39
     * @method string enableSpamProtection()
40
     * @return object
41
     */
42 2
    public function SignUpForm()
43
    {
44 2
        $form = new SignUpForm($this, 'SignUpForm');
45 2
        $config = SiteConfig::current_site_config();
46 2
        if ($config->EnableSpamProtection && class_exists('UndefinedOffset\NoCaptcha\Forms\NocaptchaField')) {
47
            $form->enableSpamProtection();
0 ignored issues
show
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

47
            $form->/** @scrutinizer ignore-call */ 
48
                   enableSpamProtection();
Loading history...
48
        }
49 2
        return $form;
50
    }
51
}
52