Skip to content

Commit ee32fa8

Browse files
add: Stubs for Page and PageController to ensure these symbols also exist for modules (#18)
1 parent 0222b18 commit ee32fa8

File tree

3 files changed

+26
-0
lines changed

3 files changed

+26
-0
lines changed

bootstrap.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,16 @@
1717
exit(1);
1818
}
1919

20+
// Ensure that the `Page` and `PageController` classes exist, if they don't _(for example when testing a
21+
// silverstripe module)_ ensure that the symbols are registered.
22+
if (!class_exists(\Page::class)) {
23+
require __DIR__ . '/stubs/Page.php';
24+
}
25+
26+
if (!class_exists(\PageController::class)) {
27+
require __DIR__ . '/stubs/PageController.php';
28+
}
29+
2030
// Ensure global $_SERVER exists
2131
global $_SERVER;
2232
if (!$_SERVER) {

stubs/Page.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?php
2+
3+
namespace {
4+
5+
use SilverStripe\CMS\Model\SiteTree;
6+
7+
class Page extends SiteTree {}
8+
}

stubs/PageController.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?php
2+
3+
namespace {
4+
5+
use SilverStripe\CMS\Controllers\ContentController;
6+
7+
class PageController extends ContentController {}
8+
}

0 commit comments

Comments
 (0)