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