1
|
|
|
<?php |
2
|
|
|
namespace UserManagement\Page; |
3
|
|
|
|
4
|
|
|
use Page; |
|
|
|
|
5
|
|
|
use SilverStripe\ORM\DataObject; |
6
|
|
|
use SilverStripe\ORM\DB; |
7
|
|
|
|
8
|
|
|
/** |
9
|
|
|
* Class UserRegistrationPage |
10
|
|
|
* |
11
|
|
|
* @package user-management |
12
|
|
|
*/ |
13
|
|
|
class UserRegistrationPage extends Page |
14
|
|
|
{ |
15
|
|
|
|
16
|
|
|
private static $table_name = 'UserManagement_UserRegistrationPage'; |
|
|
|
|
17
|
|
|
|
18
|
|
|
public function canCreate($member = null, $context = array()) |
19
|
|
|
{ |
20
|
|
|
return !self::get()->exists(); |
21
|
|
|
} |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* Returns the link or the URLSegment to the user registration page on this site |
25
|
|
|
* |
26
|
|
|
* @param boolean $urlSegment Return the URLSegment only |
27
|
|
|
* |
28
|
|
|
* @return mixed |
29
|
|
|
*/ |
30
|
|
|
public static function find_link($urlSegment = false) |
31
|
|
|
{ |
32
|
|
|
$page = self::get_if_registration_page_exists(); |
33
|
|
|
return ($urlSegment) ? $page->URLSegment : $page->Link(); |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* @return UserRegistrationPage |
38
|
|
|
*/ |
39
|
|
|
protected static function get_if_registration_page_exists() |
40
|
|
|
{ |
41
|
|
|
if ($page = DataObject::get_one(self::class)) { |
42
|
|
|
return $page; |
|
|
|
|
43
|
|
|
} |
44
|
|
|
user_error(_t(__CLASS__ . '.NoPage', 'No UserRegistrationPage was found. |
45
|
|
|
Please create one in the CMS!'), E_USER_ERROR); |
46
|
|
|
return null; // just to keep static analysis happy |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* This module always requires a page model. |
51
|
|
|
*/ |
52
|
|
|
public function requireDefaultRecords() |
53
|
|
|
{ |
54
|
|
|
parent::requireDefaultRecords(); |
55
|
|
|
if (!self::get()->exists() && $this->config()->create_default_pages) { |
56
|
|
|
/** |
57
|
|
|
* @var UserRegistrationPage $page |
58
|
|
|
*/ |
59
|
|
|
$page = self::create()->update( |
60
|
|
|
[ |
61
|
|
|
'Title' => 'UserRegistration', |
62
|
|
|
'URLSegment' => UserRegistrationPageController::config()->url_segment, |
63
|
|
|
'ShowInMenus' => 0, |
64
|
|
|
] |
65
|
|
|
); |
66
|
|
|
$page->write(); |
67
|
|
|
$page->publishSingle(); |
68
|
|
|
$page->flushCache(); |
69
|
|
|
DB::alteration_message('UserRegistration page created', 'created'); |
70
|
|
|
} |
71
|
|
|
} |
72
|
|
|
} |
73
|
|
|
|
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:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths