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